Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ Imports:
graphics,
methods,
statmod,
parallel
parallel,
rlang
Suggests:
BiocStyle,
knitr,
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions R/groupComparisonQCPlots.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) +
Expand Down Expand Up @@ -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) +
Expand Down Expand Up @@ -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)
}
}
1 change: 1 addition & 0 deletions R/msstats-package.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#' @import data.table
## usethis namespace: start
#' @importFrom Rcpp sourceCpp
#' @importFrom rlang .data
## usethis namespace: end
#' @useDynLib MSstats, .registration=TRUE
NULL
Expand Down
50 changes: 25 additions & 25 deletions R/utils_dataprocess_plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Bug: shape mapped to nonexistent column (censored) — use is_censored to match data prep.

You factorize input$is_censored above but map shape = .data$censored. Align the aesthetic to avoid empty shapes.

Apply:

-        geom_point(aes(x = .data$RUN, y = .data$newABUNDANCE, color = .data[[type_color]], shape = .data$censored),
+        geom_point(aes(x = .data$RUN, y = .data$newABUNDANCE, color = .data[[type_color]], shape = .data$is_censored),
                    data = input,
                    size = dot.size.profile) +
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
geom_point(aes(x = .data$RUN, y = .data$newABUNDANCE, color = .data[[type_color]], shape = .data$censored),
geom_point(aes(x = .data$RUN, y = .data$newABUNDANCE, color = .data[[type_color]], shape = .data$is_censored),
data = input,
size = dot.size.profile) +
🤖 Prompt for AI Agents
In R/utils_dataprocess_plots.R around line 66, the geom_point maps shape =
.data$censored which doesn't exist (the data uses is_censored); change the
aesthetic to shape = .data$is_censored so it references the factorized variable
from data prep (and update any corresponding scale_shape_* calls or legend
titles to use is_censored if present).

data = input,
size = dot.size.profile) +
scale_shape_manual(values = c(16, 1),
Expand Down Expand Up @@ -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") +
Expand Down Expand Up @@ -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),
Comment on lines +168 to 175
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Same shape/aesthetic mismatch here.

Map to is_censored in both point layers to match the available column.

Apply:

-            geom_point(data = input[input$PEPTIDE != "Run summary"], 
-                       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(x = .data$RUN, y = .data$newABUNDANCE, 
+                                  color = .data$analysis, size = .data$analysis, 
+                                  shape = .data$is_censored)) +
             geom_point(data = input[input$PEPTIDE == "Run summary"], 
-                       aes(x = .data$RUN, y = .data$newABUNDANCE, 
-                                  color = .data$analysis, size = .data$analysis, 
-                                  shape = .data$censored)) +
+                       aes(x = .data$RUN, y = .data$newABUNDANCE, 
+                                  color = .data$analysis, size = .data$analysis, 
+                                  shape = .data$is_censored)) +
🤖 Prompt for AI Agents
In R/utils_dataprocess_plots.R around lines 168 to 175, both geom_point layers
are mapping shape to .data$censored which doesn't exist; change the mapping to
.data$is_censored in both point layers (i.e., replace shape = .data$censored
with shape = .data$is_censored) and keep the existing scale_shape_manual so the
shape values align with the is_censored factor levels.

labels = c("Detected data",
"Censored missing data"))
Expand All @@ -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") +
Expand All @@ -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
}
Expand All @@ -234,17 +234,17 @@
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) +
scale_y_continuous(yaxis.name, limits = c(y.limdown, y.limup)) +
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)
Expand All @@ -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")

Expand All @@ -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
}
}
34 changes: 17 additions & 17 deletions R/utils_groupcomparison_plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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")
}
Expand All @@ -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, ")"))) +
Expand All @@ -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, ")"))) +
Expand Down Expand Up @@ -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") +
Expand All @@ -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,
Expand All @@ -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
}
}
Loading