Skip to content

Commit 54f8878

Browse files
authored
Merge pull request #10116 from samuel-marsh/fix_aes_string
Package-wide fix of `aes_string`
2 parents db9a3fb + 81d135c commit 54f8878

File tree

8 files changed

+143
-124
lines changed

8 files changed

+143
-124
lines changed

NAMESPACE

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,6 @@ importFrom(ggplot2,Geom)
632632
importFrom(ggplot2,GeomPolygon)
633633
importFrom(ggplot2,GeomViolin)
634634
importFrom(ggplot2,aes)
635-
importFrom(ggplot2,aes_string)
636635
importFrom(ggplot2,alpha)
637636
importFrom(ggplot2,annotation_raster)
638637
importFrom(ggplot2,coord_cartesian)
@@ -813,13 +812,16 @@ importFrom(reticulate,py_module_available)
813812
importFrom(reticulate,py_set_seed)
814813
importFrom(rlang,"!!!")
815814
importFrom(rlang,"!!")
815+
importFrom(rlang,.data)
816816
importFrom(rlang,abort)
817817
importFrom(rlang,arg_match)
818818
importFrom(rlang,arg_match0)
819819
importFrom(rlang,as_label)
820820
importFrom(rlang,as_name)
821821
importFrom(rlang,caller_env)
822822
importFrom(rlang,check_installed)
823+
importFrom(rlang,data_sym)
824+
importFrom(rlang,data_syms)
823825
importFrom(rlang,enquo)
824826
importFrom(rlang,exec)
825827
importFrom(rlang,inform)

