Skip to content
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

feat(metamorpheus-converter): Add clean functionality of metamorpheus converter #83

Merged
merged 4 commits into from
Jan 17, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
inst/doc
*.Rproj
*.DS_Store
*.log
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Suggests:
knitr,
rmarkdown
Collate:
'clean_Metamorpheus.R'
'clean_DIANN.R'
'clean_Philosopher.R'
'clean_Spectronaut.R'
Expand Down
7 changes: 7 additions & 0 deletions R/MSstatsConvert_core_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,13 @@ setMethod("MSstatsClean", signature = "MSstatsPhilosopherFiles",
#' @return data.table
setMethod("MSstatsClean", signature = "MSstatsDIANNFiles",
.cleanRawDIANN)
#' Clean Metamorpheus files
#' @include clean_Metamorpheus.R
#' @rdname MSstatsClean
#' @inheritParams .cleanRawMetamorpheus
#' @return data.table
setMethod("MSstatsClean", signature = "MSstatsMetamorpheusFiles",
.cleanRawMetamorpheus)


#' Preprocess outputs from MS signal processing tools for analysis with MSstats
Expand Down
18 changes: 18 additions & 0 deletions R/clean_Metamorpheus.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#' Clean raw Metamorpheus files
#' @param msstats_object an object of class `MSstatsMetamorpheusFiles`.
#' @return data.table
#' @keywords internal
.cleanRawMetamorpheus = function(msstats_object) {
metamorpheus_input = getInputFile(msstats_object, "input")
metamorpheus_input = data.table::as.data.table(metamorpheus_input)
req_cols = c('FileName', 'ProteinGroup', 'FullSequence',
'PrecursorCharge', 'Peakintensity')
metamorpheus_input = metamorpheus_input[, req_cols, with = FALSE]
data.table::setnames(
metamorpheus_input,
c("ProteinGroup", "FullSequence", "PrecursorCharge", "FileName", "Peakintensity"),
c("ProteinName", "PeptideSequence", "PrecursorCharge", "Run", "Intensity"),
skip_absent = TRUE)
.logSuccess("Metamorpheus", "clean")
metamorpheus_input
}
Binary file not shown.
5 changes: 5 additions & 0 deletions inst/tinytest/raw_data/Metamorpheus/Annotation.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Run Condition BioReplicate Fraction
NEG1-calib neg 1 1
NEG2-calib neg 2 1
POS1-calib pos 3 1
POS2-calib pos 4 1
12 changes: 12 additions & 0 deletions inst/tinytest/test_clean_Metamorpheus.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Test Metamorpheus .cleanRawMetamorpheus ---------------------------

file_path = system.file("tinytest/processed_data/Metamorpheus/MSstatsMetamorpheusFilesObject.rds", package="MSstatsConvert")
input = readRDS(file_path)
output = MSstatsConvert:::.cleanRawMetamorpheus(input)
expect_equal(ncol(output), 5)
expect_true(nrow(output) > 0)
expect_true("Run" %in% colnames(output))
expect_true("ProteinName" %in% colnames(output))
expect_true("PeptideSequence" %in% colnames(output))
expect_true("PrecursorCharge" %in% colnames(output))
expect_true("Intensity" %in% colnames(output))
7 changes: 7 additions & 0 deletions man/MSstatsClean.Rd

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

18 changes: 18 additions & 0 deletions man/dot-cleanRawMetamorpheus.Rd

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

Loading