Skip to content
Open
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
10 changes: 6 additions & 4 deletions R/dataProcessPlotsPTM.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
#' log intensities across MS runs.
#' "QCPlot" represents box plots of log intensities across channels and MS runs.
#' @param ylimUp upper limit for y-axis in the log scale.
#' FALSE(Default) for Profile Plot and QC Plot uses the upper limit as rounded
#' off maximum of log2(intensities) after normalization + 3..
#' FALSE(Default) for Profile Plot uses the maximum log2 intensity of the
#' protein of interest + 5 per plot; for QC Plot uses the maximum across all
#' proteins + 3.
#' @param ylimDown lower limit for y-axis in the log scale. FALSE(Default) for
#' Profile Plot and QC Plot uses the lower limit as floor of minimum
#' log2(intensities) after normalization - 3, or 0 if that value is negative.
#' Profile Plot uses the floor of the minimum log2 intensity of the protein of
#' interest - 3 (minimum 0) per plot; for QC Plot uses the floor of the minimum
#' across all proteins - 3, or 0 if that value is negative.
#' @param x.axis.size size of x-axis labeling for "Run" and "channel in Profile
#' Plot and QC Plot.
#' @param y.axis.size size of y-axis labels. Default is 10.
Expand Down
142 changes: 101 additions & 41 deletions R/utils_dataProcessPlots.R
Original file line number Diff line number Diff line change
Expand Up @@ -606,20 +606,36 @@
}

## factoring for run, channel, condition should be done before loop

