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
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Authors@R: c(
License: Artistic-2.0
Depends: R (>= 4.3)
Imports: dplyr, gridExtra, stringr, stats, ggplot2, stringi,
grDevices, MSstatsTMT, MSstatsConvert, MSstats,
grDevices, MSstatsTMT, MSstatsConvert (>= 1.19.1), MSstats,
data.table, Rcpp, Biostrings, checkmate, ggrepel, plotly, htmltools,
rlang
Suggests:
Expand All @@ -32,6 +32,7 @@ Suggests:
tinytest,
covr,
mockery,
arrow,
testthat (>= 3.0.0)
LazyData: true
LinkingTo: Rcpp
Expand Down
104 changes: 54 additions & 50 deletions R/converters.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
#'
#' @importFrom data.table as.data.table
#' @importFrom MSstatsConvert DIANNtoMSstatsFormat
#' @inheritParams MSstatsConvert::DIANNtoMSstatsFormat
#'
#' @param input data.frame of `report.tsv` file produced by Philosopher
#' @param annotation annotation with Run, Fraction, TechRepMixture, Mixture, Channel,
#' BioReplicate, Condition columns or a path to file. Refer to the example 'annotation' for the meaning of each column.
#' @param input_protein same as `input` for global profiling run. Default is NULL.
#' @param annotation_protein same as `annotation` for global profiling run. Default is NULL.
#' @param fasta_path A string of path to a FASTA file, used to match PTM peptides.
Expand All @@ -22,25 +20,6 @@
#' in `protein_id_col`. The protein names in these two columns must match in
#' order to join the FASTA file with the DIA-NN output. Default is "uniprot_ac"
#' for uniprot ID. For uniprot mnemonic ID, use "entry_name"
#' @param global_qvalue_cutoff The global qvalue cutoff. Default is 0.01.
#' @param qvalue_cutoff local qvalue cutoff for library. Default is 0.01.
#' @param pg_qvalue_cutoff local qvalue cutoff for protein groups Run should be
#' the same as filename. Default is 0.01.
#' @param useUniquePeptide logical, if TRUE (default) removes peptides that are assigned for more than one proteins.
#' We assume to use unique peptide for each protein.
#' @param removeFewMeasurements TRUE (default) will remove the features that have 1 or 2 measurements within each Run.
#' @param removeOxidationMpeptides TRUE (default) will remove the peptides including oxidation (M) sequence.
#' @param removeProtein_with1Feature TRUE will remove the proteins which have only 1 peptide and charge. Defaut is FALSE.
#' @param MBR If analaysis was done with match between runs or not. Default is TRUE.
#' @param use_log_file logical. If TRUE, information about data processing will
#' be saved to a file.
#' @param append logical. If TRUE, information about data processing will be
#' added to an existing log file.
#' @param verbose logical. If TRUE, information about data processing wil be
#' printed to the console.
#' @param log_file_path character. Path to a file to which information about
#' data processing will be saved. If not provided, such a file will be created
#' automatically. If 'append = TRUE', has to be a valid path to a file.
#'
#' @return `list` of one or two `data.frame` of class `MSstatsTMT`, named `PTM` and `PROTEIN`
#'
Expand Down Expand Up @@ -68,6 +47,28 @@
#'
#' head(msstatsptm_format$PTM)
#'
#' # Example DIANN 2.0
#' input = system.file("tinytest/raw_data/DIANN/diann_2_ptm.parquet",
#' package = "MSstatsPTM")
#' input = arrow::read_parquet(input)
#' annot = system.file("tinytest/raw_data/DIANN/annotation_diann_2.0_ptm.csv",
#' package = "MSstatsPTM")
#' annot = data.table::fread(annot)
#' fasta_path = system.file("extdata", "diann.fasta",
#' package="MSstatsPTM")
#'
#' msstatsptm_format = DIANNtoMSstatsPTMFormat(
#' input,
#' annot,
#' protein_id_col = "Protein.Names",
#' fasta_path = fasta_path,
#' fasta_protein_name = "entry_name",
#' use_log_file = FALSE,
#' quantificationColumn = "auto"
#' )
#'
#' head(msstatsptm_format$PTM)
#'
DIANNtoMSstatsPTMFormat = function(input,
annotation,
input_protein=NULL,
Expand All @@ -84,6 +85,7 @@ DIANNtoMSstatsPTMFormat = function(input,
removeOxidationMpeptides = TRUE,
removeProtein_with1Feature = FALSE,
MBR=TRUE,
quantificationColumn = "FragmentQuantCorrected",
use_log_file = TRUE,
append = FALSE,
verbose = TRUE,
Expand Down Expand Up @@ -120,41 +122,43 @@ DIANNtoMSstatsPTMFormat = function(input,
input = input[input[,..protein_id_col][[1]] != input$ProteinNameUnmod]
}

ptm_input = DIANNtoMSstatsFormat(input,
annotation,
global_qvalue_cutoff,
qvalue_cutoff,
pg_qvalue_cutoff,
useUniquePeptide,
removeFewMeasurements,
removeOxidationMpeptides,
removeProtein_with1Feature,
use_log_file,
append,
verbose,
log_file_path,
MBR)
ptm_input = DIANNtoMSstatsFormat(input = input,
annotation = annotation,
global_qvalue_cutoff = global_qvalue_cutoff,
qvalue_cutoff = qvalue_cutoff,
pg_qvalue_cutoff = pg_qvalue_cutoff,
useUniquePeptide = useUniquePeptide,
removeFewMeasurements = removeFewMeasurements,
removeOxidationMpeptides = removeOxidationMpeptides,
removeProtein_with1Feature = removeProtein_with1Feature,
use_log_file = use_log_file,
append = append,
verbose = verbose,
log_file_path = log_file_path,
MBR = MBR,
quantificationColumn = quantificationColumn)

msstats_format = list(PTM=ptm_input, PROTEIN=NULL)

if (!is.null(input_protein)){
checkmate::assertTRUE(!is.null(input_protein) &
!is.null(annotation_protein))

protein_input = DIANNtoMSstatsFormat(input_protein,
annotation_protein,
global_qvalue_cutoff,
qvalue_cutoff,
pg_qvalue_cutoff,
useUniquePeptide,
removeFewMeasurements,
removeOxidationMpeptides,
removeProtein_with1Feature,
use_log_file,
append,
verbose,
log_file_path,
MBR)
protein_input = DIANNtoMSstatsFormat(input = input_protein,
annotation = annotation_protein,
global_qvalue_cutoff = global_qvalue_cutoff,
qvalue_cutoff = qvalue_cutoff,
pg_qvalue_cutoff = pg_qvalue_cutoff,
useUniquePeptide = useUniquePeptide,
removeFewMeasurements = removeFewMeasurements,
removeOxidationMpeptides = removeOxidationMpeptides,
removeProtein_with1Feature = removeProtein_with1Feature,
use_log_file = use_log_file,
append = append,
verbose = verbose,
log_file_path = log_file_path,
MBR = MBR,
quantificationColumn = quantificationColumn)

msstats_format = list(PTM=ptm_input, PROTEIN=protein_input)

Expand Down
9 changes: 9 additions & 0 deletions inst/tinytest/raw_data/DIANN/annotation_diann_2.0_ptm.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Run,BioReplicate,Condition
Run1,1,Control
Run2,2,Control
Run3,3,Control
Run4,4,Control
Run5,5,Treatment
Run6,6,Treatment
Run7,7,Treatment
Run8,8,Treatment
Binary file added inst/tinytest/raw_data/DIANN/diann_2_ptm.parquet
Binary file not shown.
75 changes: 54 additions & 21 deletions man/DIANNtoMSstatsPTMFormat.Rd

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

Loading