Skip to content

Commit 64058e3

Browse files
authored
fix(dataProcessPlots, groupComparisonPlots): Migrate away from deprecated functions for ggplot (#175)
1 parent d71faa3 commit 64058e3

File tree

6 files changed

+50
-47
lines changed

6 files changed

+50
-47
lines changed

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ Imports:
3737
graphics,
3838
methods,
3939
statmod,
40-
parallel
40+
parallel,
41+
rlang
4142
Suggests:
4243
BiocStyle,
4344
knitr,
@@ -53,7 +54,7 @@ biocViews: ImmunoOncology, MassSpectrometry, Proteomics, Software, Normalization
5354
LazyData: true
5455
URL: http://msstats.org
5556
BugReports: https://groups.google.com/forum/#!forum/msstats
56-
RoxygenNote: 7.3.2
57+
RoxygenNote: 7.3.3
5758
Encoding: UTF-8
5859
NeedsCompilation: no
5960
Packaged: 2017-10-20 02:13:12 UTC; meenachoi

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ importFrom(plotly,plot_ly)
106106
importFrom(plotly,style)
107107
importFrom(plotly,subplot)
108108
importFrom(preprocessCore,normalize.quantiles)
109+
importFrom(rlang,.data)
109110
importFrom(stats,dist)
110111
importFrom(stats,fitted)
111112
importFrom(stats,formula)

R/groupComparisonQCPlots.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ modelBasedQCPlots = function(
121121
slope = diff(y) / diff(x)
122122
int = y[1L] - slope * x[1L]
123123

124-
plot = ggplot(sub.residuals.table, aes(sample = residual)) +
124+
plot = ggplot(sub.residuals.table, aes(sample = .data$residual)) +
125125
geom_point(stat = "qq", alpha = 0.8,
126126
shape = 20, size = dot.size) +
127127
scale_shape(solid=FALSE) +
@@ -172,7 +172,7 @@ modelBasedQCPlots = function(
172172
sub.residuals.table = data.frame("residual" = sub.residuals,
173173
"fitted" = sub.fitted)
174174

175-
plot = ggplot(aes_string(x = "fitted", y = "residual"),
175+
plot = ggplot(aes(x = .data$fitted, y = .data$residual),
176176
data = sub.residuals.table) +
177177
geom_point(size = dot.size,
178178
alpha = 0.5) +
@@ -263,4 +263,4 @@ groupComparisonQCPlots = function(data, type, axis.size = 10, dot.size = 3, widt
263263

264264
modelBasedQCPlots(data, type, axis.size, dot.size, width, height,
265265
which.Protein, address, FALSE)
266-
}
266+
}

R/msstats-package.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#' @import data.table
22
## usethis namespace: start
33
#' @importFrom Rcpp sourceCpp
4+
#' @importFrom rlang .data
45
## usethis namespace: end
56
#' @useDynLib MSstats, .registration=TRUE
67
NULL

R/utils_dataprocess_plots.R

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@
5656
type_color = "PEPTIDE"
5757
}
5858

59-
profile_plot = ggplot(input, aes_string(x = "RUN", y = "newABUNDANCE",
60-
color = type_color, linetype = "FEATURE")) +
59+
profile_plot = ggplot(data = input, aes(x = .data$RUN, y = .data$newABUNDANCE,
60+
color = .data[[type_color]], linetype = .data$FEATURE)) +
6161
facet_grid(~LABEL) +
62-
geom_line(size = 0.5)
62+
geom_line(linewidth = 0.5)
6363

6464
if (is_censored) {
6565
profile_plot = profile_plot +
66-
geom_point(aes_string(x = "RUN", y = "newABUNDANCE", color = type_color, shape = "censored"),
66+
geom_point(aes(x = .data$RUN, y = .data$newABUNDANCE, color = .data[[type_color]], shape = .data$censored),
6767
data = input,
6868
size = dot.size.profile) +
6969
scale_shape_manual(values = c(16, 1),
@@ -97,7 +97,7 @@
9797
scale_y_continuous(yaxis.name, limits = c(y.limdown, y.limup)) +
9898
geom_vline(xintercept = lineNameAxis + 0.5, colour = "grey", linetype = "longdash") +
9999
labs(title = unique(input$PROTEIN)) +
100-
geom_text(data = groupNametemp, aes(x = RUN, y = ABUNDANCE, label = Name),
100+
geom_text(data = groupNametemp, aes(x = .data$RUN, y = .data$ABUNDANCE, label = .data$Name),
101101
size = text.size,
102102
angle = text.angle,
103103
color = "black") +
@@ -156,22 +156,22 @@
156156

157157
num_features = data.table::uniqueN(input$FEATURE)
158158
profile_plot = ggplot(data = input,
159-
aes_string(x = "RUN", y = "newABUNDANCE",
160-
color = "analysis", linetype = "FEATURE",
161-
size = "analysis")) +
159+
aes(x = .data$RUN, y = .data$newABUNDANCE,
160+
color = .data$analysis, linetype = .data$FEATURE,
161+
size = .data$analysis)) +
162162
facet_grid(~LABEL) +
163-
geom_line(size = 0.5)
163+
geom_line(linewidth = 0.5)
164164

165165
if (is_censored) { # splitting into two layers to keep red above grey
166166
profile_plot = profile_plot +
167167
geom_point(data = input[input$PEPTIDE != "Run summary"],
168-
aes_string(x = "RUN", y = "newABUNDANCE",
169-
color = "analysis", size = "analysis",
170-
shape = "censored")) +
168+
aes(x = .data$RUN, y = .data$newABUNDANCE,
169+
color = .data$analysis, size = .data$analysis,
170+
shape = .data$censored)) +
171171
geom_point(data = input[input$PEPTIDE == "Run summary"],
172-
aes_string(x = "RUN", y = "newABUNDANCE",
173-
color = "analysis", size = "analysis",
174-
shape = "censored")) +
172+
aes(x = .data$RUN, y = .data$newABUNDANCE,
173+
color = .data$analysis, size = .data$analysis,
174+
shape = .data$censored)) +
175175
scale_shape_manual(values = c(16, 1),
176176
labels = c("Detected data",
177177
"Censored missing data"))
@@ -191,7 +191,7 @@
191191
geom_vline(xintercept = lineNameAxis + 0.5,
192192
colour = "grey", linetype = "longdash") +
193193
labs(title = unique(input$PROTEIN)) +
194-
geom_text(data = groupNametemp, aes(x = RUN, y = ABUNDANCE, label = Name),
194+
geom_text(data = groupNametemp, aes(x = .data$RUN, y = .data$ABUNDANCE, label = .data$Name),
195195
size = text.size,
196196
angle = text.angle,
197197
color = "black") +
@@ -209,8 +209,8 @@
209209
} else {
210210
profile_plot = profile_plot +
211211
guides(color = color_guide) +
212-
geom_point(aes_string(x = "RUN", y = "newABUNDANCE", size = "analysis",
213-
color = "analysis"), data = input)
212+
geom_point(aes(x = .data$RUN, y = .data$newABUNDANCE, size = .data$analysis,
213+
color = .data$analysis), data = input)
214214
}
215215
profile_plot
216216
}
@@ -234,17 +234,17 @@
234234
plot_title = unique(input$PROTEIN)
235235
}
236236

237-
ggplot(input, aes_string(x = "RUN", y = "ABUNDANCE")) +
237+
ggplot(input, aes(x = .data$RUN, y = .data$ABUNDANCE)) +
238238
facet_grid(~LABEL) +
239-
geom_boxplot(aes_string(fill = "LABEL"), outlier.shape = 1,
239+
geom_boxplot(aes(fill = .data$LABEL), outlier.shape = 1,
240240
outlier.size = 1.5) +
241241
scale_fill_manual(values = label.color, guide = "none") +
242242
scale_x_discrete("MS runs", breaks = cumGroupAxis) +
243243
scale_y_continuous(yaxis.name, limits = c(y.limdown, y.limup)) +
244244
geom_vline(xintercept = lineNameAxis + 0.5, colour = "grey",
245245
linetype = "longdash") +
246246
labs(title = plot_title) +
247-
geom_text(data = groupName, aes(x = RUN, y = ABUNDANCE, label = Name),
247+
geom_text(data = groupName, aes(x = .data$RUN, y = .data$ABUNDANCE, label = .data$Name),
248248
size = text.size, angle = text.angle, color = "black") +
249249
theme_msstats("QCPLOT", x.axis.size, y.axis.size,
250250
legend_size = NULL)
@@ -268,8 +268,8 @@
268268
input$Label = as.numeric(gsub("\\D", "", unique(input$Label)))
269269
}
270270

271-
plot = ggplot(aes_string(x = "Label", y = "Mean"), data = input) +
272-
geom_errorbar(aes(ymax = Mean + ciw, ymin = Mean - ciw),
271+
plot = ggplot(aes(x = .data$Label, y = .data$Mean), data = input) +
272+
geom_errorbar(aes(ymax = .data$Mean + .data$ciw, ymin = .data$Mean - .data$ciw),
273273
data = input, width = 0.1, colour = "red") +
274274
geom_point(size = dot.size.condition, colour = "darkred")
275275

@@ -283,9 +283,9 @@
283283
plot = plot +
284284
scale_y_continuous(yaxis.name, limits = c(y.limdown, y.limup)) +
285285
geom_hline(yintercept = 0, linetype = "twodash",
286-
colour = "darkgrey", size = 0.6) +
286+
colour = "darkgrey", linewidth = 0.6) +
287287
labs(title = unique(single_protein$PROTEIN)) +
288288
theme_msstats("CONDITIONPLOT", x.axis.size, y.axis.size,
289289
text_angle = text.angle)
290290
plot
291-
}
291+
}

R/utils_groupcomparison_plots.R

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@ colMin <- function(data) sapply(data, min, na.rm = TRUE)
189189
legend.size, log_adjp
190190
) {
191191
Protein = NULL
192-
plot = ggplot(aes_string(x = "logFC",
193-
y = log_adjp,
194-
color = "colgroup",
195-
label = "Protein"),
192+
plot = ggplot(aes(x = .data$logFC,
193+
y = .data[[log_adjp]],
194+
color = .data$colgroup,
195+
label = .data$Protein),
196196
data = input) +
197197
geom_point(size = dot.size) +
198198
scale_colour_manual(values = c("gray65", "blue", "red"),
@@ -209,7 +209,7 @@ colMin <- function(data) sapply(data, min, na.rm = TRUE)
209209
if (!(length(unique(input$colgroup)) == 1 & any(unique(input$colgroup) == "black"))) {
210210
plot = plot +
211211
geom_text_repel(data = input[input$colgroup != "black", ],
212-
aes(label = Protein),
212+
aes(label = .data$Protein),
213213
size = text.size,
214214
col = "black")
215215
}
@@ -226,9 +226,9 @@ colMin <- function(data) sapply(data, min, na.rm = TRUE)
226226
if (!FCcutoff) {
227227
plot = plot +
228228
geom_line(data = sigcut,
229-
aes_string(x = "logFC", y = log_adjp, linetype = "line"),
229+
aes(x = .data$logFC, y = .data[[log_adjp]], linetype = .data$line),
230230
colour = "darkgrey",
231-
size = 0.6,
231+
linewidth = 0.6,
232232
show.legend = TRUE) +
233233
scale_linetype_manual(values = c("twodash" = 6),
234234
labels = c(paste0("Adj p-value cutoff (", sig, ")"))) +
@@ -248,19 +248,19 @@ colMin <- function(data) sapply(data, min, na.rm = TRUE)
248248
c("Protein", "logFC", log_adjp, "line"))
249249
plot = plot +
250250
geom_line(data = sigcut,
251-
aes_string(x = "logFC", y = log_adjp, linetype = "line"),
251+
aes(x = .data$logFC, y = .data[[log_adjp]], linetype = .data$line),
252252
colour = "darkgrey",
253-
size = 0.6,
253+
linewidth = 0.6,
254254
show.legend = TRUE) +
255255
geom_line(data = FCcutpos,
256-
aes_string(x = "logFC", y = log_adjp, linetype = "line"),
256+
aes(x = .data$logFC, y = .data[[log_adjp]], linetype = .data$line),
257257
colour = "darkgrey",
258-
size = 0.6,
258+
linewidth = 0.6,
259259
show.legend = TRUE) +
260260
geom_line(data = FCcutneg,
261-
aes_string(x = "logFC", y = log_adjp, linetype = "line"),
261+
aes(x = .data$logFC, y = .data[[log_adjp]], linetype = .data$line),
262262
colour = "darkgrey",
263-
size = 0.6) +
263+
linewidth = 0.6) +
264264
scale_linetype_manual(values = c("dotted" = 3, "twodash" = 6),
265265
labels = c(paste0("Fold change cutoff (", FCcutoff, ")"),
266266
paste0("Adj p-value cutoff (", sig, ")"))) +
@@ -288,8 +288,8 @@ colMin <- function(data) sapply(data, min, na.rm = TRUE)
288288
logFC = ciw = NULL
289289

290290
protein = unique(input$Protein)
291-
plot = ggplot(input, aes_string(x = "Label", y = "logFC")) +
292-
geom_errorbar(aes(ymax = logFC + ciw, ymin = logFC - ciw),
291+
plot = ggplot(input, aes(x = .data$Label, y = .data$logFC)) +
292+
geom_errorbar(aes(ymax = .data$logFC + .data$ciw, ymin = .data$logFC - .data$ciw),
293293
data = input,
294294
width = 0.1,
295295
colour = "red") +
@@ -299,7 +299,7 @@ colMin <- function(data) sapply(data, min, na.rm = TRUE)
299299
geom_hline(yintercept = 0,
300300
linetype = "twodash",
301301
colour = "darkgrey",
302-
size = 0.6) +
302+
linewidth = 0.6) +
303303
labs(title = protein) +
304304
theme_msstats("COMPARISONPLOT", x.axis.size, y.axis.size,
305305
text_angle = text.angle, text_hjust = hjust,
@@ -308,4 +308,4 @@ colMin <- function(data) sapply(data, min, na.rm = TRUE)
308308
scale_y_continuous(paste0("Log", log_base, "-Fold Change"),
309309
limits = c(y.limdown, y.limup))
310310
plot
311-
}
311+
}

0 commit comments

Comments
 (0)