Skip to content

Commit dd926cc

Browse files
authored
Merge pull request #4 from pfizer-opensource/copilot/add-dili-discovery-proteomics-vignette
Add DILI Discovery Proteomics vignette
2 parents 114a478 + 9c7ce3f commit dd926cc

65 files changed

Lines changed: 4686 additions & 931 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

BuildSupport/BuildMe.R

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,37 @@ devtools::document(); devtools::load_all()
3939
rmarkdown::render("README.Rmd",
4040
output_file="README.md")
4141

42+
rm(list = ls()); gc()
43+
devtools::document(); devtools::load_all()
44+
45+
# build images
46+
source(file.path(getwd(), "data-raw/shiny_ui/shiny_shots_optimized.R"))
47+
48+
49+
list_rmds <- file.path(getwd(), "vignettes") |>
50+
list.files(pattern = ".Rmd", full.names = TRUE) |>
51+
stringr::str_subset("0[1-9]|DILI")
52+
53+
rendering_list_rmds <-list_rmds #[6]
54+
55+
# file.edit(list_rmds[3])
56+
57+
rendering_list_rmds|>
58+
purrr::set_names(~basename(.x)) |>
59+
purrr::iwalk(function(x,y){
60+
61+
md_name <- y |>
62+
stringr::str_replace("[.]Rmd", ".md")
63+
64+
rmarkdown::render(x,
65+
output_dir = file.path(getwd(), "vignettes"),
66+
output_file = md_name)
67+
68+
})
69+
70+
71+
72+
4273

4374
devtools::test(stop_on_failure = TRUE)
4475

DESCRIPTION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: Hotgenes
22
Type: Package
33
Title: Tools to simplify Omics DE Analysis
4-
Version: 0.0.54
4+
Version: 0.0.55
55
Author: Richard Virgen-Slane <Richard.Virgen-Slane@pfizer.com>
66
Maintainer: Richard Virgen-Slane <Richard.Virgen-Slane@pfizer.com>
77
Description: Converts outputs from DESeq2, limma, or a method of your
@@ -13,11 +13,10 @@ Encoding: UTF-8
1313
LazyData: true
1414
RoxygenNote: 7.3.3
1515
Imports:
16-
BiocParallel,
1716
cli,
1817
factoextra,
1918
FactoMineR,
20-
fgsea (>= 1.16.0),
19+
fgsea (>= 1.32.0),
2120
forcats,
2221
DRomics,
2322
DT,
@@ -59,6 +58,7 @@ Suggests:
5958
airway,
6059
apeglm,
6160
ashr,
61+
BiocParallel,
6262
edgeR,
6363
devtools,
6464
GEOquery,

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ export(wrap_fixed_names)
114114
exportMethods("Mapper_<-")
115115
exportMethods("auxiliary_assays_<-")
116116
exportMethods("coldata_<-")
117-
importFrom(BiocParallel,MulticoreParam)
118117
importFrom(DESeq2,lfcShrink)
119118
importFrom(DESeq2,normTransform)
120119
importFrom(DESeq2,resultsNames)

NEWS

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# version 0.0.55:
2+
- Fixed contrast_vectors arg to HotgenesDEseq2() bug that dropped contrast
3+
names from export.
4+
- Fixed HotgenesDEseq2() issue not supporting stat col generation for "ashr"
5+
- Updates to DE() to stabilize Topn behavoir across Report types.
6+
- Reorganized the package vignettes into a clearer 01–05 documentation suite.
7+
- Expanded the visualization vignette to include GSEA, msigdbr_wrapper(),
8+
and custom gene-set configuration examples.
9+
- Refocused the Shiny vignette on using the app to prioritize genes of
10+
interest across DE, PCA, Venn, GSEA, and expression views.
11+
- Added a separate vignette for sample-wise pathway activity with
12+
HotgeneSets().
13+
114
# version 0.0.54:
215
- Replaced base R messaging/error calls (stop(), warning(), message(),
316
print(), cat()) with cli equivalents across R/ sources.