for (i in seq_len(nrow(plot_proteins))) {

ptm_temp = .plot.profile.tmt(ptm.list,
as.character(plot_proteins[, PROTEINNAME][i]),
ptm_name = as.character(plot_proteins[, PROTEINNAME][i])
ptm_abund = datafeature.ptm[datafeature.ptm$PROTEINNAME == ptm_name, ]$ABUNDANCE
if (plot_global) {
protein_name = as.character(plot_proteins[, GLOBALPROTEIN][i])
protein_abund = datafeature.protein[datafeature.protein$PROTEINNAME == protein_name, ]$ABUNDANCE
all_abund = c(ptm_abund, protein_abund)
} else {
all_abund = ptm_abund
}
if (!is.numeric(ylimUp)) y.limup = ceiling(max(all_abund, na.rm = TRUE) + 5)
if (!is.numeric(ylimDown)) y.limdown = max(floor(min(all_abund, na.rm = TRUE) - 3), 0)
cur_ptm.list = ptm.list
cur_ptm.list[[3]]$abundance = y.limup - 0.5
cur_ptm.list[[4]]$abundance = y.limup - 0.5

ptm_temp = .plot.profile.tmt(cur_ptm.list,
ptm_name,
y.limup, y.limdown, x.axis.size,
y.axis.size, text.size, text.angle, legend.size,
dot.size.profile, ncol.guide)
if (plot_global){
protein_temp = .plot.profile.tmt(protein.list,
as.character(
plot_proteins[, GLOBALPROTEIN][i]),
cur_protein.list = protein.list
cur_protein.list[[3]]$abundance = y.limup - 0.5
cur_protein.list[[4]]$abundance = y.limup - 0.5
protein_temp = .plot.profile.tmt(cur_protein.list,
protein_name,
y.limup, y.limdown, x.axis.size,
y.axis.size, text.size, text.angle,
y.axis.size, text.size, text.angle,
legend.size, dot.size.profile, ncol.guide)
original_profile_plots <- list(PTEMP.PTM = ptm_temp, PTEMP.PROTEIN = protein_temp)
grid.arrange(ptm_temp, protein_temp, ncol=1)
Expand All @@ -628,8 +644,8 @@
print(ptm_temp)
}
output_plots[["original_plot"]][[paste("plot",i)]] <- original_profile_plots
message(paste0("Drew the Profile plot for ",
as.character(plot_proteins[, PROTEINNAME][i]),
message(paste0("Drew the Profile plot for ",
ptm_name,
" (", i, " of ", nrow(plot_proteins), ")"))
}
# end-loop for each protein
Expand Down Expand Up @@ -661,14 +677,31 @@
}

for (i in seq_len(nrow(plot_proteins))) {

ptm_temp = .plot.profile.summary.tmt(ptm.list, as.character(
plot_proteins[, PROTEINNAME][i]), y.limup, y.limdown, x.axis.size,
y.axis.size, text.size, text.angle, legend.size,dot.size.profile,
ptm_name = as.character(plot_proteins[, PROTEINNAME][i])
ptm_abund = datafeature.ptm[datafeature.ptm$PROTEINNAME == ptm_name, ]$ABUNDANCE
if (plot_global) {
protein_name = as.character(plot_proteins[, GLOBALPROTEIN][i])
protein_abund = datafeature.protein[datafeature.protein$PROTEINNAME == protein_name, ]$ABUNDANCE
all_abund = c(ptm_abund, protein_abund)
} else {
all_abund = ptm_abund
}
if (!is.numeric(ylimUp)) y.limup = ceiling(max(all_abund, na.rm = TRUE) + 5)
if (!is.numeric(ylimDown)) y.limdown = max(floor(min(all_abund, na.rm = TRUE) - 3), 0)
cur_ptm.list = ptm.list
cur_ptm.list[[3]]$abundance = y.limup - 0.5
cur_ptm.list[[4]]$abundance = y.limup - 0.5

ptm_temp = .plot.profile.summary.tmt(cur_ptm.list, ptm_name,
y.limup, y.limdown, x.axis.size,
y.axis.size, text.size, text.angle, legend.size, dot.size.profile,
ncol.guide)
if (plot_global){
protein_temp = .plot.profile.summary.tmt(protein.list, as.character(
plot_proteins[, GLOBALPROTEIN][i]), y.limup, y.limdown, x.axis.size,
cur_protein.list = protein.list
cur_protein.list[[3]]$abundance = y.limup - 0.5
cur_protein.list[[4]]$abundance = y.limup - 0.5
protein_temp = .plot.profile.summary.tmt(cur_protein.list, protein_name,
y.limup, y.limdown, x.axis.size,
y.axis.size, text.size, text.angle, legend.size,
dot.size.profile, ncol.guide)
summary_profile_plots <- list(PTEMP.PTM = ptm_temp, PTEMP.PROTEIN = protein_temp)
Expand All @@ -678,10 +711,9 @@
print(ptm_temp)
}
output_plots[["summary_plot"]][[paste("plot",i)]] <- summary_profile_plots
message(paste("Drew the Profile plot for ",
as.character(plot_proteins[, PROTEINNAME][i]),
message(paste("Drew the Profile plot for ",
ptm_name,
"(", i, " of ", nrow(plot_proteins), ")"))

}

if (address!=FALSE & !isPlotly) {
Expand Down Expand Up @@ -1430,20 +1462,33 @@
## factoring for run, channel, condition should be done before loop

for (i in seq_len(nrow(plot_proteins))) {

ptm_temp = .plot.profile.lf(ptm.list,
as.character(
plot_proteins[, PROTEINNAME][i]),
ptm_name = as.character(plot_proteins[, PROTEINNAME][i])
ptm_abund = datafeature.ptm[datafeature.ptm$PROTEINNAME == ptm_name, ]$ABUNDANCE
if (plot_global) {
protein_name = as.character(plot_proteins[, GLOBALPROTEIN][i])
protein_abund = datafeature.protein[datafeature.protein$PROTEINNAME == protein_name, ]$ABUNDANCE
all_abund = c(ptm_abund, protein_abund)
} else {
all_abund = ptm_abund
}
if (!is.numeric(ylimUp)) y.limup = ceiling(max(all_abund, na.rm = TRUE) + 5)
if (!is.numeric(ylimDown)) y.limdown = max(floor(min(all_abund, na.rm = TRUE) - 3), 0)
cur_ptm.list = ptm.list
cur_ptm.list[[3]]$ABUNDANCE = y.limup - 1

ptm_temp = .plot.profile.lf(cur_ptm.list,
ptm_name,
y.limup, y.limdown, x.axis.size,
y.axis.size, text.size, text.angle,
y.axis.size, text.size, text.angle,
legend.size, dot.size.profile, ncol.guide)
if (plot_global) {
protein_temp = .plot.profile.lf(protein.list,
as.character(
plot_proteins[, GLOBALPROTEIN][i]),
cur_protein.list = protein.list
cur_protein.list[[3]]$ABUNDANCE = y.limup - 1
protein_temp = .plot.profile.lf(cur_protein.list,
protein_name,
y.limup, y.limdown, x.axis.size,
y.axis.size, text.size, text.angle,
legend.size, dot.size.profile,
y.axis.size, text.size, text.angle,
legend.size, dot.size.profile,
ncol.guide)
original_profile_plots <- list(PTEMP.PTM = ptm_temp, PTEMP.PROTEIN = protein_temp)
grid.arrange(ptm_temp, protein_temp, ncol=1)
Expand All @@ -1452,8 +1497,8 @@
print(ptm_temp)
}
output_plots[["original_plot"]][[paste("plot",i)]] <- original_profile_plots
message(paste0("Drew the Profile plot for ",
as.character(plot_proteins[, PROTEINNAME][i]),
message(paste0("Drew the Profile plot for ",
ptm_name,
" (", i, " of ", nrow(plot_proteins), ")"))
}
# end-loop for each protein
Expand Down Expand Up @@ -1485,16 +1530,31 @@
}

for (i in seq_len(nrow(plot_proteins))) {

ptm_temp = .plot.profile.summary.lf(ptm.list, as.character(
plot_proteins[, PROTEINNAME][i]), y.limup, y.limdown, x.axis.size,
y.axis.size, text.size, text.angle, legend.size,dot.size.profile,
ptm_name = as.character(plot_proteins[, PROTEINNAME][i])
ptm_abund = datafeature.ptm[datafeature.ptm$PROTEINNAME == ptm_name, ]$ABUNDANCE
if (plot_global) {
protein_name = as.character(plot_proteins[, GLOBALPROTEIN][i])
protein_abund = datafeature.protein[datafeature.protein$PROTEINNAME == protein_name, ]$ABUNDANCE
all_abund = c(ptm_abund, protein_abund)
} else {
all_abund = ptm_abund
}
if (!is.numeric(ylimUp)) y.limup = ceiling(max(all_abund, na.rm = TRUE) + 5)
if (!is.numeric(ylimDown)) y.limdown = max(floor(min(all_abund, na.rm = TRUE) - 3), 0)
cur_ptm.list = ptm.list
cur_ptm.list[[3]]$ABUNDANCE = y.limup - 1

ptm_temp = .plot.profile.summary.lf(cur_ptm.list, ptm_name,
y.limup, y.limdown, x.axis.size,
y.axis.size, text.size, text.angle, legend.size, dot.size.profile,
ncol.guide)

if (plot_global){
protein_temp = .plot.profile.summary.lf(protein.list, as.character(
plot_proteins[, GLOBALPROTEIN][i]), y.limup, y.limdown, x.axis.size,
y.axis.size, text.size, text.angle, legend.size, dot.size.profile,
cur_protein.list = protein.list
cur_protein.list[[3]]$ABUNDANCE = y.limup - 1
protein_temp = .plot.profile.summary.lf(cur_protein.list, protein_name,
y.limup, y.limdown, x.axis.size,
y.axis.size, text.size, text.angle, legend.size, dot.size.profile,
ncol.guide)
summary_profile_plots <- list(PTEMP.PTM = ptm_temp, PTEMP.PROTEIN = protein_temp)
grid.arrange(ptm_temp, protein_temp, ncol=1)
Expand All @@ -1503,8 +1563,8 @@
print(ptm_temp)
}
output_plots[["summary_plot"]][[paste("plot",i)]] <- summary_profile_plots
message(paste("Drew the Profile plot for ",
as.character(plot_proteins[, PROTEINNAME][i]),
message(paste("Drew the Profile plot for ",
ptm_name,
"(", i, " of ", nrow(plot_proteins), ")"))
}
if (address!=FALSE & !isPlotly) {
Expand Down
Loading