Skip to content

Commit 5fe3f4d

Browse files
committed
Update readme
1 parent bfb2db4 commit 5fe3f4d

26 files changed

Lines changed: 245 additions & 85 deletions

DESCRIPTION

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ Suggests:
7575
paletteer,
7676
tibble,
7777
tidytext,
78-
phenomix
78+
phenomix,
79+
ggrepel,
80+
gtools
7981
Remotes:
8082
github::neurogenomics/HPOExplorer,
8183
github::neurogenomics/KGExplorer,

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
## New features
44
* `get_cl`: new wrapper for getting the exact version of the
55
Cell Ontology used in our original study.
6+
* Update README to better reflect the package's current state.
67

78
## Bug fixes
89
* Use `BiocMananger` to install in README.
910
* `plot_bar_dendro`: Fix https://github.com/neurogenomics/MSTExplorer/issues/22
1011
* `plot_tissues`: Don't try to facet plot types that aren't requested.
12+
* `prioritise_targets_network`: Fix examples and tests.
13+
* `plot_celltype_severity`: Fix tests.
1114

1215
# MSTExplorer 1.0.6
1316
## Bug fixes

R/get_cl.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#' A thin wrapper around \link[KGExplorer]{get_ontology} to get the
44
#' specific version of the Cell Ontology used in the original analyses that
55
#' produced the results stored in \link{load_example_results}.
6-
#'
6+
#' @param remove_rings Parameter passed to \code{simona::import_ontology}.
77
#' @inheritParams KGExplorer::get_ontology
88
#' @inheritDotParams KGExplorer::get_ontology
99
#' @export

R/plot_bar_dendro.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#' determine whether each cell type is overrepresented in a given HPO branch
1515
#' relative to all other HPO branches. Overrepresented cell types will be
1616
#' denoted by "*" above its bar.
17+
#' @param add_prop_test Add proportional enrichment results
18+
#' using \code{run_prop_tests}.
1719
#' @param expand_dendro_x Passed to \link[ggplot2]{scale_x_discrete}
1820
#' in the cell type dendrogram.
1921
#' @param cl Cell Ontology (CL) object from

R/plot_bar_dendro_facets.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#' variable (e.g. "ancestor_name").
2424
#' @param background_full Whether to use the full set of results as a
2525
#' background for proportional enrichment testing.
26+
#' @param cores Number of CPU cores to parallelise the
27+
#' proportional enrichment tests across.
2628
#' @inheritParams plot_
2729
#' @inheritParams plot_bar_dendro
2830
#' @inheritParams ggnetwork_plot_full

