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
20 changes: 19 additions & 1 deletion R/clean_Metamorpheus.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
#' Clean raw Metamorpheus files
#' @param msstats_object an object of class `MSstatsMetamorpheusFiles`.
#' @param MBR If TRUE, the function will include peaks detected by MBR
#' @param qvalue_cutoff The q-value cutoff for filtering peaks detected by MBR
#' @return data.table
#' @keywords internal
.cleanRawMetamorpheus = function(msstats_object) {
.cleanRawMetamorpheus = function(msstats_object, MBR = TRUE, qvalue_cutoff = 0.05) {
metamorpheus_input = getInputFile(msstats_object, "input")
metamorpheus_input = data.table::as.data.table(metamorpheus_input)
# Remove peptide decoys
if ("DecoyPeptide" %in% colnames(metamorpheus_input)) {
metamorpheus_input <- metamorpheus_input[!metamorpheus_input$DecoyPeptide, ]
}
# Remove peak decoys
if ("RandomRT" %in% colnames(metamorpheus_input)) {
metamorpheus_input <- metamorpheus_input[!metamorpheus_input$RandomRT, ]
}
if (MBR) {
metamorpheus_input = metamorpheus_input[
metamorpheus_input$PeakDetectionType == "MSMS" |
metamorpheus_input$`PIPQ-Value` <= qvalue_cutoff , ]
} else {
metamorpheus_input = metamorpheus_input[
metamorpheus_input$PeakDetectionType == "MSMS", ]
}
req_cols = c('FileName', 'ProteinGroup', 'FullSequence',
'PrecursorCharge', 'Peakintensity')
metamorpheus_input = metamorpheus_input[, req_cols, with = FALSE]
Expand Down
13 changes: 8 additions & 5 deletions R/converters_MetamorpheusToMSstatsFormat.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#' Import Metamorpheus files
#'
#' @param input name of Metamorpheus output file, which is tabular format. Use the AllQuantifiedPeaks.tsv file from the Metamorpheus output.
#' @param annotation name of 'annotation.txt' data which includes Condition, BioReplicate.
#' @param annotation name of 'annotation.txt' data which includes Condition, BioReplicate.
#' @param MBR If TRUE, the function will include peaks detected by MBR
#' @param qvalue_cutoff The q-value cutoff for filtering peaks detected by MBR
#' @inheritParams .sharedParametersAmongConverters
#'
#' @return data.frame in the MSstats required format.
Expand All @@ -11,17 +13,18 @@
#' @export
#'
#' @examples
#' input = system.file("tinytest/raw_data/Metamorpheus/AllQuantifiedPeaks.tsv",
#' input = system.file("tinytest/raw_data/Metamorpheus/QuantifiedPeaks.tsv",
#' package = "MSstatsConvert")
#' input = data.table::fread(input)
#' annot = system.file("tinytest/raw_data/Metamorpheus/Annotation.tsv",
#' annot = system.file("tinytest/raw_data/Metamorpheus/annotation.csv",
#' package = "MSstatsConvert")
#' annot = data.table::fread(annot)
#' metamorpheus_imported = MSstatsConvert:::MetamorpheusToMSstatsFormat(input, annotation = annot)
#' head(metamorpheus_imported)
#'
MetamorpheusToMSstatsFormat = function(
input, annotation = NULL, useUniquePeptide = TRUE, removeFewMeasurements = TRUE,
input, annotation = NULL, MBR = TRUE, qvalue_cutoff = 0.05,
useUniquePeptide = TRUE, removeFewMeasurements = TRUE,
removeProtein_with1Feature = FALSE, summaryforMultipleRows = max,
use_log_file = TRUE, append = FALSE, verbose = TRUE, log_file_path = NULL,
...
Expand All @@ -31,7 +34,7 @@ MetamorpheusToMSstatsFormat = function(

input = MSstatsConvert::MSstatsImport(list(input = input),
"MSstats", "Metamorpheus", ...)
input = MSstatsConvert::MSstatsClean(input)
input = MSstatsConvert::MSstatsClean(input, MBR, qvalue_cutoff)
annotation = MSstatsConvert::MSstatsMakeAnnotation(input, annotation)

feature_columns = c("PeptideSequence", "PrecursorCharge")
Expand Down
Binary file not shown.
339 changes: 0 additions & 339 deletions inst/tinytest/raw_data/Metamorpheus/AllQuantifiedPeaks.tsv

This file was deleted.

5 changes: 0 additions & 5 deletions inst/tinytest/raw_data/Metamorpheus/Annotation.tsv

This file was deleted.

67 changes: 67 additions & 0 deletions inst/tinytest/raw_data/Metamorpheus/QuantifiedPeaks.tsv

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions inst/tinytest/raw_data/Metamorpheus/annotation.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"Run","BioReplicate","Condition"
"B03_05_150304_human_ecoli_E_3ul_3um_column_95_HCD_OT_2hrs_30B_9B-calib",5,"E"
"B03_06_150304_human_ecoli_E_3ul_3um_column_95_HCD_OT_2hrs_30B_9B-calib",6,"E"
"B03_10_150304_human_ecoli_A_3ul_3um_column_95_HCD_OT_2hrs_30B_9B-calib",10,"A"
"B03_11_150304_human_ecoli_A_3ul_3um_column_95_HCD_OT_2hrs_30B_9B-calib",11,"A"
2 changes: 1 addition & 1 deletion inst/tinytest/test_cleanRaw.R
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,6 @@ expect_true(nrow(sn_cleaned) > 0)
expect_equal(sn_cleaned, sn_cleaned2)

# Metamorpheus
metamorpheus_table = data.table::fread("./raw_data/Metamorpheus/AllQuantifiedPeaks.tsv")
metamorpheus_table = data.table::fread("./raw_data/Metamorpheus/QuantifiedPeaks.tsv")
input = MSstatsConvert::MSstatsImport(list(input = metamorpheus_table), "MSstats", "Metamorpheus")
expect_identical(is(input), c("MSstatsMetamorpheusFiles", "MSstatsInputFiles"))
6 changes: 3 additions & 3 deletions inst/tinytest/test_converters_MetamorpheusToMSstatsFormat.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Test MetamorpheusToMSstatsFormat ---------------------------

input_file_path = system.file("tinytest/raw_data/Metamorpheus/AllQuantifiedPeaks.tsv", package="MSstatsConvert")
annotation_file_path = system.file("tinytest/raw_data/Metamorpheus/Annotation.tsv", package = "MSstatsConvert")
input_file_path = system.file("tinytest/raw_data/Metamorpheus/QuantifiedPeaks.tsv", package="MSstatsConvert")
annotation_file_path = system.file("tinytest/raw_data/Metamorpheus/annotation.csv", package = "MSstatsConvert")
input = data.table::fread(input_file_path)
annotation = data.table::fread(annotation_file_path)
output = MSstatsConvert:::MetamorpheusToMSstatsFormat(input, annotation = annotation)
expect_equal(ncol(output), 11)
expect_equal(nrow(output), 236)
expect_equal(nrow(output), 20)
expect_true("Run" %in% colnames(output))
expect_true("ProteinName" %in% colnames(output))
expect_true("PeptideSequence" %in% colnames(output))
Expand Down
4 changes: 3 additions & 1 deletion man/MSstatsClean.Rd

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

10 changes: 8 additions & 2 deletions man/MetamorpheusToMSstatsFormat.Rd

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

6 changes: 5 additions & 1 deletion man/dot-cleanRawMetamorpheus.Rd

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

Loading