Skip to content

Commit

Permalink
Avoid using deprecated aes_string()
Browse files Browse the repository at this point in the history
  • Loading branch information
nuno-agostinho authored Mar 6, 2024
1 parent 1e7f5c8 commit 7d9c082
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
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
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
19 changes: 10 additions & 9 deletions R/plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ 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"]], .data[[0]], fill="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,
geom_area(aes(group="quantile", fill="quantile"), na.rm=TRUE,
position="identity")
}
xBreaks <- c(min(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=.data[[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
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

0 comments on commit 7d9c082

Please sign in to comment.