R/plot_celltype_severity.R

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
#' a given cell type and all other cell types.
1515
#' Tests are repeated across each GPT annotation separately using
1616
#' \link[dplyr]{group_by} and \link[rstatix]{wilcox_test}.
17+
#' @param nonsig_fill Fill colour for non-significant results.
1718
#' @inheritParams prioritise_targets
1819
#' @inheritParams plot_bar_dendro
1920
#' @inheritParams ggplot2::theme_bw
21+
#' @inheritParams KGExplorer::set_cores
2022
#' @returns Named list of ggplot and data.table objects.
2123
#'
2224
#' @export
@@ -35,7 +37,8 @@ plot_celltype_severity <- function(results,
3537
nonsig_fill=ggplot2::alpha("grey90",.001),
3638
force_new=FALSE,
3739
base_size=8,
38-
save_path=tempfile(fileext = ".rds")){
40+
save_path=tempfile(fileext = ".rds"),
41+
workers=1){
3942

4043
requireNamespace("ggplot2")
4144
severity_score_gpt <- cl_name <- cl_id <- value <- variable <- p <- FDR <-
@@ -111,14 +114,23 @@ plot_celltype_severity <- function(results,
111114
wt_res <- readRDS(save_path)
112115
} else {
113116
## Run new tests
114-
BPPARAM <- KGExplorer::set_cores()
117+
BPPARAM <- KGExplorer::set_cores(workers = workers)
115118
messager("Running Wilcoxon rank-sum tests:")
116119
wt_res <- BiocParallel::bplapply(
117120
unique(agg_gpt$cl_id),
118121
function(ct){
119122
# messager("Running Wilcoxon rank-sum test:",ct)
120123
tmp <- agg_gpt[,group:=cl_id==ct][,value:=as.numeric(value)]
121-
tmp[!is.na(value)]|>
124+
tmp <- tmp[!is.na(value)]
125+
# Remove groups there's not enough samples to run tests on
126+
tmp[,n_samples:=data.table::uniqueN(value), by=variable]
127+
tmp[,n_groups:=data.table::uniqueN(group), by=variable]
128+
tmp <- tmp[n_samples>=2 & n_groups>=2]
129+
if (nrow(tmp) == 0) {
130+
return(NULL)
131+
}
132+
133+
tmp |>
122134
dplyr::group_by(variable)|>
123135
rstatix::wilcox_test(value ~ group,
124136
ref.group = "FALSE",

R/plot_differential_outcomes.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@
1414
#' @inheritDotParams ggstatsplot::ggbetweenstats
1515
#' @export
1616
#' @examples
17-
#' results <- add_symptom_results()
17+
#' results <- load_example_results()
18+
#' ## Reduce the CTD list for example purposes
19+
#' ctd_list <- load_example_ctd("ctd_DescartesHuman.rds",
20+
#' multi_dataset = TRUE)
21+
#' results <- add_symptom_results(results=results[ctd=="DescartesHuman"],
22+
#' ctd_list=ctd_list)
23+
#' ## Reduce the number of diseases for example purposes
24+
#' results <- results[disease_id %in% unique(results$disease_id)[seq(6)]]
1825
#' #### Multiple phenotypes per disease #####
1926
#' results <- HPOExplorer::add_gpt_annotations(results)
2027
#' p1 <- plot_differential_outcomes(results,

R/plot_severity_vs_nphenotypes.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#' See \link[ggstatsplot]{ggscatterstats} for details.
1616
#' @param remove_caption Remove the formula in the caption.
1717
#' See \link[ggstatsplot]{ggscatterstats} for details.
18+
#' @param cl Cell Ontology object.
19+
#' @param point_fill Fill color of the points.
1820
#' @inheritParams ggplot2::theme_bw
1921
#' @export
2022
#' @examples
@@ -34,6 +36,7 @@ plot_severity_vs_nphenotypes <- function(results,
3436
run_prune_ancestors=FALSE,
3537
...){
3638
requireNamespace("ggstatsplot")
39+
requireNamespace("ggrepel")
3740
severity_score_gpt <- hpo_id <- phenotypes_per_celltype <- .I <- NULL;
3841

3942
## Merge and annotate results

R/prioritise_targets_network.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@
3939
#'
4040
#' @export
4141
#' @examples
42-
#' top_targets <- MSTExplorer::example_targets$top_targets[1:10]
43-
#' top_targets[,estimate:=fold_change]
44-
#' top_targets <- map_celltype(top_targets)
42+
#' top_targets <- example_targets$top_targets[seq(10)]
4543
#' vn <- prioritise_targets_network(top_targets = top_targets)
4644
prioritise_targets_network <- function(top_targets,
4745
vertex_vars = c("disease_name",

R/run_prop_tests.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
1+
#' Run proportional enrichment tests
2+
#'
3+
#' Run a series of proportional enrichment tests on the results of a
4+
#' phenotype to cell type association test.
5+
#' @keywords internal
26
#' @examples
37
#' results <- load_example_results()
48
#' results <- HPOExplorer::add_ancestor(results)
5-
#'
69
run_prop_tests <- function(results,
710
branch_col="ancestor_name",
811
celltype_col="CellType",
@@ -57,6 +60,7 @@ run_prop_tests <- function(results,
5760
})|> data.table::rbindlist(fill = TRUE)
5861
# MTC
5962
if(nrow(test_res)>0){
63+
requireNamespace("gtools")
6064
test_res <- test_res |>
6165
dplyr::mutate(q=stats::p.adjust(p,"fdr"))|>
6266
dplyr::mutate(q_signif=gtools::stars.pval(p.value = q))

0 commit comments

Comments
 (0)