# nf-core/mhcquant: Output

## Introduction

This document describes the output produced by the pipeline. Most of the plots are taken from the MultiQC report, which summarises results at the end of the pipeline.

The directories listed below will be created in the results directory after the pipeline has finished. All paths are relative to the top-level results directory.

## General

<summary>Output files</summary>

- `*.mzTab`
- `*.tsv`

The mzTab output file follows the a [HUPO-PSI format](<https://www.mcponline.org/article/S1535-9476(20)32821-8/fulltext>) and combines all information of the sample-condition group extracted from a database search throughout the pipeline. A detailed explanation of the respective entries are elaborately explained [here](https://psidev.info/sites/default/files/2017-07/R2_The_ten_minute_guide_to_mzTab.pdf). MzTab files are compatible with the PRIDE Archive - proteomics data repository and can be uploaded as search files.

MzTab files contain many columns and annotate the most important information - here are a few outpointed:

```bash
PEP  sequence  accession  best_search_engine_score[1]  retention_time  charge  mass_to_charge  peptide_abundance_study_variable[1]
```

By default (only identification) the `best_search_engine_score[1]` holds the percolator q-value. If `--quantify` is specified we annotated the Comet XCorr of each peptide identification in the `best_search_engine_score[1]` column and peptide quantities in the `peptide_abundance_study_variable` columns.

The TSV output file is an alternative output of [OpenMS](https://www.openms.de/) comprising similar information to the mzTab output. The TSV output of identification runs is a simple tab-delimited file holding information about FDR-filtered peptides and currently all values produced by `MS²Rescore`. The TSV file in quantification mode (by using `--quantify`) is more complex and described in more detail below

<details markdown="1">
<summary>TSV Quant</summary>

MAP contains information about the different mzML files that were provided initially

```bash
#MAP    id    filename    label    size
```

RUN contains information about the search that was performed on each run

```bash
#RUN    run_id  score_type      score_direction date_time       search_engine_version   parameters
```

PROTEIN contains information about the protein ids corresponding to the peptides that were detected (No protein inference was performed)

```bash
#PROTEIN        score   rank    accession       protein_description     coverage        sequence
```

UNASSIGNEDPEPTIDE contains information about PSMs that were identified but couldn't be quantified to a precursor feature on MS Level 1

```bash
#UNASSIGNEDPEPTIDE      rt      mz      score   rank    sequence        charge  aa_before       aa_after        score_type      search_identifier       accessions      FFId_category   feature_id      file_origin     map_index       spectrum_reference      COMET:IonFrac   COMET:deltCn    COMET:deltLCn   COMET:lnExpect  COMET:lnNumSP   COMET:lnRankSP  MS:1001491      MS:1001492      MS:1001493      MS:1002252      MS:1002253      MS:1002254      MS:1002255      MS:1002256      MS:1002257      MS:1002258      MS:1002259      num_matched_peptides    protein_references      target_decoy
```

CONSENSUS contains information about precursor features that were identified in multiple runs (eg. run 1-3 in this case)

```bash
#CONSENSUS      rt_cf   mz_cf   intensity_cf    charge_cf       width_cf        quality_cf      rt_0    mz_0    intensity_0     charge_0        width_0 rt_1    mz_1    intensity_1     charge_1        width_1 rt_2    mz_2    intensity_2     charge_2        width_2 rt_3    mz_3    intensity_3     charge_3        width_3
```

PEPTIDE contains information about peptide hits that were identified and correspond to the consensus features described below

```bash
#PEPTIDE        rt      mz      score   rank    sequence        charge  aa_before       aa_after        score_type      search_identifier       accessions      FFId_category   fea
```

See documentation of the format or PSI documentation for more information about [annotated scores and format](https://abibuilder.informatik.uni-tuebingen.de/archive/openms/Documentation/release/latest/html/TOPP_TextExporter.html).

</details>

### Intermediate results

<details  markdown="1">

This folder contains the intermediate results from various steps of the MHCquant pipeline (e.g. (un)filtered PSMs, aligned mzMLs, features)

<summary>Output files</summary>

- `intermediate_results/`

  - `alignment`: Contains the `trafoXML` files of each run that document the retention time shift after alignment in quantification mode.

  - `comet`: Contains pin files generated by comet after database search
  - `rescoring`

    - `{Sample}_{Condition}_(psm|ms2rescore).idXML`: File holding extra features generated by MS²Rescore that will be used by percolator or mokapot.
    - `{Sample}_{Condition}_pout.idXML`: Unfiltered percolator output.
    - `{Sample}_{Condition}_pout_filtered.idXML`: FDR-filtered percolator output.

  - `features`: Holds information of quantified features in `featureXML` files as a result of the [FeatureFinderIdentification](https://openms.de/doxygen/release/3.0.0/html/TOPP_FeatureFinderIdentification.html) in the quantification mode.

- `ion_annotations`

  - `{Sample}_{Condition}_all_peaks.tsv`: Contains metadata of all measured ions of peptides reported after peptide identification.

  - `{Sample}_{Condition}_matching_ions.tsv`: Contains ion annotations and additional metadata of peptides reported after peptide identification.

</details>

### MultiQC

<details markdown="1">
<summary>Output files</summary>

- `multiqc/`

- `multiqc_report.html`: a standalone HTML file that can be viewed in your web browser.

- `multiqc_data/`: directory containing parsed statistics from the different tools used in the pipeline.

- `multiqc_plots/`: directory containing static images from the report in various formats.

</details>

[MultiQC](http://multiqc.info) is a visualization tool that generates a single HTML report summarising all samples in your project. Most of the pipeline QC results are visualised in the report and further statistics are available in the report data directory.

Results generated by MultiQC collate pipeline QC from supported tools e.g. FastQC. The pipeline has special steps which also allow the software versions to be reported in the MultiQC output for future traceability. For more information about how to use MultiQC reports, see <http://multiqc.info>.

### Pipeline information

<details markdown="1">
<summary>Output files</summary>

- `pipeline_info/`

  - Reports generated by Nextflow: `execution_report.html`, `execution_timeline.html`, `execution_trace.txt` and `pipeline_dag.html`.
  - Reports generated by the pipeline: `software_versions.yml`.
  - Reformatted samplesheet files used as input to the pipeline: `samplesheet.valid.csv`.
  - Parameters used by the pipeline run: `params.json`.

</details>

[Nextflow](https://www.nextflow.io/docs/latest/tracing.html) provides excellent functionality for generating various reports relevant to the running and execution of the pipeline. This will allow you to troubleshoot errors with the running of the pipeline, and also provide you with other information such as launch commands, run times and resource usage.
