From e265e1371bd862773aa93e4b2f9ada7b65462620 Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Wed, 4 Dec 2024 12:27:43 +0000
Subject: [PATCH 01/23] Update tests
---
DESCRIPTION | 9 +++++++--
NEWS.md | 13 +++++++++++++
README.md | 7 ++++---
tests/testthat/test-gen_results.R | 3 ++-
tests/testthat/test-load_example_results.R | 8 ++------
tests/testthat/test-plot_bar_dendro.R | 2 +-
6 files changed, 29 insertions(+), 13 deletions(-)
diff --git a/DESCRIPTION b/DESCRIPTION
index 03bbc4b..775dcdc 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Package: MSTExplorer
Title: Multi-Scale Target Explorer
-Version: 1.0.4
+Version: 1.0.5
Authors@R:
c(
person(given = "Brian",
@@ -17,7 +17,12 @@ Authors@R:
family = "Skene",
role = c("aut"),
email = "nathan.skene@gmail.com",
- comment = c(ORCID = "0000-0002-6807-3180")))
+ comment = c(ORCID = "0000-0002-6807-3180")),
+ person(given = "Hiranyamaya",
+ family = "Dash",
+ role = c("ctb"),
+ email = "hdash.work@gmail.com",
+ comment = c(ORCID = "0009-0005-5514-505X")))
Description: Multi-Scale Target Explorer (`MSTExplorer`) systematically identifies, prioritises,
and visualises cell-type-specific gene therapy targets across the phenome.
License: GPL-3
diff --git a/NEWS.md b/NEWS.md
index a7c2538..dd11de8 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,16 @@
+# MSTExplorer 1.0.5
+
+## Bug fixes
+
+* Tests
+ - Use `force_new=TRUE` where some tests occasionally fail with cached
+ files.
+ - `test-load_example_results`: Update test files.
+* `add_logfc`
+ - Return `results` with new column rather than directly modifying the original
+ input.
+ - Update references (`add_logfc(results)` -> `results <- add_logfc(results)`).
+
# MSTExplorer 1.0.4
## New features
diff --git a/README.md b/README.md
index 949d5f0..22428fa 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@ MSTExplorer
[![License:
GPL-3](https://img.shields.io/badge/license-GPL--3-blue.svg)](https://cran.r-project.org/web/licenses/GPL-3)
-[![](https://img.shields.io/badge/devel%20version-1.0.0-black.svg)](https://github.com/neurogenomics/MSTExplorer)
+[![](https://img.shields.io/badge/devel%20version-1.0.5-black.svg)](https://github.com/neurogenomics/MSTExplorer)
[![](https://img.shields.io/github/languages/code-size/neurogenomics/MSTExplorer.svg)](https://github.com/neurogenomics/MSTExplorer)
[![](https://img.shields.io/github/last-commit/neurogenomics/MSTExplorer.svg)](https://github.com/neurogenomics/MSTExplorer/commits/master)
[![R build
@@ -12,10 +12,11 @@ status](https://github.com/neurogenomics/MSTExplorer/workflows/rworkflows/badge.
-Authors: Brian Schilder, Robert Gordon-Smith, Nathan Skene
+Authors: Brian Schilder, Robert Gordon-Smith, Nathan Skene,
+Hiranyamaya Dash
-README updated: Feb-24-2024
+README updated: Dec-04-2024
diff --git a/tests/testthat/test-gen_results.R b/tests/testthat/test-gen_results.R
index 17e401f..41da81d 100644
--- a/tests/testthat/test-gen_results.R
+++ b/tests/testthat/test-gen_results.R
@@ -7,7 +7,8 @@ test_that("gen_results works", {
all_results <- gen_results(ctd = ctd,
gene_data = gene_data,
list_names = list_names,
- reps = 10)
+ reps = 10,
+ force_new = TRUE)
testthat::expect_true(methods::is(all_results$results,"data.table"))
testthat::expect_true(methods::is(all_results$gene_data,"data.table"))
testthat::expect_gte(sum(list_names %in% unique(all_results$results$hpo_id)),
diff --git a/tests/testthat/test-load_example_results.R b/tests/testthat/test-load_example_results.R
index c517105..8e9c4c1 100644
--- a/tests/testthat/test-load_example_results.R
+++ b/tests/testthat/test-load_example_results.R
@@ -1,8 +1,4 @@
test_that("load_example_results works", {
-
- res1 <- load_example_results("Descartes_All_Results_extras.rds")
- testthat::expect_equal(nrow(res1), 475321)
-
- res2 <- load_example_results("tabulamuris_merged.rds")
- testthat::expect_equal(nrow(res2), 213028)
+ res1 <- load_example_results("phenomix_results.tsv.gz")
+ testthat::expect_equal(nrow(res1), 2206994)
})
diff --git a/tests/testthat/test-plot_bar_dendro.R b/tests/testthat/test-plot_bar_dendro.R
index bf95e79..5636b17 100644
--- a/tests/testthat/test-plot_bar_dendro.R
+++ b/tests/testthat/test-plot_bar_dendro.R
@@ -1,6 +1,6 @@
test_that("plot_bar_dendro works", {
- results <- load_example_results(multi_dataset=TRUE)
+ results <- load_example_results()
out <- plot_bar_dendro(results = results)
testthat::expect_true(methods::is(out$plot,"gg"))
testthat::expect_true(methods::is(out$data,"data.table"))
From cf70bd3f7a3a3affb08ec212a025970bd024b410 Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Wed, 4 Dec 2024 12:34:48 +0000
Subject: [PATCH 02/23] `document()` updates
---
man/ewce_para.Rd | 32 ++++++++++++++++++++++++
man/gen_results.Rd | 32 ++++++++++++++++++++++++
man/load_example_CTD.Rd | 2 +-
man/plot_congenital_annotations.Rd | 40 ++++++++++++++++--------------
man/plot_differential_outcomes.Rd | 32 ++++++++++++------------
5 files changed, 103 insertions(+), 35 deletions(-)
diff --git a/man/ewce_para.Rd b/man/ewce_para.Rd
index e39ae22..f67d6fb 100644
--- a/man/ewce_para.Rd
+++ b/man/ewce_para.Rd
@@ -106,10 +106,42 @@ cell type.}
(passed to \link[stats]{p.adjust}).}
\item{\code{sort_results}}{Sort enrichment results from
smallest to largest p-values.}
+ \item{\code{standardise_sct_data}}{Should \code{sct_data} be standardised?
+if \code{TRUE}:
+\itemize{
+\item{When \code{sctSpecies!=output_species}
+ the \code{sct_data} will be checked for object formatting and
+ the genes will be converted to the orthologs of the \code{output_species}
+ with \link[EWCE]{standardise_ctd}
+ (which calls \link[orthogene]{map_genes} internally).
+}
+\item{When \code{sctSpecies==output_species},
+ the \code{sct_data} will be checked for object formatting
+ with \link[EWCE]{standardise_ctd}, but the gene names
+ will remain untouched.
+ }
+}}
+ \item{\code{standardise_hits}}{Should \code{hits} be standardised?
+If \code{TRUE}:
+\itemize{
+\item{When \code{genelistSpecies!=output_species},
+ the genes will be converted to the orthologs of the \code{output_species}
+ with \link[orthogene]{convert_orthologs}.
+ }
+\item{When \code{genelistSpecies==output_species},
+ the genes will be standardised with \link[orthogene]{map_genes}.
+ }
+}
+If \code{FALSE}, \code{hits} will be passed on to subsequent steps as-is.}
\item{\code{localHub}}{If working offline, add argument localHub=TRUE to work
with a local, non-updated hub; It will only have resources available that
have previously been downloaded. If offline, Please also see BiocManager
vignette section on offline use to ensure proper functionality.}
+ \item{\code{store_gene_data}}{Store sampled gene data for every bootstrap iteration.
+When the number of bootstrap \code{reps} is very high (>=100k) and/or
+ the number of genes in \code{hits} is very high, you may want
+ to set \code{store_gene_data=FALSE} to avoid using excessive amounts of
+ CPU memory.}
}}
}
\value{
diff --git a/man/gen_results.Rd b/man/gen_results.Rd
index a06f368..688ca5c 100644
--- a/man/gen_results.Rd
+++ b/man/gen_results.Rd
@@ -109,10 +109,42 @@ cell type.}
(passed to \link[stats]{p.adjust}).}
\item{\code{sort_results}}{Sort enrichment results from
smallest to largest p-values.}
+ \item{\code{standardise_sct_data}}{Should \code{sct_data} be standardised?
+if \code{TRUE}:
+\itemize{
+\item{When \code{sctSpecies!=output_species}
+ the \code{sct_data} will be checked for object formatting and
+ the genes will be converted to the orthologs of the \code{output_species}
+ with \link[EWCE]{standardise_ctd}
+ (which calls \link[orthogene]{map_genes} internally).
+}
+\item{When \code{sctSpecies==output_species},
+ the \code{sct_data} will be checked for object formatting
+ with \link[EWCE]{standardise_ctd}, but the gene names
+ will remain untouched.
+ }
+}}
+ \item{\code{standardise_hits}}{Should \code{hits} be standardised?
+If \code{TRUE}:
+\itemize{
+\item{When \code{genelistSpecies!=output_species},
+ the genes will be converted to the orthologs of the \code{output_species}
+ with \link[orthogene]{convert_orthologs}.
+ }
+\item{When \code{genelistSpecies==output_species},
+ the genes will be standardised with \link[orthogene]{map_genes}.
+ }
+}
+If \code{FALSE}, \code{hits} will be passed on to subsequent steps as-is.}
\item{\code{localHub}}{If working offline, add argument localHub=TRUE to work
with a local, non-updated hub; It will only have resources available that
have previously been downloaded. If offline, Please also see BiocManager
vignette section on offline use to ensure proper functionality.}
+ \item{\code{store_gene_data}}{Store sampled gene data for every bootstrap iteration.
+When the number of bootstrap \code{reps} is very high (>=100k) and/or
+ the number of genes in \code{hits} is very high, you may want
+ to set \code{store_gene_data=FALSE} to avoid using excessive amounts of
+ CPU memory.}
}}
}
\value{
diff --git a/man/load_example_CTD.Rd b/man/load_example_CTD.Rd
index 0543b21..34063ac 100644
--- a/man/load_example_CTD.Rd
+++ b/man/load_example_CTD.Rd
@@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/load_example_ctd.R
+% Please edit documentation in R/load_example_CTD.R
\name{load_example_ctd}
\alias{load_example_ctd}
\title{Load example CTD (Descartes)}
diff --git a/man/plot_congenital_annotations.Rd b/man/plot_congenital_annotations.Rd
index 3fddac2..e524258 100644
--- a/man/plot_congenital_annotations.Rd
+++ b/man/plot_congenital_annotations.Rd
@@ -56,7 +56,7 @@ be extracted. The available palettes and packages can be checked by running
\item{proportion.test}{Decides whether proportion test for \code{x} variable is to
be carried out for each level of \code{y}. Defaults to \code{results.subtitle}. In
-\code{ggbarstats}, only \emph{p}-values from this test will be displayed.}
+\code{\link[ggstatsplot:ggbarstats]{ggbarstats()}}, only \emph{p}-values from this test will be displayed.}
\item{add_baseline}{Add a horizontal line showing the proportions
expected by random.}
@@ -78,7 +78,7 @@ Please note that if there are empty factor levels in your variable, they
will be dropped. Default is \code{NULL}. If \code{NULL}, one-sample proportion test
(a goodness of fit test) will be run for the \code{x} variable. Otherwise an
appropriate association test will be run. This argument can not be \code{NULL}
-for \code{ggbarstats} function.}
+for \code{\link[ggstatsplot:ggbarstats]{ggbarstats()}}.}
\item{\code{counts}}{The variable in data containing counts, or \code{NULL} if each row
represents a single observation.}
\item{\code{type}}{A character specifying the type of statistical approach:
@@ -99,17 +99,17 @@ the plot will be returned.}
on the label in each pie slice. Possible options are \code{"percentage"}
(default), \code{"counts"}, \code{"both"}.}
\item{\code{label.args}}{Additional aesthetic arguments that will be passed to
-\code{ggplot2::geom_label()}.}
- \item{\code{sample.size.label.args}}{Additional aesthetic arguments that will be passed to
-\code{ggplot2::geom_text()}.}
+\code{\link[ggplot2:geom_text]{ggplot2::geom_label()}}.}
+ \item{\code{sample.size.label.args}}{Additional aesthetic arguments that will be
+passed to \code{\link[ggplot2:geom_text]{ggplot2::geom_text()}}.}
\item{\code{digits}}{Number of digits for rounding or significant figures. May also
be \code{"signif"} to return significant figures or \code{"scientific"}
to return scientific notation. Control the number of digits by adding the
value as suffix, e.g. \code{digits = "scientific4"} to have scientific
notation with 4 decimal places, or \code{digits = "signif5"} for 5
significant figures (see also \code{\link[=signif]{signif()}}).}
- \item{\code{digits.perc}}{Numeric that decides number of decimal places for percentage
-labels (Default: \code{0L}).}
+ \item{\code{digits.perc}}{Numeric that decides number of decimal places for
+percentage labels (Default: \code{0L}).}
\item{\code{bf.message}}{Logical that decides whether to display Bayes Factor in
favor of the \emph{null} hypothesis. This argument is relevant only \strong{for
parametric test} (Default: \code{TRUE}).}
@@ -121,10 +121,14 @@ E.g., \code{ratio = c(0.5, 0.5)} for two levels,
\item{\code{conf.level}}{Scalar between \code{0} and \code{1} (default: \verb{95\%}
confidence/credible intervals, \code{0.95}). If \code{NULL}, no confidence intervals
will be computed.}
- \item{\code{sampling.plan}}{Character describing the sampling plan. Possible options
-are \code{"indepMulti"} (independent multinomial; default), \code{"poisson"},
-\code{"jointMulti"} (joint multinomial), \code{"hypergeom"} (hypergeometric). For
-more, see \code{?BayesFactor::contingencyTableBF()}.}
+ \item{\code{sampling.plan}}{Character describing the sampling plan. Possible options:
+\itemize{
+\item \code{"indepMulti"} (independent multinomial; default)
+\item \code{"poisson"}
+\item \code{"jointMulti"} (joint multinomial)
+\item \code{"hypergeom"} (hypergeometric).
+For more, see \code{\link[BayesFactor:contingencyTableBF]{BayesFactor::contingencyTableBF()}}.
+}}
\item{\code{fixed.margin}}{For the independent multinomial sampling plan, which
margin is fixed (\code{"rows"} or \code{"cols"}). Defaults to \code{"rows"}.}
\item{\code{prior.concentration}}{Specifies the prior concentration parameter, set
@@ -142,13 +146,13 @@ variable name for \code{x} will be used.}
\item{\code{ylab}}{Labels for \code{y} axis variable. If \code{NULL} (default),
variable name for \code{y} will be used.}
\item{\code{ggtheme}}{A \code{{ggplot2}} theme. Default value is
-\code{ggstatsplot::theme_ggstatsplot()}. Any of the \code{{ggplot2}} themes (e.g.,
-\code{theme_bw()}), or themes from extension packages are allowed (e.g.,
-\code{ggthemes::theme_fivethirtyeight()}, \code{hrbrthemes::theme_ipsum_ps()}, etc.).
-But note that sometimes these themes will remove some of the details that
-\code{{ggstatsplot}} plots typically contains. For example, if relevant,
-\code{ggbetweenstats()} shows details about multiple comparison test as a label
-on the secondary Y-axis. Some themes (e.g.
+\code{\link[ggstatsplot:theme_ggstatsplot]{theme_ggstatsplot()}}. Any of the \code{{ggplot2}} themes (e.g.,
+\code{\link[ggplot2:ggtheme]{ggplot2::theme_bw()}}), or themes from extension packages are allowed
+(e.g., \code{ggthemes::theme_fivethirtyeight()}, \code{hrbrthemes::theme_ipsum_ps()},
+etc.). But note that sometimes these themes will remove some of the details
+that \code{{ggstatsplot}} plots typically contains. For example, if relevant,
+\code{\link[ggstatsplot:ggbetweenstats]{ggbetweenstats()}} shows details about multiple comparison test as a
+label on the secondary Y-axis. Some themes (e.g.
\code{ggthemes::theme_fivethirtyeight()}) will remove the secondary Y-axis and
thus the details as well.}
\item{\code{package,palette}}{Name of the package from which the given palette is to
diff --git a/man/plot_differential_outcomes.Rd b/man/plot_differential_outcomes.Rd
index 51f3d23..848dd60 100644
--- a/man/plot_differential_outcomes.Rd
+++ b/man/plot_differential_outcomes.Rd
@@ -55,7 +55,7 @@ data has already been sorted by such an id by the user and creates an
internal identifier. So if your data is \strong{not} sorted, the results \emph{can}
be inaccurate when there are more than two levels in \code{x} and there are
\code{NA}s present. The data is expected to be sorted by user in
-subject-1,subject-2, ..., pattern.}
+subject-1, subject-2, ..., pattern.}
\item{\code{y}}{The response (or outcome or dependent) variable from \code{data}.}
\item{\code{type}}{A character specifying the type of statistical approach:
\itemize{
@@ -88,8 +88,8 @@ omega-squared).}
width to use in calculating Bayes factors and posterior estimates. In
addition to numeric arguments, several named values are also recognized:
\code{"medium"}, \code{"wide"}, and \code{"ultrawide"}, corresponding to \emph{r} scale values
-of 1/2, sqrt(2)/2, and 1, respectively. In case of an ANOVA, this value
-corresponds to scale for fixed effects.}
+of \code{1/2}, \code{sqrt(2)/2}, and \code{1}, respectively. In case of an ANOVA, this
+value corresponds to scale for fixed effects.}
\item{\code{bf.message}}{Logical that decides whether to display Bayes Factor in
favor of the \emph{null} hypothesis. This argument is relevant only \strong{for
parametric test} (Default: \code{TRUE}).}
@@ -148,24 +148,24 @@ to be:
Just as \code{type} argument, abbreviations are also accepted.}
\item{\code{centrality.point.args,centrality.label.args}}{A list of additional aesthetic
-arguments to be passed to \code{ggplot2::geom_point()} and
-\code{ggrepel::geom_label_repel} geoms, which are involved in mean plotting.}
+arguments to be passed to \code{\link[ggplot2:geom_point]{ggplot2::geom_point()}} and
+\code{\link[ggrepel:geom_text_repel]{ggrepel::geom_label_repel()}} geoms, which are involved in mean plotting.}
\item{\code{point.args}}{A list of additional aesthetic arguments to be passed to
-the \code{ggplot2::geom_point()} displaying the raw data.}
+the \code{\link[ggplot2:geom_point]{ggplot2::geom_point()}}.}
\item{\code{boxplot.args}}{A list of additional aesthetic arguments passed on to
-\code{ggplot2::geom_boxplot()}.}
+\code{\link[ggplot2:geom_boxplot]{ggplot2::geom_boxplot()}}.}
\item{\code{violin.args}}{A list of additional aesthetic arguments to be passed to
-the \code{ggplot2::geom_violin()}.}
+the \code{\link[ggplot2:geom_violin]{ggplot2::geom_violin()}}.}
\item{\code{ggsignif.args}}{A list of additional aesthetic
-arguments to be passed to \code{ggsignif::geom_signif}.}
+arguments to be passed to \code{\link[ggsignif:stat_signif]{ggsignif::geom_signif()}}.}
\item{\code{ggtheme}}{A \code{{ggplot2}} theme. Default value is
-\code{ggstatsplot::theme_ggstatsplot()}. Any of the \code{{ggplot2}} themes (e.g.,
-\code{theme_bw()}), or themes from extension packages are allowed (e.g.,
-\code{ggthemes::theme_fivethirtyeight()}, \code{hrbrthemes::theme_ipsum_ps()}, etc.).
-But note that sometimes these themes will remove some of the details that
-\code{{ggstatsplot}} plots typically contains. For example, if relevant,
-\code{ggbetweenstats()} shows details about multiple comparison test as a label
-on the secondary Y-axis. Some themes (e.g.
+\code{\link[ggstatsplot:theme_ggstatsplot]{theme_ggstatsplot()}}. Any of the \code{{ggplot2}} themes (e.g.,
+\code{\link[ggplot2:ggtheme]{ggplot2::theme_bw()}}), or themes from extension packages are allowed
+(e.g., \code{ggthemes::theme_fivethirtyeight()}, \code{hrbrthemes::theme_ipsum_ps()},
+etc.). But note that sometimes these themes will remove some of the details
+that \code{{ggstatsplot}} plots typically contains. For example, if relevant,
+\code{\link[ggstatsplot:ggbetweenstats]{ggbetweenstats()}} shows details about multiple comparison test as a
+label on the secondary Y-axis. Some themes (e.g.
\code{ggthemes::theme_fivethirtyeight()}) will remove the secondary Y-axis and
thus the details as well.}
\item{\code{package,palette}}{Name of the package from which the given palette is to
From bb1e5acc9cfe2ff66a5c4b7562b0580149dd6848 Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Wed, 4 Dec 2024 12:40:46 +0000
Subject: [PATCH 03/23] `add_logfc`: Return `results` with new column rather
than directly modifying the original input
---
R/add_logfc.R | 9 ++++-----
R/plot_bar_dendro.R | 4 ++--
R/plot_bar_dendro_facets.R | 2 +-
R/predict_celltypes.R | 2 +-
R/prioritise_targets.R | 2 +-
R/prioritise_targets_network.R | 2 +-
R/validate_associations_correlate_ctd.R | 2 +-
R/validate_associations_mkg.R | 2 +-
8 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/R/add_logfc.R b/R/add_logfc.R
index 1d5027a..63688b8 100644
--- a/R/add_logfc.R
+++ b/R/add_logfc.R
@@ -14,13 +14,12 @@ add_logfc <- function(results,
logFC <- NULL;
if(!"logFC" %in% names(results) || isTRUE(force_new)){
messager("Adding logFC column.")
- # results[,logFC:=log10(scales::rescale(estimate,c(.Machine$double.xmin, 1)))]
- # results[,logFC:=logFC/mean(results$logFC)]
- results[,logFC:=(get(effect_var)+abs(min(get(effect_var))))]
- results[,logFC:=(log2(logFC/mean(results$logFC)))]
- # hist(results$logFC)
+ results$logFC <- results[[effect_var]]+abs(min(results[[effect_var]]))
+ results$logFC <- log2(results$logFC/mean(results$logFC))
+ return(results)
} else {
messager("logFC already exists in results.",
"Use `force_new=TRUE` to overwrite.")
+ return(results)
}
}
diff --git a/R/plot_bar_dendro.R b/R/plot_bar_dendro.R
index 1a7816a..2ab27b9 100644
--- a/R/plot_bar_dendro.R
+++ b/R/plot_bar_dendro.R
@@ -87,7 +87,7 @@ plot_bar_dendro <- function(results = load_example_results(),
}
#### Filter the results ####
by <- unique(c(celltype_col,"cl_id","ancestor","ancestor_name"))
- add_logfc(results)
+ results <- add_logfc(results)
dat <- results[q
Date: Wed, 4 Dec 2024 13:14:44 +0000
Subject: [PATCH 04/23] Add check for disease column names before executing
`HPOExplorer::add_disease` on input
---
NEWS.md | 5 +++++
R/ttd_check.R | 6 +++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/NEWS.md b/NEWS.md
index dd11de8..46bf339 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -10,6 +10,11 @@
- Return `results` with new column rather than directly modifying the original
input.
- Update references (`add_logfc(results)` -> `results <- add_logfc(results)`).
+* `ttd_check`
+ - Add check for disease column names before executing
+ `HPOExplorer::add_disease` on input.
+* `plot_ttd`
+ - Remove `fill` aesthetic for `geom_text` (doesn't exist anymore).
# MSTExplorer 1.0.4
diff --git a/R/ttd_check.R b/R/ttd_check.R
index 789c0f8..879d20e 100644
--- a/R/ttd_check.R
+++ b/R/ttd_check.R
@@ -67,8 +67,12 @@ ttd_check <- function(top_targets,
TARGETID <- DRUGNAME <- DRUGTYPE <- DRUGID <-
GENENAME2 <- prioritised <- HIGHEST_STATUS <- NULL;
- top_targets <- HPOExplorer::add_disease(top_targets,
+ #### add_disease if not already done ###
+ if (!"disease_name" %in% names(top_targets) |
+ !"disease_id" %in% names(top_targets)) {
+ top_targets <- HPOExplorer::add_disease(top_targets,
add_descriptions = TRUE)
+ }
ttdi <- KGExplorer::get_ttd(force_new = force_new,
run_map_genes = run_map_genes)
#### Remove results that can't be linked to specific genes #####
From 2e6a5ae24a1af50f06f62207e1788406b6e4ea9a Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Wed, 4 Dec 2024 13:14:57 +0000
Subject: [PATCH 05/23] Remove `fill` aesthetic for `geom_text` (doesn't exist
anymore)
---
R/plot_ttd.R | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/R/plot_ttd.R b/R/plot_ttd.R
index 48807e9..8c7ba93 100644
--- a/R/plot_ttd.R
+++ b/R/plot_ttd.R
@@ -33,7 +33,7 @@ plot_ttd <- function(dat_sub,
size=label_size,
angle=90,
hjust=1,
- ggplot2::aes(x=HIGHEST_STATUS, fill=prioritised,
+ ggplot2::aes(x=HIGHEST_STATUS,
label=paste0("n=",n_drugs), y=.95),
# fill="white", alpha=.75,
inherit.aes = FALSE) +
From 446003d7cfe93dce871955c8f2c43a030ee5b79d Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Wed, 4 Dec 2024 13:55:32 +0000
Subject: [PATCH 06/23] Look for help docs only in legitimate pkg installation
paths
---
NEWS.md | 3 +++
R/extract_help.R | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/NEWS.md b/NEWS.md
index 46bf339..cf64e76 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -15,6 +15,9 @@
`HPOExplorer::add_disease` on input.
* `plot_ttd`
- Remove `fill` aesthetic for `geom_text` (doesn't exist anymore).
+* `extract_help`
+ - [DEVELOPEMENT ONLY] Look for help docs only in legitimate pkg installation
+ paths.
# MSTExplorer 1.0.4
diff --git a/R/extract_help.R b/R/extract_help.R
index 422822b..dc06f9d 100644
--- a/R/extract_help.R
+++ b/R/extract_help.R
@@ -14,7 +14,7 @@ extract_help <- function(pkg,
requireNamespace("tools")
to <- match.arg(to)
- rdbfile <- file.path(find.package(pkg), "help", pkg)
+ rdbfile <- file.path(find.package(pkg, lib.loc = .libPaths()), "help", pkg)
fetchRdDB <- utils::getFromNamespace("fetchRdDB","tools")
rdb <- fetchRdDB(rdbfile, key = fn)
convertor <- switch(to,
From fdb5327faf07c4126cc57c45cc55d7ac7c8b7fb2 Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Wed, 4 Dec 2024 15:32:48 +0000
Subject: [PATCH 07/23] Remove unused arguments and change input size
---
NEWS.md | 1 +
tests/testthat/test-prioritise_targets.R | 11 ++++-------
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/NEWS.md b/NEWS.md
index cf64e76..307618b 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -6,6 +6,7 @@
- Use `force_new=TRUE` where some tests occasionally fail with cached
files.
- `test-load_example_results`: Update test files.
+ - `test-prioritise_targets`: Remove unused arguments and change input size.
* `add_logfc`
- Return `results` with new column rather than directly modifying the original
input.
diff --git a/tests/testthat/test-prioritise_targets.R b/tests/testthat/test-prioritise_targets.R
index d3337d2..a47a5c3 100644
--- a/tests/testthat/test-prioritise_targets.R
+++ b/tests/testthat/test-prioritise_targets.R
@@ -1,6 +1,6 @@
test_that("prioritise_targets works", {
- results <- load_example_results()[seq(50000),]
+ results <- load_example_results()[q<0.01]
ctd_list <- load_example_ctd(c("ctd_DescartesHuman.rds",
"ctd_HumanCellLandscape.rds"),
multi_dataset = TRUE)
@@ -17,7 +17,7 @@ test_that("prioritise_targets works", {
testthat::expect_gte(nrow(res2$top_targets), 6)
#### Plot evidence score vs. specificity ####
- res3 <- prioritise_targets(results = results[seq(2500)],
+ res3 <- prioritise_targets(results = results,
ctd_list = ctd_list,
keep_deaths = NULL,
#### Phenotype level ####
@@ -32,8 +32,6 @@ test_that("prioritise_targets works", {
#### Celltype level ####
q_threshold = 0.05,
effect_threshold = 1,
- symptom_p_threshold = NULL,
- symptom_intersection_size_threshold = 1,
keep_celltypes = NULL,
#### Gene level ####
evidence_score_threshold = NULL,
@@ -43,7 +41,6 @@ test_that("prioritise_targets works", {
gene_frequency_threshold = NULL,
keep_biotypes = NULL,
keep_specificity_quantiles = NULL,
- keep_mean_exp_quantiles = seq(1,40),
- symptom_gene_overlap = TRUE)
- testthat::expect_gte(nrow(res3$top_targets), 40000)
+ keep_mean_exp_quantiles = seq(1,40))
+ testthat::expect_gte(nrow(res3$top_targets), 1000)
})
From d605e00cb359844ba1fcca10ab1379322e2831f0 Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Wed, 4 Dec 2024 15:41:11 +0000
Subject: [PATCH 08/23] Process `top_targets` to include effect variable
---
NEWS.md | 2 ++
tests/testthat/test-prioritise_targets_network.R | 5 ++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/NEWS.md b/NEWS.md
index 307618b..4f61df5 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -7,6 +7,8 @@
files.
- `test-load_example_results`: Update test files.
- `test-prioritise_targets`: Remove unused arguments and change input size.
+ - `test-prioritise_targets_network`: Process `top_targets` to include effect
+ variable.
* `add_logfc`
- Return `results` with new column rather than directly modifying the original
input.
diff --git a/tests/testthat/test-prioritise_targets_network.R b/tests/testthat/test-prioritise_targets_network.R
index d521c48..4988551 100644
--- a/tests/testthat/test-prioritise_targets_network.R
+++ b/tests/testthat/test-prioritise_targets_network.R
@@ -1,6 +1,9 @@
test_that("prioritise_targets_network works", {
- vn <- prioritise_targets_network(top_targets = example_targets$top_targets)
+ top_targets <- example_targets$top_targets
+ top_targets[,estimate:=fold_change]
+ top_targets <- map_celltype(top_targets)
+ vn <- prioritise_targets_network(top_targets)
testthat::expect_true(methods::is(vn$plot,"visNetwork"))
testthat::expect_true(methods::is(vn$data,"tbl_graph"))
From aa94a9bff14c05643fd6ec9dcd90c48e9740e3f7 Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Wed, 4 Dec 2024 15:54:32 +0000
Subject: [PATCH 09/23] Add new `effect_var` argument and adjust default
`effect_threshold` to 0.1
---
NEWS.md | 3 +++
R/subset_results.R | 6 ++++--
man/subset_results.Rd | 5 ++++-
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/NEWS.md b/NEWS.md
index 4f61df5..2d866d7 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -21,6 +21,9 @@
* `extract_help`
- [DEVELOPEMENT ONLY] Look for help docs only in legitimate pkg installation
paths.
+* `subset_results`
+ - Add new `effect_var` argument.
+ - Adjust default `effect_threshold` to 0.1.
# MSTExplorer 1.0.4
diff --git a/R/subset_results.R b/R/subset_results.R
index 23f48bb..c340f6d 100644
--- a/R/subset_results.R
+++ b/R/subset_results.R
@@ -4,6 +4,7 @@
#' @inheritParams ggnetwork_plot_full
#' @inheritParams KGExplorer::filter_dt
#' @inheritParams HPOExplorer::make_phenos_dataframe
+#' @inheritParams add_logfc
#' @returns A data frame of the selected subset of RD EWCE results
#' with HPO ID column added.
#'
@@ -13,7 +14,8 @@
subset_results <- function(filters = list(cl_name=NULL),
results = load_example_results(),
q_threshold = 0.0005,
- effect_threshold = 1,
+ effect_threshold = 0.1,
+ effect_var = "fold_change",
verbose = TRUE){
effect <- hpo_id <- hpo_id <- NULL;
@@ -24,7 +26,7 @@ subset_results <- function(filters = list(cl_name=NULL),
results_sig <- results_sig[qeffect_threshold]
+ results_sig <- results_sig[results_sig[[effect_var]]>effect_threshold,]
}
#### Check that celltype is available ####
if(nrow(results_sig)==0){
diff --git a/man/subset_results.Rd b/man/subset_results.Rd
index 193ebd0..abc30f2 100644
--- a/man/subset_results.Rd
+++ b/man/subset_results.Rd
@@ -8,7 +8,8 @@ subset_results(
filters = list(cl_name = NULL),
results = load_example_results(),
q_threshold = 5e-04,
- effect_threshold = 1,
+ effect_threshold = 0.1,
+ effect_var = "fold_change",
verbose = TRUE
)
}
@@ -26,6 +27,8 @@ and merged together with \link[MSTExplorer]{merge_results}}
\item{effect_threshold}{The minimum fold change in specific expression
to subset the \code{results} by.}
+\item{effect_var}{Name of the effect size column in the \code{results}.}
+
\item{verbose}{Print messages.}
}
\value{
From c889f7cb4dc64e42a01996b20e18b6fccc319be8 Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Thu, 5 Dec 2024 12:22:01 +0000
Subject: [PATCH 10/23] Only merge `results` and `phenotypes_to_genes` if
required (prevents column duplicates with altered names)
---
NEWS.md | 5 +++++
R/add_symptom_results.R | 24 +++++++++++++++---------
2 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/NEWS.md b/NEWS.md
index 2d866d7..d7bfcd6 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -8,6 +8,8 @@
- `test-load_example_results`: Update test files.
- `test-prioritise_targets`: Remove unused arguments and change input size.
- `test-prioritise_targets_network`: Process `top_targets` to include effect
+ - `test-plot_differential_outcomes`: Use non-specific plot name in
+ `patchwork::wrap_plots`.
variable.
* `add_logfc`
- Return `results` with new column rather than directly modifying the original
@@ -24,6 +26,9 @@
* `subset_results`
- Add new `effect_var` argument.
- Adjust default `effect_threshold` to 0.1.
+* `add_symptom_results`
+ - Only merge `results` and `phenotypes_to_genes` if required (prevents
+ column duplicates with altered names).
# MSTExplorer 1.0.4
diff --git a/R/add_symptom_results.R b/R/add_symptom_results.R
index 880136a..5c43c20 100644
--- a/R/add_symptom_results.R
+++ b/R/add_symptom_results.R
@@ -16,8 +16,8 @@
#'
#' @export
#' @examples
-#' results = load_example_results()[seq(5000)]
-#' results <- add_symptom_results()
+#' results <- load_example_results()[seq(5000)]
+#' results <- add_symptom_results(results)
add_symptom_results <- function(results = load_example_results(),
q_threshold = 0.05,
effect_threshold = NULL,
@@ -57,13 +57,19 @@ add_symptom_results <- function(results = load_example_results(),
results <- HPOExplorer::add_genes(results,
phenotype_to_genes = phenotype_to_genes,
allow.cartesian = TRUE)
- results_annot <- data.table::merge.data.table(
- results,
- unique(phenotype_to_genes[,c("hpo_id","disease_id",
- "n_genes_hpo_id",
- "n_genes_disease_id",
- "n_genes_symptom")]),
- by=c("hpo_id","disease_id"))
+ merge_cols <- c("hpo_id",
+ "disease_id",
+ "n_genes_hpo_id",
+ "n_genes_disease_id",
+ "n_genes_symptom")
+ if(all(merge_cols %in% colnames(results))){
+ results_annot <- results
+ }else{
+ results_annot <- data.table::merge.data.table(
+ results,
+ unique(phenotype_to_genes[,..merge_cols]),
+ by=c("hpo_id","disease_id"))
+ }
#### Add genes that intersect between the
phenos <- add_driver_genes(results = results_annot,
ctd_list = ctd_list,
From 33a0affc247a21ff1585adf363b8a40148e2e4d4 Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Thu, 5 Dec 2024 12:23:16 +0000
Subject: [PATCH 11/23] Add check for disease column names before executing, if
required
---
NEWS.md | 4 ++--
R/plot_differential_outcomes.R | 4 ++++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/NEWS.md b/NEWS.md
index d7bfcd6..4343bef 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -15,8 +15,8 @@
- Return `results` with new column rather than directly modifying the original
input.
- Update references (`add_logfc(results)` -> `results <- add_logfc(results)`).
-* `ttd_check`
- - Add check for disease column names before executing
+* `ttd_check`, `plot_differential_outcomes`
+ - Add check for disease column names before executing, if required.
`HPOExplorer::add_disease` on input.
* `plot_ttd`
- Remove `fill` aesthetic for `geom_text` (doesn't exist anymore).
diff --git a/R/plot_differential_outcomes.R b/R/plot_differential_outcomes.R
index dbda94a..2136d34 100644
--- a/R/plot_differential_outcomes.R
+++ b/R/plot_differential_outcomes.R
@@ -39,6 +39,10 @@ plot_differential_outcomes <- function(results,
{
results <- HPOExplorer::add_hpo_name(results)
+ if ("disease_name" %in% c(facet_var, x_var, y_var) &&
+ !"disease_name" %in% names(results)) {
+ results <- HPOExplorer::add_disease(results, add_descriptions = TRUE)
+ }
plot_dat <- results[!is.na(get(y_var)),]
plot_dat[,n_celltype:=length(unique(get(x_var))),by=c(facet_var)]
plot_dat[,n_ids:=.N, by=c(facet_var)]
From dd1ad42c5280cdb28215d3f7af4f544367765509 Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Thu, 5 Dec 2024 14:48:14 +0000
Subject: [PATCH 12/23] Wrap p3 in `expect_error` to prevent test failure even
if error was handled
---
NEWS.md | 2 ++
tests/testthat/test-plot_differential_outcomes.R | 7 ++++---
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/NEWS.md b/NEWS.md
index 4343bef..3330658 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -10,6 +10,8 @@
- `test-prioritise_targets_network`: Process `top_targets` to include effect
- `test-plot_differential_outcomes`: Use non-specific plot name in
`patchwork::wrap_plots`.
+ - `test-plot_differential_outcomes`: Wrap p3 in `expect_error` to prevent
+ test failure even if error was handled.
variable.
* `add_logfc`
- Return `results` with new column rather than directly modifying the original
diff --git a/tests/testthat/test-plot_differential_outcomes.R b/tests/testthat/test-plot_differential_outcomes.R
index ce7e32e..f326068 100644
--- a/tests/testthat/test-plot_differential_outcomes.R
+++ b/tests/testthat/test-plot_differential_outcomes.R
@@ -48,16 +48,17 @@ test_that("plot_differential_outcomes works", {
facet_var = "disease_name",
y_var = "cancer",
run_stats = TRUE)
- patchwork::wrap_plots(p1c$plot$`Granulomatosis with polyangiitis`)
+ patchwork::wrap_plots(p1c$plot[1])
run_tests(p1c)
# #### Multiple diseases per phenotype: Severity_score #####
results <- HPOExplorer::add_severity(results)
- p2 <- plot_differential_outcomes(results,
+ # Testthat interprets messages with errors as failures even with tryCatch()
+ testthat::expect_error(p2 <- plot_differential_outcomes(results,
max_facets=10,
facet_var = "hpo_name",
y_var = "Severity_score",
- run_stats = TRUE)
+ run_stats = TRUE))
# #### Multiple diseases per phenotype: AgeOfDeath #####
results <- HPOExplorer::add_death(results,
From 5ed8191843e0720cdfaa6a27c1cb326adfff9271 Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Thu, 5 Dec 2024 14:48:31 +0000
Subject: [PATCH 13/23] Update man
---
README.md | 2 +-
man/add_symptom_results.Rd | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 22428fa..86e9431 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@ Authors: Brian Schilder, Robert Gordon-Smith, Nathan Skene,
Hiranyamaya Dash
-README updated: Dec-04-2024
+README updated: Dec-05-2024
diff --git a/man/add_symptom_results.Rd b/man/add_symptom_results.Rd
index 3dcb99d..269483f 100644
--- a/man/add_symptom_results.Rd
+++ b/man/add_symptom_results.Rd
@@ -58,6 +58,6 @@ via a specific disease) and the driver genes
Add symptom results to the results data.table.
}
\examples{
-results = load_example_results()[seq(5000)]
-results <- add_symptom_results()
+results <- load_example_results()[seq(5000)]
+results <- add_symptom_results(results)
}
From 96372fd61db24fec33db628ffd89d1b3161082e6 Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Thu, 5 Dec 2024 14:54:46 +0000
Subject: [PATCH 14/23] Update effect variable to `fold_change`
---
NEWS.md | 2 ++
vignettes/MSTExplorer.Rmd | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/NEWS.md b/NEWS.md
index 3330658..2fcbc14 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -13,6 +13,8 @@
- `test-plot_differential_outcomes`: Wrap p3 in `expect_error` to prevent
test failure even if error was handled.
variable.
+* Vignettes
+ - `MSTExplorer`: Update effect variable to `fold_change`.
* `add_logfc`
- Return `results` with new column rather than directly modifying the original
input.
diff --git a/vignettes/MSTExplorer.Rmd b/vignettes/MSTExplorer.Rmd
index 778b984..b0f4b67 100644
--- a/vignettes/MSTExplorer.Rmd
+++ b/vignettes/MSTExplorer.Rmd
@@ -113,7 +113,7 @@ library(data.table)
#### Aggregate results ####
n_signif <- results[q<=0.05 & !is.na(q),
list(sig_enrichments = .N,
- mean_effect=mean(effect)),
+ mean_effect=mean(fold_change)),
by="hpo_id"]
#### Plot ####
plot1 <- ggplot(n_signif, aes(x = stringr::str_wrap(hpo_id,width = 10),
From b593510a01855d8a677dba8bbd012b3ddf0915c8 Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Thu, 5 Dec 2024 15:15:15 +0000
Subject: [PATCH 15/23] Add missing import (simona)
---
DESCRIPTION | 3 ++-
NEWS.md | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/DESCRIPTION b/DESCRIPTION
index 775dcdc..ea4df41 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -54,7 +54,8 @@ Imports:
future,
furrr,
tidygraph,
- rstatix
+ rstatix,
+ simona
Suggests:
rmarkdown,
knitr,
diff --git a/NEWS.md b/NEWS.md
index 2fcbc14..cfd9910 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -33,6 +33,7 @@
* `add_symptom_results`
- Only merge `results` and `phenotypes_to_genes` if required (prevents
column duplicates with altered names).
+* Add missing import: simona
# MSTExplorer 1.0.4
From 9196f38ff01e1eadfd98c768db5986064fe3a73e Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Thu, 5 Dec 2024 15:19:58 +0000
Subject: [PATCH 16/23] Fix detection for ggplot object in test
---
NEWS.md | 1 +
tests/testthat/test-report_plot.R | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/NEWS.md b/NEWS.md
index cfd9910..d8b3784 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -12,6 +12,7 @@
`patchwork::wrap_plots`.
- `test-plot_differential_outcomes`: Wrap p3 in `expect_error` to prevent
test failure even if error was handled.
+ - `test-report_plot`: Fix detection for ggplot object.
variable.
* Vignettes
- `MSTExplorer`: Update effect variable to `fold_change`.
diff --git a/tests/testthat/test-report_plot.R b/tests/testthat/test-report_plot.R
index 07a1086..7a5d849 100644
--- a/tests/testthat/test-report_plot.R
+++ b/tests/testthat/test-report_plot.R
@@ -3,5 +3,5 @@ test_that("plot_report works", {
results <- load_example_results()
rep_dt <- example_targets$report
gp <- plot_report(rep_dt=rep_dt, results=results)
- testthat::expect_true(methods::is(gp,"ggplot"))
+ testthat::expect_true(methods::is(gp$plot,"ggplot"))
})
From 02b65713520b23269ba4d6444ea72b57687ed8b0 Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Thu, 5 Dec 2024 15:46:14 +0000
Subject: [PATCH 17/23] Rewrite merge logic to fix error: attempt to replicate
non-vector
---
NEWS.md | 2 ++
R/map_tissue.R | 13 ++++++++-----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/NEWS.md b/NEWS.md
index d8b3784..f0418c8 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -34,6 +34,8 @@
* `add_symptom_results`
- Only merge `results` and `phenotypes_to_genes` if required (prevents
column duplicates with altered names).
+* `map_tissue`
+ - Rewrite merge logic to fix error: attempt to replicate non-vector.
* Add missing import: simona
# MSTExplorer 1.0.4
diff --git a/R/map_tissue.R b/R/map_tissue.R
index 6d4295b..6709c66 100644
--- a/R/map_tissue.R
+++ b/R/map_tissue.R
@@ -47,12 +47,15 @@ map_tissue <- function(results = NULL,
by=by]
#### Get the ancestor for each tissue #####
if(!isFALSE(lvl)){
+ ancestor_dat <- data.frame(uberon@elementMetadata@listData) |>
+ dplyr::select(id,ancestor,ancestor_name) |>
+ dplyr::rename(
+ uberon_id = id,
+ uberon_ancestor = ancestor,
+ uberon_ancestor_name = ancestor_name
+ )
map_agg2 <- merge(map_agg,
- data.table::data.table(
- uberon@elementMetadata
- )[,list(uberon_id=id,
- uberon_ancestor=ancestor,
- uberon_ancestor_name=ancestor_name)],
+ ancestor_dat,
all.x=TRUE,
by.x="top_uberon_id",
by.y="uberon_id")
From 284906989f54a8d194760618817c450ba9e02250 Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Thu, 5 Dec 2024 16:29:51 +0000
Subject: [PATCH 18/23] Add check for `disease_name` column before executing
`HPOExplorer::add_disease` on input
---
NEWS.md | 4 ++--
R/prioritise_targets_grid.R | 12 ++++++++----
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/NEWS.md b/NEWS.md
index f0418c8..e18e886 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -20,8 +20,8 @@
- Return `results` with new column rather than directly modifying the original
input.
- Update references (`add_logfc(results)` -> `results <- add_logfc(results)`).
-* `ttd_check`, `plot_differential_outcomes`
- - Add check for disease column names before executing, if required.
+* `ttd_check`, `plot_differential_outcomes`, `prioritise_targets_grid`
+ - Add check for `disease_name` column before executing
`HPOExplorer::add_disease` on input.
* `plot_ttd`
- Remove `fill` aesthetic for `geom_text` (doesn't exist anymore).
diff --git a/R/prioritise_targets_grid.R b/R/prioritise_targets_grid.R
index eb633b9..b2bd744 100644
--- a/R/prioritise_targets_grid.R
+++ b/R/prioritise_targets_grid.R
@@ -85,10 +85,14 @@ prioritise_targets_grid <- function(top_targets,
size=3){
if(!is.null(labels)) labels <- stats::setNames(labels,as.character(x_pos))
dat <- merge(dt1[,-c("hpo_id")],
- dt2, by="hpo_name", sort=FALSE)|>
- data.table::melt.data.table(
- id.vars=c("hpo_id","hpo_name","severity_class","p"),
- measure.vars=unique(c(label_cols,"gene_symbol")))
+ dt2, by="hpo_name", sort=FALSE)
+ # Check for disease_name
+ if("disease_name" %in% label_cols && !"disease_name" %in% names(dat)){
+ dat <- HPOExplorer::add_disease(dat, add_descriptions = TRUE)
+ }
+ dat <- data.table::melt.data.table(dat,
+ id.vars=c("hpo_id","hpo_name","severity_class","p"),
+ measure.vars=unique(c(label_cols,"gene_symbol")))
dat[,hpo_name:=factor(hpo_name,
levels=rev(levels(dt1$hpo_name)), ordered=TRUE)]
dat[startsWith(value,"GRANULOMATOUS"), value:=stringr::str_to_title(value)]
From 40cf0a75cfb92a889c47fe92b5708a82e7cce4b7 Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Thu, 5 Dec 2024 17:01:11 +0000
Subject: [PATCH 19/23] Uncomment `add_ancestors(results)` to ensure required
ancestor columns are present
---
NEWS.md | 3 +++
R/test_target_celltypes.R | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/NEWS.md b/NEWS.md
index e18e886..8e58a24 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -36,6 +36,9 @@
column duplicates with altered names).
* `map_tissue`
- Rewrite merge logic to fix error: attempt to replicate non-vector.
+* `test_target_celltypes`
+ - Uncomment `add_ancestors(results)` to ensure required ancestor columns are
+ present.
* Add missing import: simona
# MSTExplorer 1.0.4
diff --git a/R/test_target_celltypes.R b/R/test_target_celltypes.R
index 6d4646b..d082aad 100644
--- a/R/test_target_celltypes.R
+++ b/R/test_target_celltypes.R
@@ -40,7 +40,7 @@ test_target_celltypes <- function(results=load_example_results(),
ancestor_name <- is_sig <- is_target <- valid <- cl_id <- NULL;
method <- match.arg(method)
- # results <- HPOExplorer::add_ancestor(results)
+ results <- HPOExplorer::add_ancestor(results)
results <- map_celltype(results)
results[,is_sig:=q
Date: Thu, 5 Dec 2024 17:24:50 +0000
Subject: [PATCH 20/23] Switch to rworkflows master branch
---
.github/workflows/rworkflows.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/rworkflows.yml b/.github/workflows/rworkflows.yml
index e48f867..75a40a5 100644
--- a/.github/workflows/rworkflows.yml
+++ b/.github/workflows/rworkflows.yml
@@ -38,7 +38,7 @@ jobs:
cont: ~
rspm: ~
steps:
- - uses: neurogenomics/rworkflows@dev
+ - uses: neurogenomics/rworkflows@master
with:
run_bioccheck: ${{ false }}
run_rcmdcheck: ${{ true }}
From a1983d08edf06515f1b33c3fd9dbe246fe230ef3 Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Mon, 16 Dec 2024 14:34:16 +0000
Subject: [PATCH 21/23] Fix `color_vector` assignment
---
DESCRIPTION | 2 +-
NEWS.md | 6 ++++++
R/get_color_map.R | 2 +-
README.md | 4 ++--
4 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/DESCRIPTION b/DESCRIPTION
index ea4df41..7f0590d 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Package: MSTExplorer
Title: Multi-Scale Target Explorer
-Version: 1.0.5
+Version: 1.0.6
Authors@R:
c(
person(given = "Brian",
diff --git a/NEWS.md b/NEWS.md
index 8e58a24..89f1cc3 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,9 @@
+# MSTExplorer 1.0.6
+
+## Bug fixes
+* `get_color_map`
+ - Fix `color_vector` assignment.
+
# MSTExplorer 1.0.5
## Bug fixes
diff --git a/R/get_color_map.R b/R/get_color_map.R
index cc2c393..82999c5 100644
--- a/R/get_color_map.R
+++ b/R/get_color_map.R
@@ -14,7 +14,7 @@ get_color_map <- function(dat,
if(!is.null(celltype_col_order)){
dat2 <- dat2[order(match(dat2[[celltype_col]],celltype_col_order)),]
}
- dat2[,ancestor_color:=color_map[top_ancestor_name]]
+ dat2$ancestor_color<-color_map[dat2[[columns]]]
color_vector <- dat2$ancestor_color
return(list(
color_map=color_map,
diff --git a/README.md b/README.md
index 86e9431..0a41d15 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@ MSTExplorer
[![License:
GPL-3](https://img.shields.io/badge/license-GPL--3-blue.svg)](https://cran.r-project.org/web/licenses/GPL-3)
-[![](https://img.shields.io/badge/devel%20version-1.0.5-black.svg)](https://github.com/neurogenomics/MSTExplorer)
+[![](https://img.shields.io/badge/devel%20version-1.0.6-black.svg)](https://github.com/neurogenomics/MSTExplorer)
[![](https://img.shields.io/github/languages/code-size/neurogenomics/MSTExplorer.svg)](https://github.com/neurogenomics/MSTExplorer)
[![](https://img.shields.io/github/last-commit/neurogenomics/MSTExplorer.svg)](https://github.com/neurogenomics/MSTExplorer/commits/master)
[![R build
@@ -16,7 +16,7 @@ Authors: Brian Schilder, Robert Gordon-Smith, Nathan Skene,
Hiranyamaya Dash
-README updated: Dec-05-2024
+README updated: Dec-16-2024
From 32eced410da78520d1ad573f244964cd3f56ce18 Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Wed, 18 Dec 2024 10:57:52 +0000
Subject: [PATCH 22/23] Temp GA fix: Switch to custom rworkflows fork
---
.github/workflows/rworkflows.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/rworkflows.yml b/.github/workflows/rworkflows.yml
index 75a40a5..92970b1 100644
--- a/.github/workflows/rworkflows.yml
+++ b/.github/workflows/rworkflows.yml
@@ -38,7 +38,7 @@ jobs:
cont: ~
rspm: ~
steps:
- - uses: neurogenomics/rworkflows@master
+ - uses: HDash/rworkflows@temp-citeproc-fix
with:
run_bioccheck: ${{ false }}
run_rcmdcheck: ${{ true }}
From 7555c485c76d9785820cade3086a278a5a2f4b8c Mon Sep 17 00:00:00 2001
From: HDash <16350928+HDash@users.noreply.github.com>
Date: Wed, 18 Dec 2024 14:33:18 +0000
Subject: [PATCH 23/23] Switch back to master rworkflows branch
---
.github/workflows/rworkflows.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/rworkflows.yml b/.github/workflows/rworkflows.yml
index 92970b1..75a40a5 100644
--- a/.github/workflows/rworkflows.yml
+++ b/.github/workflows/rworkflows.yml
@@ -38,7 +38,7 @@ jobs:
cont: ~
rspm: ~
steps:
- - uses: HDash/rworkflows@temp-citeproc-fix
+ - uses: neurogenomics/rworkflows@master
with:
run_bioccheck: ${{ false }}
run_rcmdcheck: ${{ true }}