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): Add converter from metamorpheus to core MSstats #109

Closed
wants to merge 1 commit into from
Closed
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 NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export(MSstatsSummarize)
export(MSstatsSummarizeSingleLinear)
export(MSstatsSummarizeSingleTMP)
export(MaxQtoMSstatsFormat)
export(MetamorpheustoMSstatsFormat)
export(OpenMStoMSstatsFormat)
export(OpenSWATHtoMSstatsFormat)
export(PDtoMSstatsFormat)
Expand Down
61 changes: 61 additions & 0 deletions R/converters.R
Original file line number Diff line number Diff line change
Expand Up @@ -860,3 +860,64 @@ FragPipetoMSstatsFormat = function(
getOption("MSstatsLog")("INFO", "\n")
input
}


#' 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 ... additional parameters to `data.table::fread`.
#' @inheritParams .documentFunction
#'
#' @return data.frame in the MSstats required format.
#'
#' @author Anthony Wu
#'
#' @export
#'
#' @examples
#' input = system.file("tinytest/raw_data/Metamorpheus/AllQuantifiedPeaks.tsv",
#' package = "MSstatsConvert")
#' input = data.table::fread(input)
#' annot = system.file("tinytest/raw_data/Metamorpheus/Annotation.tsv",
#' package = "MSstatsConvert")
#' annot = data.table::fread(annot)
#' metamorpheus_imported = MSstats:::MetamorpheustoMSstatsFormat(input, annotation = annot)
#' head(metamorpheus_imported)
#'
MetamorpheustoMSstatsFormat = function(
input, annotation = NULL, useUniquePeptide = TRUE, removeFewMeasurements = TRUE,
removeProtein_with1Feature = FALSE, summaryforMultipleRows = max,
use_log_file = TRUE, append = FALSE, verbose = TRUE, log_file_path = NULL,
...
) {
MSstatsConvert::MSstatsLogsSettings(use_log_file, append, verbose,
log_file_path)

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

feature_columns = c("PeptideSequence", "PrecursorCharge")
input = MSstatsConvert::MSstatsPreprocess(
input,
annotation,
feature_columns,
remove_shared_peptides = useUniquePeptide,
remove_single_feature_proteins = removeProtein_with1Feature,
feature_cleaning = list(remove_features_with_few_measurements = removeFewMeasurements,
summarize_multiple_psms = summaryforMultipleRows),
columns_to_fill = list("FragmentIon" = NA,
"ProductCharge" = NA,
"IsotopeLabelType" = "L"))
input = MSstatsConvert::MSstatsBalancedDesign(input, feature_columns,
remove_few = removeFewMeasurements)

msg_final = paste("** Finished preprocessing. The dataset is ready",
"to be processed by the dataProcess function.")
getOption("MSstatsLog")("INFO", msg_final)
getOption("MSstatsMsg")("INFO", msg_final)
getOption("MSstatsLog")("INFO", "\n")
return(input)
}
24 changes: 24 additions & 0 deletions inst/tinytest/test_converters.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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 = data.table::fread(input_file_path)
annotation = data.table::fread(annotation_file_path)
output = MSstats:::MetamorpheustoMSstatsFormat(input, annotation = annotation)
expect_equal(ncol(output), 11)
expect_true(nrow(output) > 0)
expected_column_names = c(
"Run",
"ProteinName",
"PeptideSequence",
"PrecursorCharge",
"Intensity",
"FragmentIon",
"ProductCharge",
"IsotopeLabelType",
"Condition",
"BioReplicate",
"Fraction"
)
missing_columns = setdiff(expected_column_names, colnames(output))
expect_equal(length(missing_columns), 0)
70 changes: 70 additions & 0 deletions man/MetamorpheustoMSstatsFormat.Rd

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