R/GSEA.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fgsea_ <- function(
2222
pathways = NULL,
2323
minSize = 1,
2424
maxSize = Inf,
25-
nproc = 1,
25+
nproc = 0,
2626
verbose = FALSE,
2727
...) {
2828
# Check if Ranks is a list

R/Hotgenes.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ HotgenesDEseq2 <- function(DEseq2_object = NULL,
199199

200200
} else {
201201
output_method <- Output_contrasts %>%
202+
purrr::set_names(~ .x) %>%
202203
purrr::imap(function(xList, yList) {
203204
list(
204205

@@ -209,6 +210,9 @@ HotgenesDEseq2 <- function(DEseq2_object = NULL,
209210
}
210211

211212

213+
DESeq2_args <- tryCatch(list(...),
214+
error = function(e) NULL)
215+
212216
Output_DE <- output_method %>%
213217
purrr::set_names(~ .x) %>%
214218
purrr::imap(function(xList, yList) {
@@ -218,16 +222,17 @@ HotgenesDEseq2 <- function(DEseq2_object = NULL,
218222
dds = DEseq2_object
219223
) |>
220224
append(xList) |>
221-
append(list(...))
225+
append(DESeq2_args)
222226

223227
out_lfcSh <- base::do.call(what = DESeq2::lfcShrink,
224228
args = list_lfcSh ) |>
225229
base::as.data.frame() |>
226230
tibble::rownames_to_column(var = "Feature") |>
227231
dplyr::arrange(.data$padj)
228232

229-
# Calculating stat for GSEA
230-
if (lfcShrink_type == "apeglm") {
233+
234+
# Calculating stat for GSEA when not returned by lfcShrink
235+
if (!"stat" %in% names(out_lfcSh)) {
231236
out_lfcSh <- out_lfcSh %>%
232237
dplyr::mutate(stat = (-log10(.data$padj) * sign(.data$log2FoldChange)))
233238
}

R/Shiny_Hotgenes_UI_Module.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ return(UI_params)
209209
#' Mapper_ columns that should be used to map expression data
210210
#' to ontology gene identifiers. Default is names(Mapper_(Hotgenes)).
211211
#' A named vector may be used, as well.
212-
#' @param parallel.sz Number of threads of execution
212+
#' @param nproc Number of threads of execution
213213
#' to use when doing the calculations in parallel.
214214
#' @param remove_modal_spinner logical, if TRUE remove_modal_spinner will
215215
#' run at the end of initial server run.
@@ -225,7 +225,7 @@ session = NULL,
225225
Hotgenes = NULL,
226226
OntologyMethods = Hotgenes::OntologyMethods(),
227227
Mapper_choices = names(Mapper_(Hotgenes)),
228-
parallel.sz = 1L,
228+
nproc = 1L,
229229
max_col_levels = Inf,
230230
selected_fillby = "",
231231
remove_modal_spinner = TRUE) {
@@ -355,7 +355,7 @@ BoxPlot_output$reactive_NormSlot()
355355
# # verifies that everything is loaded
356356
if (isTRUE(remove_modal_spinner)) {
357357
shiny::observeEvent(shiny::req(serverOut() %in% ExpressionSlots_(Hotgenes_out)), {
358-
cli::cli_inform("remove_modal_spinner")
358+
359359
shinybusy::remove_modal_spinner(session = session)
360360
})
361361
}
@@ -396,7 +396,7 @@ Hotgenes = NULL,
396396
OntologyMethods = Hotgenes::OntologyMethods(),
397397
Mapper_choices = names(Mapper_(Hotgenes)),
398398
theme = shinythemes::shinytheme("united"),
399-
parallel.sz = 1L,
399+
nproc = 1L,
400400
max_col_levels = Inf)
401401
UseMethod("Shiny_Hotgenes", Hotgenes)
402402

@@ -409,7 +409,7 @@ Hotgenes = NULL,
409409
OntologyMethods = Hotgenes::OntologyMethods(),
410410
Mapper_choices = names(Mapper_(Hotgenes)),
411411
theme = shinythemes::shinytheme("united"),
412-
parallel.sz = 1L,
412+
nproc = 1L,
413413
max_col_levels = Inf) {
414414

415415

@@ -457,7 +457,7 @@ Hotgenes = NULL,
457457
OntologyMethods = Hotgenes::OntologyMethods(),
458458
Mapper_choices = names(Mapper_(Hotgenes)),
459459
theme = shinythemes::shinytheme("united"),
460-
parallel.sz = 1L,
460+
nproc = 1L,
461461
max_col_levels = Inf) {
462462

463463
cli::cli_inform("processing as list")
@@ -568,7 +568,7 @@ session = session,
568568
OntologyMethods = OntologyMethods,
569569
max_col_levels = max_col_levels,
570570
Hotgenes = Hotgenes_out() ,
571-
parallel.sz = parallel.sz,
571+
nproc = nproc,
572572
id = "Obj_A"
573573
)
574574

R/Shiny_Tabs.R

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,13 +1685,12 @@ shiny::plotOutput("enrichmentPlot" %>% ns())
16851685
#' @inheritParams DE_pheServer
16861686
#' @inheritParams fgsea_
16871687
#' @inheritParams Shiny_Hotgenes_Server
1688-
#' @importFrom BiocParallel MulticoreParam
16891688
#' @param OntologyMethods output of OntologyMethods function.
16901689
#' @param Mapper_choices vector containing names of
16911690
#' Mapper_ columns that should be used to map expression data
16921691
#' to ontology gene identifiers. Default is names(Mapper_(Hotgenes)).
16931692
#' A named vector may be used, as well.
1694-
#' @param parallel.sz Number of threads of execution
1693+
#' @param nproc Number of threads of execution
16951694
#' to use when doing the calculations in parallel.
16961695
#' @param PCA_TopTibble reactive object containing the TopTibble slots returned
16971696
#' by PCA.
@@ -1708,7 +1707,7 @@ ExpressionSlots = shiny::reactive(NULL),
17081707
SampleIDs = shiny::reactive(NULL),
17091708
OntologyMethods = OntologyMethods(),
17101709
Mapper_choices = names(Mapper_(Hotgenes)),
1711-
parallel.sz = 1) {
1710+
nproc = 0) {
17121711
shiny::moduleServer(
17131712
id,
17141713
function(input, output, session) {
@@ -1812,10 +1811,12 @@ input$fgsea_Button
18121811

18131812
# must be observed
18141813
shiny::observe({
1815-
paste0(
1816-
"Setting GSEA ini_fgsea() = ",
1817-
ini_fgsea()
1818-
)
1814+
# this_message <- paste0(
1815+
# "Setting GSEA ini_fgsea() = ",
1816+
# ini_fgsea()
1817+
# )
1818+
1819+
cli::cli_inform("Setting GSEA ini_fgsea() = {ini_fgsea()}")
18191820
})
18201821

18211822

@@ -1906,27 +1907,18 @@ if(gs_check == 0) {
19061907
shiny::req(gs_check > 0)
19071908

19081909

1909-
shinybusy::update_modal_spinner(
1910-
paste0(
1911-
"Checking ",
1912-
length(pthyways),
1913-
" pathways"
1914-
),
1915-
session = session
1916-
)
1917-
1918-
19191910
OutPut_fgsea <- fgsea_(
19201911
Ranks = list_Ranks,
19211912
pathways = pthyways,
1922-
BPPARAM = BiocParallel::MulticoreParam(workers = parallel.sz),
1913+
nproc = nproc,
19231914
minSize = input$minSize_Onto,
19241915
maxSize = input$maxSize_Onto
19251916
)
19261917

19271918

19281919
shinybusy::remove_modal_spinner(session = session)
19291920

1921+
19301922
return(OutPut_fgsea)
19311923
})
19321924

R/Utilities.R

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,11 @@ DE <- function(
173173
purrr::set_names(levels(Output_DE[[dplyr::group_vars(Output_DE)]])) %>%
174174
purrr::map_int(function(x) {
175175
x %>%
176-
head(n = Topn) %>%
176+
177177
dplyr::pull(.data$Feature) %>%
178178
# to bypass issue with multiple mappings due to mapFeatures = TRUE
179179
unique() %>%
180+
head(n = Topn) %>%
180181
length()
181182
})
182183
return(ReportOut)
@@ -189,10 +190,11 @@ DE <- function(
189190
purrr::set_names(levels(Output_DE[[dplyr::group_vars(Output_DE)]])) %>%
190191
purrr::map(function(x) {
191192
x %>%
192-
head(n = Topn) %>%
193193
dplyr::pull(.data$Feature) %>%
194+
# to bypass issue with multiple mappings due to mapFeatures = TRUE
195+
unique() %>%
196+
head(n = Topn)
194197

195-
unique()
196198
})
197199
return(ReportOut)
198200
}
@@ -202,10 +204,11 @@ DE <- function(
202204

203205
plyr::dlply("contrast_dir", identity) %>%
204206
purrr::map(function(x) {
205-
x %>%
206-
head(n = Topn) %>%
207+
x %>%
207208
dplyr::pull(.data$Feature) %>%
208-
unique()
209+
# to bypass issue with multiple mappings due to mapFeatures = TRUE
210+
unique() %>%
211+
head(n = Topn)
209212
})
210213
return(ReportOut)
211214
}
@@ -218,10 +221,8 @@ DE <- function(
218221
purrr::set_names(levels(Output_DE[[dplyr::group_vars(Output_DE)]])) %>%
219222
purrr::map(function(x) {
220223
x <- x %>%
221-
head(n = Topn) %>%
222-
223224
dplyr::select(dplyr::all_of(c(Rank_name_Final, "stat"))) %>%
224-
225+
dplyr::distinct() %>%
225226
dplyr::filter(
226227
dplyr::if_any(
227228
.cols = dplyr::any_of(Rank_name_Final),
@@ -233,7 +234,9 @@ DE <- function(
233234
dplyr::ungroup() %>%
234235
dplyr::arrange(dplyr::desc(.data$stat)) %>%
235236
unique() %>%
236-
tibble::deframe()
237+
head(n = Topn) %>%
238+
tibble::deframe()
239+
237240

238241

239242

README.Rmd

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,34 @@ options(tibble.print_min = 5, tibble.print_max = 5)
2424

2525
<br>
2626

27+
> For a guided introduction to the package, start with the **[vignette suite](#vignettes)** below.
28+
> The remainder of this README contains extended worked examples and required project information.
29+
30+
## Contents
31+
32+
- [Vignettes](#vignettes)
33+
- [Installation](#installation-requires-r--420-however-r--430-is-recommended)
34+
- [License information](#license-information)
35+
- [Background](#background)
36+
- [Why are Pfizer sharing this?](#why-are-pfizer-sharing-this)
37+
- [What is the benefit of this work?](#what-is-the-benefit-of-this-work)
38+
- [How should I submit questions, queries and enhancements?](#how-should-i-submit-questions-queries-and-enhancements)
39+
- [How does Hotgenes work?](#how-does-hotgenes-work)
40+
- [What can you do with a Hotgenes object?](#what-can-you-do-with-a-hotgenes-object)
41+
- [All functionality is available in a shiny app!](#all-functionality-is-available-in-a-shiny-app)
42+
- [Explore functions](#explore-functions)
43+
- [Code of Conduct](#code-of-conduct)
44+
45+
## Vignettes
46+
47+
The package documentation is organized into the following vignettes:
48+
49+
- [01 Creating Hotgenes Objects](vignettes/01_Creating_Hotgenes_Objects.md)
50+
- [02 API and Methods](vignettes/02_API_and_Methods.md)
51+
- [03 Visualization, Exploration, and Enrichment](vignettes/03_Visualization_and_Exploration.md)
52+
- [04 Using Shiny to Prioritize Genes of Interest](vignettes/04_Interactive_Exploration_Shiny.md)
53+
- [05 Sample-wise Pathway Activity with HotgeneSets](vignettes/05_Samplewise_Pathway_Activity_HotgeneSets.md)
54+
2755
## Installation requires R (>= 4.2.0); however R (>= 4.3.0) is recommended
2856

2957
```{r install_reqs, eval=FALSE, include=TRUE}

0 commit comments

Comments
 (0)