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
19 changes: 11 additions & 8 deletions R/clean_DIANN.R
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,11 @@
#'
#' \strong{ModifiedSequence-parsing path} (\code{has_channel = FALSE}):
#' \code{PeptideSequence} (the retained \code{ModifiedSequence}) is matched
#' against SILAC suffixes of the form \code{(SILAC-<AA>-H)} or
#' \code{(SILAC-<AA>-L)}, where \code{<AA>} is any code in
#' \code{labeledAminoAcids}. Sequences carrying neither suffix receive
#' \code{IsotopeLabelType = NA}. The SILAC suffix is stripped from
#' against label suffixes of the form \code{(<label>-<AA>-H)} or
#' \code{(<label>-<AA>-L)}, where \code{<AA>} is any code in
#' \code{labeledAminoAcids} and \code{<label>} is any non-dash token (e.g.
#' \code{SILAC} or \code{label}). Sequences carrying neither suffix receive
#' \code{IsotopeLabelType = NA}. The label suffix is stripped from
#' \code{PeptideSequence} after classification.
#'
#' @param dn_input \code{data.table} after column renaming.
Expand Down Expand Up @@ -265,9 +266,11 @@
dn_input[, Channel := NULL]
} else {
aa_pattern <- paste0(labeledAminoAcids, collapse = "|")
heavy_regex <- paste0("\\(SILAC-(?:", aa_pattern, ")-H\\)")
light_regex <- paste0("\\(SILAC-(?:", aa_pattern, ")-L\\)")
strip_regex <- paste0("\\(SILAC-(?:", aa_pattern, ")-[HL]\\)")
# The label token after the first parenthesis is not always "SILAC"
# (e.g. "(SILAC-L-L)" vs "(label-L-L)"), so match any non-dash token there.
heavy_regex <- paste0("\\([^-]+-(?:", aa_pattern, ")-H\\)")
light_regex <- paste0("\\([^-]+-(?:", aa_pattern, ")-L\\)")
strip_regex <- paste0("\\([^-]+-(?:", aa_pattern, ")-[HL]\\)")

dn_input <- .classifyIsotopeLabelType(dn_input, heavy_regex, light_regex)
dn_input[, PeptideSequence := gsub(strip_regex, "", PeptideSequence, perl = TRUE)]
Expand All @@ -276,7 +279,7 @@
if (all(is.na(dn_input[["IsotopeLabelType"]]))) {
warning("labeledAminoAcids was provided but no rows were classified as H or L. ",
"Check that the input contains either a Channel column with H/L values ",
"or ModifiedSequence entries with (SILAC-<AA>-H)/(SILAC-<AA>-L) suffixes.")
"or ModifiedSequence entries with (<label>-<AA>-H)/(<label>-<AA>-L) suffixes.")
}

dn_input
Expand Down
12 changes: 7 additions & 5 deletions R/converters_DIANNtoMSstatsFormat.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@
#' \strong{ModifiedSequence-parsing path} (DIA-NN 1.x exports without a
#' \code{Channel} column): when \code{labeledAminoAcids} is non-\code{NULL}
#' and no \code{Channel} column is present, each \code{ModifiedSequence} is
#' inspected for SILAC suffixes of the form \code{(SILAC-<AA>-H)} or
#' \code{(SILAC-<AA>-L)}, where \code{<AA>} is one of the supplied amino acid
#' codes. Matching sequences are classified as \code{"H"} or \code{"L"};
#' sequences carrying neither suffix receive \code{IsotopeLabelType = NA}.
#' The SILAC suffix is then stripped from \code{PeptideSequence}.
#' inspected for label suffixes of the form \code{(<label>-<AA>-H)} or
#' \code{(<label>-<AA>-L)}, where \code{<AA>} is one of the supplied amino acid
#' codes and \code{<label>} is any non-dash token (e.g. \code{SILAC} or
#' \code{label}). Matching sequences are classified as \code{"H"} or
#' \code{"L"}; sequences carrying neither suffix receive
#' \code{IsotopeLabelType = NA}. The label suffix is then stripped from
#' \code{PeptideSequence}.
#'
#' When \code{NULL} (default), protein-turnover mode is disabled and all
#' peptides receive \code{IsotopeLabelType = "Light"}.
Expand Down
15 changes: 15 additions & 0 deletions inst/tinytest/test_clean_DIANN.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,18 @@ result_null = MSstatsConvert:::.assignDIANNIsotopeLabelType(
)
expect_false("IsotopeLabelType" %in% colnames(result_null))
expect_equal(nrow(result_null), 2L)

# ModifiedSequence-parsing path: classification and stripping are agnostic to
# the label token after the first parenthesis. The suffix may be (SILAC-<AA>-H)
# or any (<label>-<AA>-H), e.g. (label-K-H).
dt_label = data.table::data.table(
PeptideSequence = c("PEPTIDEK(SILAC-K-H)", "PEPTIDEK(SILAC-K-L)",
"PEPTIDEK(label-K-H)", "PEPTIDEK(label-K-L)",
"PEPTIDEK")
)
result_label = MSstatsConvert:::.assignDIANNIsotopeLabelType(
dt_label, labeledAminoAcids = c("K"), has_channel = FALSE
)
expect_equal(result_label$IsotopeLabelType, c("H", "L", "H", "L", NA_character_))
# Suffix is stripped regardless of the label token
expect_equal(unique(result_label$PeptideSequence), "PEPTIDEK")
12 changes: 7 additions & 5 deletions man/DIANNtoMSstatsFormat.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions man/MSstatsClean.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions man/dot-cleanRawDIANN.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading