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
54 changes: 29 additions & 25 deletions R/dataProcessPlots.R
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,10 @@ dataProcessPlots = function(
labels = seq(1, length(unique(RUN))))]
summarized[, RUN := as.numeric(RUN)]

## Meena :due to GROUP=0 for labeled.. extra care required.
tempGroupName = unique(processed[, c("GROUP", "RUN")])
if (length(unique(processed$LABEL)) == 2) {
tempGroupName = tempGroupName[GROUP != '0']
}
tempGroupName = tempGroupName[order(RUN), ] ## Meena : should we order by GROUP or RUN? I guess by RUn, because x-axis is by RUN
tempGroupName = tempGroupName[order(RUN), ]
level.group = as.character(unique(tempGroupName$GROUP))
tempGroupName$GROUP = factor(tempGroupName$GROUP,
levels = level.group) ## Meena : factor GROUP again, due to 1, 10, 2, ... if you have better way, please change
tempGroupName$GROUP = factor(tempGroupName$GROUP, levels = level.group)

groupAxis = as.numeric(xtabs(~GROUP, tempGroupName))
cumGroupAxis = cumsum(groupAxis)
Expand All @@ -291,16 +286,22 @@ dataProcessPlots = function(
Name = levels(tempGroupName$GROUP))


if (length(unique(processed$LABEL)) == 2) {
processed[, LABEL := factor(LABEL, labels = c("Reference", "Endogenous"))]
if ("is_labeled_ref" %in% colnames(processed)) {
processed[, LABEL := factor(
ifelse(is_labeled_ref, "Reference", "Endogenous"),
levels = c("Reference", "Endogenous")
)]
} else {
if (unique(processed$LABEL) == "L") {
label_levels = levels(factor(processed$LABEL))
if (length(label_levels) == 2) {
processed[, LABEL := factor(LABEL, labels = c("Heavy", "Light"))]
} else if ("L" %in% label_levels) {
processed[, LABEL := factor(LABEL, labels = c("Endogenous"))]
} else {
processed[, LABEL := factor(LABEL, labels = c("Reference"))]
processed[, LABEL := factor(LABEL, labels = c("Heavy"))]
}
}

if ("feature_quality" %in% colnames(processed)) {
processed[, feature_quality := NULL]
}
Expand Down Expand Up @@ -357,10 +358,11 @@ dataProcessPlots = function(
}

if (summaryPlot) {
protein_by_run = expand.grid(Protein = unique(summarized$Protein),
protein_by_run = expand.grid(Protein = unique(summarized$Protein),
RUN = unique(summarized$RUN))
summarized = merge(summarized, protein_by_run, by = c("Protein", "RUN"),
all.x = TRUE, all.y = TRUE)
summary_label = if ("Light" %in% levels(processed$LABEL)) "Light" else "Endogenous"
if(!isPlotly) {
savePlot(address, "ProfilePlot_wSummarization", width, height)
}
Expand All @@ -384,7 +386,7 @@ dataProcessPlots = function(
Protein == all_proteins[i],
list(PROTEIN = unique(Protein), PEPTIDE = "Run summary",
TRANSITION = "Run summary", FEATURE = "Run summary",
LABEL = "Endogenous", RUN = RUN,
LABEL = summary_label, RUN = RUN,
ABUNDANCE = LogIntensities, FRACTION = 1,
UPPERBOUND = if("Variance" %in% names(.SD)) LogIntensities + 1.96 * sqrt(Variance) else NA_real_, # 95% confidence interval
LOWERBOUND = if("Variance" %in% names(.SD)) LogIntensities - 1.96 * sqrt(Variance) else NA_real_
Expand Down Expand Up @@ -442,30 +444,32 @@ dataProcessPlots = function(
processed[, RUN := factor(RUN, levels = unique(processed$RUN),
labels = seq(1, data.table::uniqueN(processed$RUN)))]

if (length(unique(processed$LABEL)) == 2) {
processed[, LABEL := factor(LABEL, labels = c("Reference", "Endogenous"))]
if ("is_labeled_ref" %in% colnames(processed)) {
processed[, LABEL := factor(
ifelse(is_labeled_ref, "Reference", "Endogenous"),
levels = c("Reference", "Endogenous")
)]
label.color = c("darkseagreen1", "lightblue")
} else {
if (unique(processed$LABEL) == "L") {
label_levels = levels(factor(processed$LABEL))
if (length(label_levels) == 2) {
processed[, LABEL := factor(LABEL, labels = c("Heavy", "Light"))]
label.color = c("darkseagreen1", "lightblue")
} else if ("L" %in% label_levels) {
processed[, LABEL := factor(LABEL, labels = c("Endogenous"))]
label.color = c("lightblue")
} else {
processed[, LABEL := factor(LABEL, labels = c("Reference"))]
processed[, LABEL := factor(LABEL, labels = c("Heavy"))]
label.color = c("darkseagreen1")
}
}

processed = processed[order(LABEL, GROUP, SUBJECT)]

## Meena :due to GROUP=0 for labeled.. extra care required.
tempGroupName = unique(processed[, list(GROUP, RUN)])
if (length(unique(processed$LABEL)) == 2) {
tempGroupName = tempGroupName[GROUP != '0']
}
tempGroupName = tempGroupName[order(RUN), ] ## Meena : should we order by GROUP or RUN? I guess by RUn, because x-axis is by RUN
tempGroupName = tempGroupName[order(RUN), ]
level.group = as.character(unique(tempGroupName$GROUP))
tempGroupName$GROUP = factor(tempGroupName$GROUP,
levels = level.group) ## Meena : factor GROUP again, due to 1, 10, 2, ... if you have better way, please change
tempGroupName$GROUP = factor(tempGroupName$GROUP, levels = level.group)

groupAxis = as.numeric(xtabs(~GROUP, tempGroupName))
cumGroupAxis = cumsum(groupAxis)
Expand Down
4 changes: 2 additions & 2 deletions R/utils_checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ setMethod(".checkDataValidity", "MSstatsValidated", .prepareForDataProcess)
skip_absent = TRUE)

input[, FEATURE := paste(PEPTIDE, TRANSITION, sep = "_")]
input[, GROUP := ifelse(LABEL == "L", GROUP_ORIGINAL, "0")]
input[, SUBJECT := ifelse(LABEL == "L", SUBJECT_ORIGINAL, "0")]
input[, GROUP := GROUP_ORIGINAL]
input[, SUBJECT := SUBJECT_ORIGINAL]

cols = c("PROTEIN", "PEPTIDE", "TRANSITION", "FEATURE", "LABEL",
"GROUP_ORIGINAL", "SUBJECT_ORIGINAL", "RUN", "GROUP",
Expand Down
Binary file modified inst/tinytest/processed_data/quant_data_srm.rds
Binary file not shown.
Loading