diff --git a/DESCRIPTION b/DESCRIPTION index e58adaf6..542f2980 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: cTRAP Title: Identification of candidate causal perturbations from differential gene expression data -Version: 1.14.1 +Version: 1.20.1 Authors@R: c( person(c("Bernardo", "P."), "de Almeida", role="aut"), person("Nuno", "Saraiva-Agostinho", @@ -30,7 +30,7 @@ Suggests: spelling, biomaRt, remotes -RoxygenNote: 7.2.0 +RoxygenNote: 7.3.1 Imports: AnnotationDbi, AnnotationHub, binr, diff --git a/NAMESPACE b/NAMESPACE index ccb2b6f7..b52a3ae4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -67,7 +67,6 @@ importFrom(fastmatch,fmatch) importFrom(fgsea,calcGseaStat) importFrom(fgsea,fgsea) importFrom(ggplot2,aes) -importFrom(ggplot2,aes_string) importFrom(ggplot2,annotate) importFrom(ggplot2,element_blank) importFrom(ggplot2,element_rect) diff --git a/NEWS.md b/NEWS.md index c9813d4f..7cbf5fad 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# cTRAP 1.20.1 (6 March, 2024) + +* When running `cTRAP()`, raise error if `commonPath` does not exist +* Fix modular graphical interface functions not showing dropdown choices +* Update icon names for FontAwesome 6 + # cTRAP 1.14.1 (14 July, 2022) * Add cTRAP version to welcome modal @@ -145,7 +151,7 @@ down-regulated genes with `geneSize` argument: * Plotting: - `plot()` now supports plotting `predictTargetingDrugs()` results for a given drug, e.g. `plot(targetingDrugs, "1425")` - - `plot()` nows allows to set plot title with argument `title` + - `plot()` now allows to set plot title with argument `title` - `plot()` now plots results based on available methods instead of trying to plot based on results from `spearman` method only - GSEA plots now support two or less gene hits diff --git a/R/drugSensitivity.R b/R/drugSensitivity.R index bab6fd3b..58450135 100644 --- a/R/drugSensitivity.R +++ b/R/drugSensitivity.R @@ -734,7 +734,7 @@ plotTargetingDrug <- function(x, drug, method=c("spearman", "pearson", "gsea"), } df <- data.frame(input=input[intersecting], cor=val) - plot <- ggplot(df, aes_string("input", "cor")) + + plot <- ggplot(df, aes(.data[["input"]], .data[["cor"]])) + geom_point(alpha=0.1, na.rm=TRUE) + geom_rug(alpha=0.1) + geom_density_2d(na.rm=TRUE) + diff --git a/R/plots.R b/R/plots.R index a8987e27..c03765fc 100644 --- a/R/plots.R +++ b/R/plots.R @@ -41,7 +41,7 @@ plotESplot <- function(enrichmentScore, gseaStat, compact=FALSE) { geom_hline(yintercept=0, colour="darkgrey", linetype="longdash") + geom_hline(yintercept=ES, colour="#3895D3") + geom_rug(alpha=rugAlpha, sides="b", length=unit(rugLength, "npc")) + - geom_line(colour="orange", na.rm=TRUE, size=0.7) + + geom_line(colour="orange", na.rm=TRUE, linewidth=0.7) + scale_x_continuous(expand=c(0,0)) + labs(y="Enrichment score") + theme_bw() + @@ -94,14 +94,14 @@ plotMetricDistribution <- function(stat, compact=FALSE) { rankedMetric <- data.frame(sort=seq(stat), stat=stat, quantile=quantile) if (compact) { - aes <- aes_string("sort", 0, fill="stat") + aes <- aes(.data[["sort"]], 0, fill=.data[["stat"]]) metricPlot <- ggplot(rankedMetric, aes) + geom_raster() } else { - aes <- aes_string("sort", "stat") + aes <- aes(.data[["sort"]], .data[["stat"]]) metricPlot <- ggplot(rankedMetric, aes) + - geom_area(aes_string(group="quantile", fill="quantile"), na.rm=TRUE, - position="identity") + geom_area(aes(group=.data[["quantile"]], fill=.data[["quantile"]]), + na.rm=TRUE, position="identity") } xBreaks <- c(min(rankedMetric$sort), extended_breaks()(rankedMetric$sort), @@ -233,10 +233,11 @@ plotSingleCorr <- function(perturbation, ylabel, diffExprGenes, title=NULL) { multipleCellLines <- length(perturbation) > 1 if (multipleCellLines) { - aesMap <- aes_string("diffExprGenes", "zscores", colour="perturbation") + aesMap <- aes(.data[["diffExprGenes"]], .data[["zscores"]], + colour="perturbation") guide <- guides(colour=guide_legend(title="Cell line")) } else { - aesMap <- aes_string("diffExprGenes", "zscores") + aesMap <- aes(.data[["diffExprGenes"]], .data[["zscores"]]) guide <- NULL } @@ -378,7 +379,7 @@ plotComparison <- function(x, method, n, showMetadata, } # Correlation coefficient with labels for top and bottom perturbations - vars <- aes_string(x=1, y=stat, label="label", colour="ranked") + vars <- aes(x=1, y=.data[[stat]], label="label", colour="ranked") rug <- geom_rug(alpha=alpha, sides="l") plot <- ggplot(x, vars) + @@ -440,8 +441,8 @@ plotComparison <- function(x, method, n, showMetadata, #' #' @importFrom graphics plot #' @importFrom R.utils capitalize -#' @importFrom ggplot2 ggplot aes_string geom_point geom_hline ylab theme -#' element_blank scale_colour_manual xlim theme_classic guides scale_y_reverse +#' @importFrom ggplot2 ggplot aes geom_point geom_hline ylab theme element_blank +#' scale_colour_manual xlim theme_classic guides scale_y_reverse #' @importFrom ggrepel geom_text_repel #' #' @family functions related with the ranking of CMap perturbations @@ -675,7 +676,7 @@ plotTargetingDrugsVSsimilarPerturbations <- function( ylabel <- paste("CMap comparison:", column) df$highlight <- highlight - plot <- ggplot(df, aes_string(cols[[1]], cols[[2]], colour=highlight)) + + plot <- ggplot(df, aes(.data[[ cols[[1]] ]], .data[[ cols[[2]] ]], colour=highlight)) + geom_point(alpha=0.7, show.legend=FALSE) + geom_rug(alpha=0.3, show.legend=FALSE) + xlab(xlabel) + diff --git a/R/shinyInterface.R b/R/shinyInterface.R index 0e828153..a400a18d 100644 --- a/R/shinyInterface.R +++ b/R/shinyInterface.R @@ -109,7 +109,11 @@ #' @keywords internal .prepareNavPage <- function(...) { app <- "cTRAP" - ui <- navbarPage(app, ...) %>% + # Add JS and CSS in header + header <- tagList( + includeScript(system.file("shiny", "www", "cTRAP.js", package="cTRAP")), + includeCSS(system.file("shiny", "www", "cTRAP.css", package="cTRAP"))) + ui <- navbarPage(app, ..., header=header) %>% .replaceStrInList("navbar-static-top", "") %>% .replaceStrInList("container-fluid", "") %>% tags$div(class="container-fluid", style="padding-top: 15px;") @@ -321,7 +325,7 @@ diffExpr <- tags$span( "data-toggle"="tooltip", "data-placement"="right", title="Gene symbols and respective differential expression values (e.g. t-statistics)", - "Differential gene expression", icon("question-circle")) + "Differential gene expression", icon("circle-question")) sidebar <- sidebarPanel( textAreaInput(ns("diffExpr"), diffExpr, height="300px"), @@ -1148,17 +1152,17 @@ convertTaskState2HTML <- function(state, toStr=TRUE, ..., label=FALSE) { state <- tolower(state) if (state %in% c("failure", "revoked")) { colour <- "red" - icon <- icon("times-circle") + icon <- icon("circle-xmark") state <- "Error" class <- "danger" } else if (state %in% c("not found")) { colour <- "red" - icon <- icon("question-circle") + icon <- icon("circle-question") state <- "Not Found" class <- "danger" } else if (state %in% c("received", "pending", "retry")) { colour <- "grey" - icon <- icon("pause-circle") + icon <- icon("circle-pause") state <- "Waiting" class <- "default" } else if (state %in% c("started")) { @@ -1168,7 +1172,7 @@ convertTaskState2HTML <- function(state, toStr=TRUE, ..., label=FALSE) { class <- "warning" } else if (state %in% c("success", "loaded")) { colour <- "green" - icon <- icon("check-circle") + icon <- icon("circle-check") state <- "Loaded" class <- "success" } else { @@ -1711,7 +1715,7 @@ launchCMapDataLoader <- function(metadata="cmapMetadata.txt", #' #' @importFrom shiny runApp shinyApp #' -#' @return Metadata viewer (retunrs \code{NULL}) +#' @return Metadata viewer (returns \code{NULL}) #' @family visual interface functions #' @export launchMetadataViewer <- function(...) { diff --git a/R/shinyInterface_session.R b/R/shinyInterface_session.R index eacaf8e5..01e54418 100644 --- a/R/shinyInterface_session.R +++ b/R/shinyInterface_session.R @@ -63,12 +63,12 @@ loadTokenUI <- tagList( textInput("token", "Insert token of a previous session:"), actionButton("loadToken", "Load session with token", - width="100%", icon=icon("history"), class="btn-info")) + width="100%", icon=icon("clock-rotate-left"), class="btn-info")) loadDataUI <- tagList( fileInput("sessionFile", width="100%", multiple=TRUE, accept=".rds", "Upload RDS file of a previous session:"), actionButton("loadData", "Load session from RDS file", width="100%", - icon=icon("history"), class="btn-info")) + icon=icon("clock-rotate-left"), class="btn-info")) pills <- tabsetPanel( type="pills", tabPanel("Session token", loadTokenUI), @@ -164,7 +164,7 @@ globalUI <- function(elems, idList, expire) { .diffExprENCODEloaderUI(idList$encode), "----", .cmapDataLoaderUI(idList$cmap, globalUI=TRUE)), - navbarMenu("Analyse", icon=icon("cogs"), + navbarMenu("Analyse", icon=icon("gears"), .rankSimilarPerturbationsUI(idList$rankPerts), .predictTargetingDrugsUI(idList$predictDrugs)), navbarMenu("Visualise", icon=icon("chart-bar"), @@ -178,12 +178,6 @@ globalUI <- function(elems, idList, expire) { icon=icon("compass"), menuName="session")) ui <- .modifySessionUI(ui, expire=expire) ui <- .addLoadingStatus(ui) - - # Add JS and CSS in header - header <- tags$head( - includeScript(system.file("shiny", "www", "cTRAP.js", package="cTRAP")), - includeCSS(system.file("shiny", "www", "cTRAP.css", package="cTRAP"))) - ui <- tagList(header, ui) return(ui) } @@ -439,6 +433,9 @@ updateAppData <- function(appData, x) { cTRAP <- function(..., commonPath="data", expire=14, fileSizeLimitMiB=50, flowerURL=NULL, port=getOption("shiny.port"), host=getOption("shiny.host", "127.0.0.1")) { + if (!dir.exists(commonPath)) { + stop("commonPath directory does not exist:", commonPath) + } .setFileSizeLimit(fileSizeLimitMiB) elems <- .prepareEllipsis(...) diff --git a/dev/benchmark/R/memoryConsumptionPlot_help.R b/dev/benchmark/R/memoryConsumptionPlot_help.R index dce08f3f..1fdb9ada 100644 --- a/dev/benchmark/R/memoryConsumptionPlot_help.R +++ b/dev/benchmark/R/memoryConsumptionPlot_help.R @@ -78,8 +78,8 @@ addNAsBetweenCategories <- function(snap) { library(ggplot2) plotMemConsumption <- function(data) { - ggplot(data, aes_string("time / 60", "memory", ymax="memory", - colour="category", fill="category")) + + ggplot(data, aes(.data[["time / 60"]], .data[["memory"]], ymax="memory", + colour="category", fill="category")) + xlab("Time (minutes)") + ylab("Memory (GB)") + geom_ribbon(alpha=0.8, ymin=0) + diff --git a/inst/WORDLIST b/inst/WORDLIST index f3056967..60945c3a 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -1,42 +1,61 @@ +API's Agostinho +AnnotationHub +BPPARAM Benjamini BiocViews -biomaRt -bplapply -bpparam -BPPARAM CMap +CMap's +COMPZ CTRP +DT +EIF ENSEMBL +FontAwesome GCT GCTX GDSC +GESA +GSE GSEA +HDF +HepG Hochberg +IPv ImmunoOncology Instituto -knockdown -Medicina +LINCS MOA +MODZ +Medicina +Minimial NCI -nperm -nproc -pertubations RSEM +RStudio Saraiva -shRNA -timepoint -transcriptomic +ShinyProxy Transcriptomics -upregulation WTCS +biomaRt +bplapply +bpparam +dropdown filepath -HepG +floweRy +gctx +gseaParam +gz +knockdown nd -CMap's -EIF -st +negateive +nperm +nproc +pos seq -Minimial +shRNA +st statis -gseaParam +std +timepoint +transcriptomic +upregulation diff --git a/man/analyseDrugSetEnrichment.Rd b/man/analyseDrugSetEnrichment.Rd index ae81e2b5..436d2752 100644 --- a/man/analyseDrugSetEnrichment.Rd +++ b/man/analyseDrugSetEnrichment.Rd @@ -36,7 +36,11 @@ if class of \code{stats} is either \code{similarPerturbations} or Arguments passed on to \code{\link[fgsea:fgseaSimple]{fgsea::fgseaSimple}} \describe{ \item{\code{minSize}}{Minimal size of a gene set to test. All pathways below the threshold are excluded.} - \item{\code{scoreType}}{This parameter defines the GSEA score type. Possible options are ("std", "pos", "neg")} + \item{\code{scoreType}}{This parameter defines the GSEA score type. +Possible options are ("std", "pos", "neg"). +By default ("std") the enrichment score is computed as in the original GSEA. +The "pos" and "neg" score types are intended to be used for one-tailed tests +(i.e. when one is interested only in positive ("pos") or negateive ("neg") enrichment).} \item{\code{nproc}}{If not equal to zero sets BPPARAM to use nproc workers (default = 0).} \item{\code{gseaParam}}{GSEA parameter value, all gene-level statis are raised to the power of `gseaParam` before calculation of GSEA enrichment scores.} diff --git a/man/cTRAP.Rd b/man/cTRAP.Rd index 8e15a103..b4d6bdd9 100644 --- a/man/cTRAP.Rd +++ b/man/cTRAP.Rd @@ -2,6 +2,7 @@ % Please edit documentation in R/cTRAP-package.r, R/shinyInterface_session.R \docType{package} \name{cTRAP} +\alias{cTRAP-package} \alias{cTRAP} \title{cTRAP package} \usage{ @@ -84,11 +85,29 @@ Values for each perturbation type can be listed with based on the associated statistical values and respective p-values. } \seealso{ +Useful links: +\itemize{ + \item \url{https://nuno-agostinho.github.io/cTRAP} + \item \url{https://github.com/nuno-agostinho/cTRAP} + \item Report bugs at \url{https://github.com/nuno-agostinho/cTRAP/issues} +} + + Other visual interface functions: \code{\link{launchCMapDataLoader}()}, \code{\link{launchDiffExprLoader}()}, \code{\link{launchDrugSetEnrichmentAnalyser}()}, \code{\link{launchMetadataViewer}()}, \code{\link{launchResultPlotter}()} +} +\author{ +\strong{Maintainer}: Nuno Saraiva-Agostinho \email{nunodanielagostinho@gmail.com} + +Authors: +\itemize{ + \item Bernardo P. de Almeida + \item Nuno L. Barbosa-Morais [lead] +} + } \concept{visual interface functions} diff --git a/man/launchMetadataViewer.Rd b/man/launchMetadataViewer.Rd index 361efa04..3abacc31 100644 --- a/man/launchMetadataViewer.Rd +++ b/man/launchMetadataViewer.Rd @@ -10,7 +10,7 @@ launchMetadataViewer(...) \item{...}{Objects} } \value{ -Metadata viewer (retunrs \code{NULL}) +Metadata viewer (returns \code{NULL}) } \description{ View metadata via a visual interface diff --git a/tests/testthat/test_plots.R b/tests/testthat/test_plots.R index c5dcecad..d54ed94f 100644 --- a/tests/testthat/test_plots.R +++ b/tests/testthat/test_plots.R @@ -59,13 +59,12 @@ test_that("Plot similar perturbations with/without metadata", { test_that("Plot only ranked perturbations", { plot <- plot(cmp, "spearman", plotNonRankedPerturbations=FALSE) expect_s3_class(plot, "ggplot") - expect_equal(plot$guides$colour, "none") + expect_null(plot$guides$colour) }) test_that("Plot non-ranked perturbations", { plot <- plot(cmp, "spearman", plotNonRankedPerturbations=TRUE) expect_s3_class(plot, "ggplot") - expect_identical(plot$labels$colour, "ranked") expect_null(plot$guides$colour) })