diff --git a/DESCRIPTION b/DESCRIPTION index e53be39..74aab93 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -37,7 +37,8 @@ Imports: graphics, methods, statmod, - parallel + parallel, + rlang Suggests: BiocStyle, knitr, @@ -53,7 +54,7 @@ biocViews: ImmunoOncology, MassSpectrometry, Proteomics, Software, Normalization LazyData: true URL: http://msstats.org BugReports: https://groups.google.com/forum/#!forum/msstats -RoxygenNote: 7.3.2 +RoxygenNote: 7.3.3 Encoding: UTF-8 NeedsCompilation: no Packaged: 2017-10-20 02:13:12 UTC; meenachoi diff --git a/NAMESPACE b/NAMESPACE index e98c1a2..514752c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -106,6 +106,7 @@ importFrom(plotly,plot_ly) importFrom(plotly,style) importFrom(plotly,subplot) importFrom(preprocessCore,normalize.quantiles) +importFrom(rlang,.data) importFrom(stats,dist) importFrom(stats,fitted) importFrom(stats,formula) diff --git a/R/groupComparisonQCPlots.R b/R/groupComparisonQCPlots.R index 9934e98..45cbcf8 100644 --- a/R/groupComparisonQCPlots.R +++ b/R/groupComparisonQCPlots.R @@ -121,7 +121,7 @@ modelBasedQCPlots = function( slope = diff(y) / diff(x) int = y[1L] - slope * x[1L] - plot = ggplot(sub.residuals.table, aes(sample = residual)) + + plot = ggplot(sub.residuals.table, aes(sample = .data$residual)) + geom_point(stat = "qq", alpha = 0.8, shape = 20, size = dot.size) + scale_shape(solid=FALSE) + @@ -172,7 +172,7 @@ modelBasedQCPlots = function( sub.residuals.table = data.frame("residual" = sub.residuals, "fitted" = sub.fitted) - plot = ggplot(aes_string(x = "fitted", y = "residual"), + plot = ggplot(aes(x = .data$fitted, y = .data$residual), data = sub.residuals.table) + geom_point(size = dot.size, alpha = 0.5) + @@ -263,4 +263,4 @@ groupComparisonQCPlots = function(data, type, axis.size = 10, dot.size = 3, widt modelBasedQCPlots(data, type, axis.size, dot.size, width, height, which.Protein, address, FALSE) -} +} \ No newline at end of file diff --git a/R/msstats-package.R b/R/msstats-package.R index 4092079..bafb327 100644 --- a/R/msstats-package.R +++ b/R/msstats-package.R @@ -1,6 +1,7 @@ #' @import data.table ## usethis namespace: start #' @importFrom Rcpp sourceCpp +#' @importFrom rlang .data ## usethis namespace: end #' @useDynLib MSstats, .registration=TRUE NULL diff --git a/R/utils_dataprocess_plots.R b/R/utils_dataprocess_plots.R index 17d8f9f..d2ecd72 100644 --- a/R/utils_dataprocess_plots.R +++ b/R/utils_dataprocess_plots.R @@ -56,14 +56,14 @@ type_color = "PEPTIDE" } - profile_plot = ggplot(input, aes_string(x = "RUN", y = "newABUNDANCE", - color = type_color, linetype = "FEATURE")) + + profile_plot = ggplot(data = input, aes(x = .data$RUN, y = .data$newABUNDANCE, + color = .data[[type_color]], linetype = .data$FEATURE)) + facet_grid(~LABEL) + - geom_line(size = 0.5) + geom_line(linewidth = 0.5) if (is_censored) { profile_plot = profile_plot + - geom_point(aes_string(x = "RUN", y = "newABUNDANCE", color = type_color, shape = "censored"), + geom_point(aes(x = .data$RUN, y = .data$newABUNDANCE, color = .data[[type_color]], shape = .data$censored), data = input, size = dot.size.profile) + scale_shape_manual(values = c(16, 1), @@ -97,7 +97,7 @@ scale_y_continuous(yaxis.name, limits = c(y.limdown, y.limup)) + geom_vline(xintercept = lineNameAxis + 0.5, colour = "grey", linetype = "longdash") + labs(title = unique(input$PROTEIN)) + - geom_text(data = groupNametemp, aes(x = RUN, y = ABUNDANCE, label = Name), + geom_text(data = groupNametemp, aes(x = .data$RUN, y = .data$ABUNDANCE, label = .data$Name), size = text.size, angle = text.angle, color = "black") + @@ -156,22 +156,22 @@ num_features = data.table::uniqueN(input$FEATURE) profile_plot = ggplot(data = input, - aes_string(x = "RUN", y = "newABUNDANCE", - color = "analysis", linetype = "FEATURE", - size = "analysis")) + + aes(x = .data$RUN, y = .data$newABUNDANCE, + color = .data$analysis, linetype = .data$FEATURE, + size = .data$analysis)) + facet_grid(~LABEL) + - geom_line(size = 0.5) + geom_line(linewidth = 0.5) if (is_censored) { # splitting into two layers to keep red above grey profile_plot = profile_plot + geom_point(data = input[input$PEPTIDE != "Run summary"], - aes_string(x = "RUN", y = "newABUNDANCE", - color = "analysis", size = "analysis", - shape = "censored")) + + aes(x = .data$RUN, y = .data$newABUNDANCE, + color = .data$analysis, size = .data$analysis, + shape = .data$censored)) + geom_point(data = input[input$PEPTIDE == "Run summary"], - aes_string(x = "RUN", y = "newABUNDANCE", - color = "analysis", size = "analysis", - shape = "censored")) + + aes(x = .data$RUN, y = .data$newABUNDANCE, + color = .data$analysis, size = .data$analysis, + shape = .data$censored)) + scale_shape_manual(values = c(16, 1), labels = c("Detected data", "Censored missing data")) @@ -191,7 +191,7 @@ geom_vline(xintercept = lineNameAxis + 0.5, colour = "grey", linetype = "longdash") + labs(title = unique(input$PROTEIN)) + - geom_text(data = groupNametemp, aes(x = RUN, y = ABUNDANCE, label = Name), + geom_text(data = groupNametemp, aes(x = .data$RUN, y = .data$ABUNDANCE, label = .data$Name), size = text.size, angle = text.angle, color = "black") + @@ -209,8 +209,8 @@ } else { profile_plot = profile_plot + guides(color = color_guide) + - geom_point(aes_string(x = "RUN", y = "newABUNDANCE", size = "analysis", - color = "analysis"), data = input) + geom_point(aes(x = .data$RUN, y = .data$newABUNDANCE, size = .data$analysis, + color = .data$analysis), data = input) } profile_plot } @@ -234,9 +234,9 @@ plot_title = unique(input$PROTEIN) } - ggplot(input, aes_string(x = "RUN", y = "ABUNDANCE")) + + ggplot(input, aes(x = .data$RUN, y = .data$ABUNDANCE)) + facet_grid(~LABEL) + - geom_boxplot(aes_string(fill = "LABEL"), outlier.shape = 1, + geom_boxplot(aes(fill = .data$LABEL), outlier.shape = 1, outlier.size = 1.5) + scale_fill_manual(values = label.color, guide = "none") + scale_x_discrete("MS runs", breaks = cumGroupAxis) + @@ -244,7 +244,7 @@ geom_vline(xintercept = lineNameAxis + 0.5, colour = "grey", linetype = "longdash") + labs(title = plot_title) + - geom_text(data = groupName, aes(x = RUN, y = ABUNDANCE, label = Name), + geom_text(data = groupName, aes(x = .data$RUN, y = .data$ABUNDANCE, label = .data$Name), size = text.size, angle = text.angle, color = "black") + theme_msstats("QCPLOT", x.axis.size, y.axis.size, legend_size = NULL) @@ -268,8 +268,8 @@ input$Label = as.numeric(gsub("\\D", "", unique(input$Label))) } - plot = ggplot(aes_string(x = "Label", y = "Mean"), data = input) + - geom_errorbar(aes(ymax = Mean + ciw, ymin = Mean - ciw), + plot = ggplot(aes(x = .data$Label, y = .data$Mean), data = input) + + geom_errorbar(aes(ymax = .data$Mean + .data$ciw, ymin = .data$Mean - .data$ciw), data = input, width = 0.1, colour = "red") + geom_point(size = dot.size.condition, colour = "darkred") @@ -283,9 +283,9 @@ plot = plot + scale_y_continuous(yaxis.name, limits = c(y.limdown, y.limup)) + geom_hline(yintercept = 0, linetype = "twodash", - colour = "darkgrey", size = 0.6) + + colour = "darkgrey", linewidth = 0.6) + labs(title = unique(single_protein$PROTEIN)) + theme_msstats("CONDITIONPLOT", x.axis.size, y.axis.size, text_angle = text.angle) plot -} +} \ No newline at end of file diff --git a/R/utils_groupcomparison_plots.R b/R/utils_groupcomparison_plots.R index e6040fc..d69424a 100644 --- a/R/utils_groupcomparison_plots.R +++ b/R/utils_groupcomparison_plots.R @@ -189,10 +189,10 @@ colMin <- function(data) sapply(data, min, na.rm = TRUE) legend.size, log_adjp ) { Protein = NULL - plot = ggplot(aes_string(x = "logFC", - y = log_adjp, - color = "colgroup", - label = "Protein"), + plot = ggplot(aes(x = .data$logFC, + y = .data[[log_adjp]], + color = .data$colgroup, + label = .data$Protein), data = input) + geom_point(size = dot.size) + scale_colour_manual(values = c("gray65", "blue", "red"), @@ -209,7 +209,7 @@ colMin <- function(data) sapply(data, min, na.rm = TRUE) if (!(length(unique(input$colgroup)) == 1 & any(unique(input$colgroup) == "black"))) { plot = plot + geom_text_repel(data = input[input$colgroup != "black", ], - aes(label = Protein), + aes(label = .data$Protein), size = text.size, col = "black") } @@ -226,9 +226,9 @@ colMin <- function(data) sapply(data, min, na.rm = TRUE) if (!FCcutoff) { plot = plot + geom_line(data = sigcut, - aes_string(x = "logFC", y = log_adjp, linetype = "line"), + aes(x = .data$logFC, y = .data[[log_adjp]], linetype = .data$line), colour = "darkgrey", - size = 0.6, + linewidth = 0.6, show.legend = TRUE) + scale_linetype_manual(values = c("twodash" = 6), labels = c(paste0("Adj p-value cutoff (", sig, ")"))) + @@ -248,19 +248,19 @@ colMin <- function(data) sapply(data, min, na.rm = TRUE) c("Protein", "logFC", log_adjp, "line")) plot = plot + geom_line(data = sigcut, - aes_string(x = "logFC", y = log_adjp, linetype = "line"), + aes(x = .data$logFC, y = .data[[log_adjp]], linetype = .data$line), colour = "darkgrey", - size = 0.6, + linewidth = 0.6, show.legend = TRUE) + geom_line(data = FCcutpos, - aes_string(x = "logFC", y = log_adjp, linetype = "line"), + aes(x = .data$logFC, y = .data[[log_adjp]], linetype = .data$line), colour = "darkgrey", - size = 0.6, + linewidth = 0.6, show.legend = TRUE) + geom_line(data = FCcutneg, - aes_string(x = "logFC", y = log_adjp, linetype = "line"), + aes(x = .data$logFC, y = .data[[log_adjp]], linetype = .data$line), colour = "darkgrey", - size = 0.6) + + linewidth = 0.6) + scale_linetype_manual(values = c("dotted" = 3, "twodash" = 6), labels = c(paste0("Fold change cutoff (", FCcutoff, ")"), paste0("Adj p-value cutoff (", sig, ")"))) + @@ -288,8 +288,8 @@ colMin <- function(data) sapply(data, min, na.rm = TRUE) logFC = ciw = NULL protein = unique(input$Protein) - plot = ggplot(input, aes_string(x = "Label", y = "logFC")) + - geom_errorbar(aes(ymax = logFC + ciw, ymin = logFC - ciw), + plot = ggplot(input, aes(x = .data$Label, y = .data$logFC)) + + geom_errorbar(aes(ymax = .data$logFC + .data$ciw, ymin = .data$logFC - .data$ciw), data = input, width = 0.1, colour = "red") + @@ -299,7 +299,7 @@ colMin <- function(data) sapply(data, min, na.rm = TRUE) geom_hline(yintercept = 0, linetype = "twodash", colour = "darkgrey", - size = 0.6) + + linewidth = 0.6) + labs(title = protein) + theme_msstats("COMPARISONPLOT", x.axis.size, y.axis.size, text_angle = text.angle, text_hjust = hjust, @@ -308,4 +308,4 @@ colMin <- function(data) sapply(data, min, na.rm = TRUE) scale_y_continuous(paste0("Log", log_base, "-Fold Change"), limits = c(y.limdown, y.limup)) plot -} +} \ No newline at end of file