% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/converters_DIANNtoMSstatsFormat.R
\name{DIANNtoMSstatsFormat}
\alias{DIANNtoMSstatsFormat}
\title{Import Diann files}
\usage{
DIANNtoMSstatsFormat(
  input,
  annotation = NULL,
  global_qvalue_cutoff = 0.01,
  qvalue_cutoff = 0.01,
  pg_qvalue_cutoff = 0.01,
  useUniquePeptide = TRUE,
  removeFewMeasurements = TRUE,
  removeOxidationMpeptides = TRUE,
  removeProtein_with1Feature = TRUE,
  MBR = TRUE,
  labeledAminoAcids = NULL,
  quantificationColumn = "FragmentQuantCorrected",
  calculateAnomalyScores = FALSE,
  anomalyModelFeatures = c(),
  anomalyModelFeatureTemporal = c(),
  removeMissingFeatures = 0.5,
  anomalyModelFeatureCount = 100,
  runOrder = NULL,
  n_trees = 100,
  max_depth = "auto",
  numberOfCores = 1,
  use_log_file = TRUE,
  append = FALSE,
  verbose = TRUE,
  log_file_path = NULL,
  ...
)
}
\arguments{
\item{input}{name of MSstats input report from Diann, which includes fragment-level data.
Output fragment data with --export-quant flag in DIA-NN 2.0}

\item{annotation}{name of 'annotation.txt' data which includes Condition, BioReplicate, Run.}

\item{global_qvalue_cutoff}{The qvalue cutoff for the Q.Value column, i.e.
the run-specific precursor q-value. Default is 0.01.}

\item{qvalue_cutoff}{If MBR is false, the qvalue cutoff for the Global.Q.Value
column, i.e. global precursor q-value.  If MBR is true, the qvalue cutoff for the
Lib.Q.Value column, i.e. the q-value for the library created after the first MBR pass.
Default is 0.01.}

\item{pg_qvalue_cutoff}{If MBR is false, the qvalue cutoff for the Global.PG.Q.Value
column, i.e. the global q-value for the protein group.  If MBR is true, the
qvalue cutoff for the Lib.PG.Q.Value column, i.e. the protein group q-value for
the library created after the first MBR pass. Default is 0.01.}

\item{useUniquePeptide}{should unique peptides be removed}

\item{removeFewMeasurements}{should proteins with few measurements be removed}

\item{removeOxidationMpeptides}{should peptides with oxidation be removed}

\item{removeProtein_with1Feature}{should proteins with a single feature be removed}

\item{MBR}{True if analysis was done with match between runs}

\item{labeledAminoAcids}{Character vector of single-letter amino acid codes
that carry the SILAC label in protein turnover experiments, e.g.
\code{c("K")} or \code{c("K", "R")}.  Supplying this vector opts in to
protein-turnover mode; the exact amino acids determine behaviour only in the
\code{ModifiedSequence}-parsing path described below.

\strong{Channel-based path} (DIA-NN 2.x exports that include a
\code{Channel} column): when \code{labeledAminoAcids} is non-\code{NULL}
\emph{and} the input contains a \code{Channel} column, \code{Channel} values
are mapped directly to \code{IsotopeLabelType} (\code{"H"} → \code{"H"},
\code{"L"} → \code{"L"}, anything else → \code{NA}).  The amino acid codes
in \code{labeledAminoAcids} are \strong{not} used to validate or filter
\code{ModifiedSequence} in this path.

\strong{ModifiedSequence-parsing path} (DIA-NN 1.x exports without a
\code{Channel} column): when \code{labeledAminoAcids} is non-\code{NULL}
and no \code{Channel} column is present, each \code{ModifiedSequence} is
inspected for SILAC suffixes of the form \code{(SILAC-<AA>-H)} or
\code{(SILAC-<AA>-L)}, where \code{<AA>} is one of the supplied amino acid
codes.  Matching sequences are classified as \code{"H"} or \code{"L"};
sequences carrying neither suffix receive \code{IsotopeLabelType = NA}.
The SILAC suffix is then stripped from \code{PeptideSequence}.

When \code{NULL} (default), protein-turnover mode is disabled and all
peptides receive \code{IsotopeLabelType = "Light"}.}

\item{quantificationColumn}{Use 'FragmentQuantCorrected'(default) column for quantified intensities for DIANN 1.8.x.
Use 'FragmentQuantRaw' for quantified intensities for DIANN 1.9.x.
Use 'auto' for quantified intensities for DIANN 2.x where each fragment intensity is a separate column, e.g. Fr0Quantity.}

\item{calculateAnomalyScores}{Default is FALSE. If TRUE, will run anomaly detection model and calculate anomaly scores for each feature. Used downstream to weigh measurements in differential analysis.}

\item{anomalyModelFeatures}{character vector of quality metric column names to be used as features in the anomaly detection model. List must not be empty if calculateAnomalyScores=TRUE.}

\item{anomalyModelFeatureTemporal}{character vector of temporal direction corresponding to columns passed to anomalyModelFeatures. Values must be one of: \code{mean_decrease}, \code{mean_increase}, \code{dispersion_increase}, or NULL (to perform no temporal feature engineering). Default is empty vector. If calculateAnomalyScores=TRUE, vector must have as many values as anomalyModelFeatures (even if all NULL).}

\item{removeMissingFeatures}{Remove features with missing values in more than this fraction of runs. Default is 0.5. Only used if calculateAnomalyScores=TRUE.}

\item{anomalyModelFeatureCount}{Feature selection for anomaly model. Anomaly detection works on the precursor-level and can be much slower if all features used. We will by default filter to the top-100 highest intensity features. This can be adjusted as necessary. To turn feature-selection off, set this value to a high number (e.g. 10000). Only used if calculateAnomalyScores=TRUE.}

\item{runOrder}{Temporal order of MS runs. Should be a two column data.table with columns \code{Run} and \code{Order}, where \code{Run} matches the run name output by DIA-NN and \code{Order} is an integer. Used to engineer the temporal features defined in anomalyModelFeatureTemporal.}

\item{n_trees}{Number of trees to use in isolation forest when calculateAnomalyScores=TRUE. Default is 100.}

\item{max_depth}{Max tree depth to use in isolation forest when calculateAnomalyScores=TRUE. Default is "auto" which calculates depth as log2(N) where N is the number of runs. Otherwise must be an integer.}

\item{numberOfCores}{Number of cores for parallel processing anomaly detection model. When > 1, a logfile named 'MSstats_anomaly_model_progress.log' is created to track progress. Only works for Linux & Mac OS. Default is 1.}

\item{use_log_file}{logical. If TRUE, information about data processing
will be saved to a file.}

\item{append}{logical. If TRUE, information about data processing will be added
to an existing log file.}

\item{verbose}{logical. If TRUE, information about data processing will be printed
to the console.}

\item{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 \code{append = TRUE}, has to be a valid path to a file.}

\item{...}{additional parameters to \code{data.table::fread}.}
}
\value{
data.frame in the MSstats required format.
}
\description{
Import Diann files
}
\examples{
input_file_path = system.file("tinytest/raw_data/DIANN/diann_input.tsv", 
                                package="MSstatsConvert")
annotation_file_path = system.file("tinytest/raw_data/DIANN/annotation.csv", 
                                package = "MSstatsConvert")
input = data.table::fread(input_file_path)
annot = data.table::fread(annotation_file_path)
output = DIANNtoMSstatsFormat(input, annotation = annot, MBR = FALSE, 
                                use_log_file = FALSE)
head(output)

# For DIANN 2.0, set quantificationColumn = 'auto'
input_file_path_2_0 = system.file("tinytest/raw_data/DIANN/diann_2.0.parquet", 
                                package="MSstatsConvert")
annotation_file_path_2_0 = system.file("tinytest/raw_data/DIANN/annotation_diann_2.0.csv", 
                                package = "MSstatsConvert")
input_2_0 = arrow::read_parquet(input_file_path_2_0)
annot_2_0 = data.table::fread(annotation_file_path_2_0)
output_2_0 = DIANNtoMSstatsFormat(input_2_0, annotation = annot_2_0, MBR = FALSE, 
                                use_log_file = FALSE, quantificationColumn = 'auto')
head(output_2_0)
}
\author{
Elijah Willie
}
