diff --git a/.gitignore b/.gitignore index 7c81cae0..ee6edbaa 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ inst/doc *.Rproj *.DS_Store +*.log diff --git a/DESCRIPTION b/DESCRIPTION index 365ec25c..89057915 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,6 +29,7 @@ Suggests: knitr, rmarkdown Collate: + 'clean_Metamorpheus.R' 'clean_DIANN.R' 'clean_Philosopher.R' 'clean_Spectronaut.R' diff --git a/R/MSstatsConvert_core_functions.R b/R/MSstatsConvert_core_functions.R index 1bd59788..7141e231 100644 --- a/R/MSstatsConvert_core_functions.R +++ b/R/MSstatsConvert_core_functions.R @@ -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 diff --git a/R/clean_Metamorpheus.R b/R/clean_Metamorpheus.R new file mode 100644 index 00000000..1ebeb10d --- /dev/null +++ b/R/clean_Metamorpheus.R @@ -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 +} \ No newline at end of file diff --git a/inst/tinytest/processed_data/Metamorpheus/MSstatsMetamorpheusFilesObject.rds b/inst/tinytest/processed_data/Metamorpheus/MSstatsMetamorpheusFilesObject.rds new file mode 100644 index 00000000..252a0912 Binary files /dev/null and b/inst/tinytest/processed_data/Metamorpheus/MSstatsMetamorpheusFilesObject.rds differ diff --git a/inst/tinytest/raw_data/Metamorpheus/Annotation.tsv b/inst/tinytest/raw_data/Metamorpheus/Annotation.tsv new file mode 100644 index 00000000..3745fb78 --- /dev/null +++ b/inst/tinytest/raw_data/Metamorpheus/Annotation.tsv @@ -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 \ No newline at end of file diff --git a/inst/tinytest/test_clean_Metamorpheus.R b/inst/tinytest/test_clean_Metamorpheus.R new file mode 100644 index 00000000..5bbc2136 --- /dev/null +++ b/inst/tinytest/test_clean_Metamorpheus.R @@ -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)) \ No newline at end of file diff --git a/man/MSstatsClean.Rd b/man/MSstatsClean.Rd index 5568bd5a..bca5ce16 100644 --- a/man/MSstatsClean.Rd +++ b/man/MSstatsClean.Rd @@ -13,6 +13,7 @@ \alias{MSstatsClean,MSstatsSpectronautFiles-method} \alias{MSstatsClean,MSstatsPhilosopherFiles-method} \alias{MSstatsClean,MSstatsDIANNFiles-method} +\alias{MSstatsClean,MSstatsMetamorpheusFiles-method} \title{Clean files generated by a signal processing tools.} \usage{ MSstatsClean(msstats_object, ...) @@ -57,6 +58,8 @@ MSstatsClean(msstats_object, ...) ) \S4method{MSstatsClean}{MSstatsDIANNFiles}(msstats_object, MBR = TRUE) + +\S4method{MSstatsClean}{MSstatsMetamorpheusFiles}(msstats_object) } \arguments{ \item{msstats_object}{object that inherits from \code{MSstatsInputFiles} class.} @@ -125,6 +128,8 @@ data.table data.table +data.table + data.table } \description{ @@ -151,6 +156,8 @@ Clean Spectronaut files Clean Philosopher files Clean DIA-NN files + +Clean Metamorpheus files } \examples{ evidence_path = system.file("tinytest/raw_data/MaxQuant/mq_ev.csv", diff --git a/man/dot-cleanRawMetamorpheus.Rd b/man/dot-cleanRawMetamorpheus.Rd new file mode 100644 index 00000000..b977802d --- /dev/null +++ b/man/dot-cleanRawMetamorpheus.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/clean_Metamorpheus.R +\name{.cleanRawMetamorpheus} +\alias{.cleanRawMetamorpheus} +\title{Clean raw Metamorpheus files} +\usage{ +.cleanRawMetamorpheus(msstats_object) +} +\arguments{ +\item{msstats_object}{an object of class \code{MSstatsMetamorpheusFiles}.} +} +\value{ +data.table +} +\description{ +Clean raw Metamorpheus files +} +\keyword{internal}