-
Notifications
You must be signed in to change notification settings - Fork 52
Removed deep-copy data.table ops from the dataProcess pipeline #208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devel
Are you sure you want to change the base?
Changes from all commits
16edbd5
b64b004
e2bd771
65df2b5
0764b34
27d5f7c
50a30da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -170,7 +170,7 @@ MSstatsPrepareForDataProcess = function(input, log_base, fix_missing) { | |
| input = data.table::as.data.table(unclass(input)) | ||
|
|
||
| if (!"AnomalyScores" %in% colnames(input)){ | ||
| input$AnomalyScores = NA | ||
| data.table::set(input, j = "AnomalyScores", value = NA) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use Using plain After column names are uppercased at line 198, the check at line 317 will find the column already exists and skip the Proposed fix- data.table::set(input, j = "AnomalyScores", value = NA)
+ data.table::set(input, j = "AnomalyScores", value = NA_real_)🤖 Prompt for AI Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NA_real_ is a good call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
- data.table::set(input, j = "AnomalyScores", value = NA)
+ data.table::set(input, j = "AnomalyScores", value = NA_real_)This ensures type consistency throughout the pipeline — the column stays numeric from the start, avoiding any silent logical→numeric coercion later when (ノ◕ヮ◕)ノ*:・゚✧ |
||
| } | ||
|
|
||
| cols = c("ProteinName", "PeptideSequence", "PeptideModifiedSequence", | ||
|
|
@@ -200,7 +200,8 @@ MSstatsPrepareForDataProcess = function(input, log_base, fix_missing) { | |
|
|
||
| if (!is.numeric(input$INTENSITY)) { | ||
| suppressWarnings({ | ||
| input$INTENSITY = as.numeric(as.character(input$INTENSITY)) | ||
| data.table::set(input, j = "INTENSITY", | ||
| value = as.numeric(as.character(input$INTENSITY))) | ||
| }) | ||
| } | ||
|
|
||
|
|
@@ -211,12 +212,15 @@ MSstatsPrepareForDataProcess = function(input, log_base, fix_missing) { | |
| cols = toupper(cols) | ||
| cols = intersect(c(cols, "FRACTION", "TECHREPLICATE"), | ||
| colnames(input)) | ||
| input = input[, cols, with = FALSE] | ||
|
|
||
| input$PEPTIDE = paste(input$PEPTIDESEQUENCE, | ||
| input$PRECURSORCHARGE, sep = "_") | ||
| input$TRANSITION = paste(input$FRAGMENTION, | ||
| input$PRODUCTCHARGE, sep = "_") | ||
| drop_cols = setdiff(colnames(input), cols) | ||
| for (col in drop_cols) data.table::set(input, j = col, value = NULL) | ||
|
|
||
| data.table::set(input, j = "PEPTIDE", | ||
| value = paste(input$PEPTIDESEQUENCE, | ||
| input$PRECURSORCHARGE, sep = "_")) | ||
| data.table::set(input, j = "TRANSITION", | ||
| value = paste(input$FRAGMENTION, | ||
| input$PRODUCTCHARGE, sep = "_")) | ||
|
|
||
| if (data.table::uniqueN(input$ISOTOPELABELTYPE) > 2) { | ||
| getOption("MSstatsLog")( | ||
|
|
@@ -226,7 +230,8 @@ MSstatsPrepareForDataProcess = function(input, log_base, fix_missing) { | |
| stop("Statistical tools in MSstats are only proper for label-free or with reference peptide experiments.") | ||
| } | ||
|
|
||
| input$ISOTOPELABELTYPE <- .mapIsotopeLabelType(input$ISOTOPELABELTYPE) | ||
| data.table::set(input, j = "ISOTOPELABELTYPE", | ||
| value = .mapIsotopeLabelType(input$ISOTOPELABELTYPE)) | ||
| input | ||
| } | ||
|
|
||
|
|
@@ -242,9 +247,14 @@ MSstatsPrepareForDataProcess = function(input, log_base, fix_missing) { | |
| data.table::setnames( | ||
| input, "PEPTIDEMODIFIEDSEQUENCE", "PEPTIDESEQUENCE") | ||
| } | ||
| input$PEPTIDE = paste(input$PEPTIDESEQUENCE, input$PRECURSORCHARGE, sep = "_") | ||
| input$TRANSITION = paste(input$FRAGMENTION, input$PRODUCTCHARGE, sep = "_") | ||
| input$ISOTOPELABELTYPE <- .mapIsotopeLabelType(input$ISOTOPELABELTYPE) | ||
| data.table::set(input, j = "PEPTIDE", | ||
| value = paste(input$PEPTIDESEQUENCE, | ||
| input$PRECURSORCHARGE, sep = "_")) | ||
| data.table::set(input, j = "TRANSITION", | ||
| value = paste(input$FRAGMENTION, | ||
| input$PRODUCTCHARGE, sep = "_")) | ||
| data.table::set(input, j = "ISOTOPELABELTYPE", | ||
| value = .mapIsotopeLabelType(input$ISOTOPELABELTYPE)) | ||
| input | ||
| } | ||
|
|
||
|
|
@@ -322,8 +332,8 @@ setMethod(".checkDataValidity", "MSstatsValidated", .prepareForDataProcess) | |
| input[, PROTEIN := factor(PROTEIN)] | ||
| input[, PEPTIDE := factor(PEPTIDE)] | ||
| input[, TRANSITION := factor(TRANSITION)] | ||
| input = input[order(LABEL, GROUP_ORIGINAL, SUBJECT_ORIGINAL, | ||
| RUN, PROTEIN, PEPTIDE, TRANSITION), ] | ||
| data.table::setorder(input, LABEL, GROUP_ORIGINAL, SUBJECT_ORIGINAL, | ||
| RUN, PROTEIN, PEPTIDE, TRANSITION) | ||
| input[, GROUP := factor(GROUP)] | ||
| input[, SUBJECT := factor(SUBJECT)] | ||
| input[, FEATURE := factor(FEATURE)] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,28 +74,22 @@ MSstatsSelectFeatures = function(input, method, top_n = 3, min_feature_count = 2 | |
| #' @return data.table | ||
| #' @keywords internal | ||
| .selectHighQualityFeatures = function(input, min_feature_count) { | ||
| PROTEIN = PEPTIDE = FEATURE = originalRUN = ABUNDANCE = is_censored = NULL | ||
| is_obs = log2inty = LABEL = NULL | ||
|
|
||
| cols = c("PROTEIN", "PEPTIDE", "FEATURE", "originalRUN", "LABEL", | ||
| "ABUNDANCE", "censored") | ||
| cols = intersect(cols, colnames(input)) | ||
| input = input[, cols, with = FALSE] | ||
| if (!("censored" %in% cols)) { | ||
| input$censored = FALSE | ||
| } | ||
| data.table::setnames(input, "censored", "is_censored") | ||
| PROTEIN = PEPTIDE = FEATURE = originalRUN = ABUNDANCE = censored = NULL | ||
| is_obs = log2inty = is_censored = LABEL = NULL | ||
|
|
||
| has_censored = is.element("censored", colnames(input)) | ||
| input = input[, list(protein = as.character(PROTEIN), | ||
| peptide = as.character(PEPTIDE), | ||
| feature = as.character(FEATURE), | ||
| run = as.character(originalRUN), | ||
| label = as.character(LABEL), | ||
| log2inty = ifelse(!(is.na(ABUNDANCE) | is_censored), | ||
| ABUNDANCE, NA), | ||
| is_censored)] | ||
| input[, is_obs := !(is.na(log2inty) | is_censored)] | ||
| log2inty = ABUNDANCE, | ||
| is_censored = if (has_censored) censored else FALSE)] | ||
| # Censored or missing intensities are not observations. | ||
| input[is_censored | is.na(log2inty), log2inty := NA] | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be |
||
| input[, is_obs := !is.na(log2inty)] | ||
| input[, is_censored := NULL] | ||
|
|
||
| features_quality = data.table::rbindlist(lapply(split(input, input$label), | ||
| .flagUninformativeSingleLabel, | ||
| min_feature_count = min_feature_count)) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.