Skip to content

Commit

Permalink
Merge pull request #38 from nuno-agostinho/dev
Browse files Browse the repository at this point in the history
cTRAP 1.20.1
  • Loading branch information
nuno-agostinho authored Mar 27, 2024
2 parents ac97834 + a177f66 commit 8763bdb
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 57 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -30,7 +30,7 @@ Suggests:
spelling,
biomaRt,
remotes
RoxygenNote: 7.2.0
RoxygenNote: 7.3.1
Imports: AnnotationDbi,
AnnotationHub,
binr,
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/drugSensitivity.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) +
Expand Down
23 changes: 12 additions & 11 deletions R/plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -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() +
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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) +
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) +
Expand Down
18 changes: 11 additions & 7 deletions R/shinyInterface.R
Original file line number Diff line number Diff line change
Expand Up @@ -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;")
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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")) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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(...) {
Expand Down
15 changes: 6 additions & 9 deletions R/shinyInterface_session.R
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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"),
Expand All @@ -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)
}

Expand Down Expand Up @@ -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(...)

Expand Down
4 changes: 2 additions & 2 deletions dev/benchmark/R/memoryConsumptionPlot_help.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) +
Expand Down
57 changes: 38 additions & 19 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion man/analyseDrugSetEnrichment.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions man/cTRAP.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/launchMetadataViewer.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions tests/testthat/test_plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

Expand Down

0 comments on commit 8763bdb

Please sign in to comment.