R/mixscape.R

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ CalcPerturbSig <- function(
128128
#' positive DE genes.If false, only positive DE gene will be displayed.
129129
#' @param max.genes Maximum number of genes to use as input to enrichR.
130130
#' @param logfc.threshold Limit testing to genes which show, on average, at least
131-
#' X-fold difference (log-scale) between the two groups of cells. Default is 0.25.
131+
#' X-fold difference (log-scale) between the two groups of cells. Default is 0.25.
132132
#' Increasing logfc.threshold speeds up the function, but can miss weaker signals.
133133
#' @param p.val.cutoff Cutoff to select DE genes.
134134
#' @param cols A list of colors to use for barplots.
@@ -247,14 +247,14 @@ DEenrichRPlot <- function(
247247

248248
if (isTRUE(x = balanced)) {
249249

250-
p2 <- ggplot(data = neg.er, aes_string(x = "term", y = "log10pval")) +
250+
p2 <- ggplot(data = neg.er, aes(x = .data[["term"]], y = .data[["log10pval"]])) +
251251
geom_bar(stat = "identity", fill = "indianred2") +
252252
coord_flip() + xlab("Pathway") +
253253
scale_fill_manual(values = cols, drop = FALSE) +
254254
ylab("-log10(pval)") +
255255
ggtitle(paste(enrich.database, ident.1, sep = "_", "negative markers")) +
256256
theme_classic() +
257-
geom_text(aes_string(label = "term", y = 0),
257+
geom_text(aes(label = .data[["term"]], y = 0),
258258
size = 5,
259259
color = "black",
260260
position = position_dodge(1),
@@ -271,14 +271,14 @@ DEenrichRPlot <- function(
271271
}
272272

273273
else {
274-
p <- ggplot(data = pos.er, aes_string(x = "term", y = "log10pval")) +
274+
p <- ggplot(data = pos.er, aes(x = .data[["term"]], y = .data[["log10pval"]])) +
275275
geom_bar(stat = "identity", fill = "dodgerblue") +
276276
coord_flip() + xlab("Pathway") +
277277
scale_fill_manual(values = cols, drop = FALSE) +
278278
ylab("-log10(pval)") +
279279
ggtitle(paste(enrich.database, ident.1, sep = "_", "positive markers")) +
280280
theme_classic() +
281-
geom_text(aes_string(label = "term", y = 0),
281+
geom_text(aes(label = .data[["term"]], y = 0),
282282
size = 5,
283283
color = "black",
284284
position = position_dodge(1),
@@ -288,14 +288,14 @@ DEenrichRPlot <- function(
288288
axis.ticks.y = element_blank())
289289
if (isTRUE(x = balanced)) {
290290

291-
p2 <- ggplot(data = neg.er, aes_string(x = "term", y = "log10pval")) +
291+
p2 <- ggplot(data = neg.er, aes(x = .data[["term"]], y = .data[["log10pval"]])) +
292292
geom_bar(stat = "identity", fill = "indianred2") +
293293
coord_flip() + xlab("Pathway") +
294294
scale_fill_manual(values = cols, drop = FALSE) +
295295
ylab("-log10(pval)") +
296296
ggtitle(paste(enrich.database, ident.1, sep = "_", "negative markers")) +
297297
theme_classic() +
298-
geom_text(aes_string(label = "term", y = 0),
298+
geom_text(aes(label = .data[["term"]], y = 0),
299299
size = 5,
300300
color = "black",
301301
position = position_dodge(1),
@@ -371,7 +371,7 @@ MixscapeLDA <- function(
371371
#' @param npcs Number of principle components to use.
372372
#' @param verbose Print progress bar.
373373
#' @param logfc.threshold Limit testing to genes which show, on average, at least
374-
#' X-fold difference (log-scale) between the two groups of cells. Default is 0.25.
374+
#' X-fold difference (log-scale) between the two groups of cells. Default is 0.25.
375375
#' Increasing logfc.threshold speeds up the function, but can miss weaker signals.
376376
#' @return Returns a list of the first 10 PCs from each projection.
377377
#'
@@ -872,7 +872,7 @@ RunMixscape <- function(
872872
#' @param max.genes Total number of DE genes to plot.
873873
#' @param balanced Plot an equal number of genes with both groups of cells.
874874
#' @param logfc.threshold Limit testing to genes which show, on average, at least
875-
#' X-fold difference (log-scale) between the two groups of cells. Default is 0.25.
875+
#' X-fold difference (log-scale) between the two groups of cells. Default is 0.25.
876876
#' Increasing logfc.threshold speeds up the function, but can miss weaker signals.
877877
#' @param order.by.prob Order cells on heatmap based on their mixscape knockout
878878
#' probability from highest to lowest score.
@@ -888,7 +888,7 @@ RunMixscape <- function(
888888
#'
889889
#' @importFrom stats median
890890
#' @importFrom scales hue_pal
891-
#' @importFrom ggplot2 annotation_raster coord_cartesian ggplot_build aes_string
891+
#' @importFrom ggplot2 annotation_raster coord_cartesian ggplot_build
892892
#' @export
893893
#' @concept mixscape
894894
#'
@@ -1004,7 +1004,7 @@ MixscapeHeatmap <- function(
10041004
#'
10051005
#' @importFrom stats median
10061006
#' @importFrom scales hue_pal
1007-
#' @importFrom ggplot2 annotation_raster coord_cartesian ggplot_build aes_string
1007+
#' @importFrom ggplot2 annotation_raster coord_cartesian ggplot_build
10081008
#' geom_density theme_classic
10091009
#' @export
10101010
#' @concept mixscape
@@ -1040,7 +1040,7 @@ PlotPerturbScore <- function(
10401040
nm = c(gd, target.gene.ident)
10411041
)
10421042

1043-
p <- ggplot(data = prtb_score, mapping = aes_string(x = "pvec", color = "gene")) +
1043+
p <- ggplot(data = prtb_score, mapping = aes(x = .data[["pvec"]], color = .data[["gene"]])) +
10441044
geom_density() + theme_classic()
10451045
top_r <- ggplot_build(p)$layout$panel_params[[1]]$y.range[2]
10461046
prtb_score$y.jitter <- prtb_score$pvec
@@ -1059,7 +1059,7 @@ PlotPerturbScore <- function(
10591059
prtb_score$split <- as.character(object[[split.by]][prtb_score$cell.bc,1])
10601060
p2 <- p + scale_color_manual(values = cols, drop = FALSE) +
10611061
geom_density(size = 1.5) +
1062-
geom_point(data = prtb_score, aes_string(x = "pvec", y = "y.jitter"), size = 0.1) +
1062+
geom_point(data = prtb_score, aes(x = .data[["pvec"]], y = .data[["y.jitter"]]), size = 0.1) +
10631063
theme(axis.text = element_text(size = 18), axis.title = element_text(size = 20)) +
10641064
ylab("Cell density") + xlab("perturbation score") +
10651065
theme(legend.key.size = unit(1, "cm"),
@@ -1071,7 +1071,7 @@ PlotPerturbScore <- function(
10711071
else{
10721072
p2 <- p + scale_color_manual(values = cols, drop = FALSE) +
10731073
geom_density(size = 1.5) +
1074-
geom_point(data = prtb_score, aes_string(x = "pvec", y = "y.jitter"), size = 0.1) +
1074+
geom_point(data = prtb_score, aes(x = .data[["pvec"]], y = .data[["y.jitter"]]), size = 0.1) +
10751075
theme(axis.text = element_text(size = 18), axis.title = element_text(size = 20)) +
10761076
ylab("Cell density") + xlab("perturbation score") +
10771077
theme(legend.key.size = unit(1, "cm"),
@@ -1089,7 +1089,7 @@ PlotPerturbScore <- function(
10891089
#add mixscape identities
10901090
prtb_score$mix <- object[[mixscape.class]][prtb_score$cell.bc,]
10911091

1092-
p <- ggplot(data = prtb_score, aes_string(x = "pvec", color = "mix")) +
1092+
p <- ggplot(data = prtb_score, aes(x = .data[["pvec"]], color = .data[["mix"]])) +
10931093
geom_density() + theme_classic()
10941094

10951095
top_r <- ggplot_build(p)$layout$panel_params[[1]]$y.range[2]
@@ -1117,10 +1117,10 @@ PlotPerturbScore <- function(
11171117

11181118
if(is.null(split.by) == FALSE){
11191119
prtb_score$split <- as.character(object[[split.by]][prtb_score$cell.bc,1])
1120-
p2 <- ggplot(data = prtb_score, aes_string(x = "pvec", color = "mix")) +
1120+
p2 <- ggplot(data = prtb_score, aes(x = .data[["pvec"]], color = .data[["mix"]])) +
11211121
scale_color_manual(values = cols, drop = FALSE) +
11221122
geom_density(size = 1.5) +
1123-
geom_point(aes_string(x = "pvec", y = "y.jitter"), size = 0.1) +
1123+
geom_point(aes(x = .data[["pvec"]], y = .data[["y.jitter"]]), size = 0.1) +
11241124
theme_classic() +
11251125
theme(axis.text = element_text(size = 18), axis.title = element_text(size = 20)) +
11261126
ylab("Cell density") + xlab("perturbation score") +
@@ -1133,7 +1133,7 @@ PlotPerturbScore <- function(
11331133
else{
11341134
p2 <- p + scale_color_manual(values = cols, drop = FALSE) +
11351135
geom_density(size = 1.5) +
1136-
geom_point(data = prtb_score, aes_string(x = "pvec", y = "y.jitter"), size = 0.1) +
1136+
geom_point(data = prtb_score, aes(x = .data[["pvec"]], y = .data[["y.jitter"]]), size = 0.1) +
11371137
theme(axis.text = element_text(size = 18), axis.title = element_text(size = 20)) +
11381138
ylab("Cell density") + xlab("perturbation score") +
11391139
theme(legend.key.size = unit(1, "cm"),

0 commit comments

Comments
 (0)