nf-core/metaboigniter
Pre-processing of mass spectrometry-based metabolomics data with quantification and identification based on MS1 and MS2 data.
Introduction
Samplesheet input
You will need to create a samplesheet with information about the samples you would like to analyse before running the pipeline. Use this parameter to specify its location. It has to be a comma-separated file with 4 columns, and a header row as shown in the examples below.
--input '[path to samplesheet file]'Each row in this CSV file represents a unique sample, with the details provided in the columns.
sample,level,type,msfileCONTROL_REP1,MS1,normal,mzML_POS_Quant/X2_Rep1.mzMLCONTROL_REP2,MS1,normal,mzML_POS_Quant/X2_Rep2.mzMLPOOL_MS2,MS2,normal,mzML_POS_ID/POOL_MS2.mzML| Column | Description |
|---|---|
sample |
This column should contain unique names for each sample. No two samples should share the same name in this column |
level |
This can be ‘MS1’ for files containing only MS1 data, ‘MS2’ for files containing only MS2 data, and ‘MS12’ for files containing both MS1 and MS2 data. |
type |
This column can contain any descriptor of your choice, such as ‘normal’, ‘disease’, etc. |
msfile |
This column should contain the path to the mzML file for each sample. |
Quantification
The quantification part of the contains the following steps:
- Optional centroiding (skipped by default)
- Feature detection
- Retention time aligmnet (can be skipped)
- Adduct annotation (can be skipped)
- feature linking or grouping
💡 Quantification is only performed on the samples with MS1 and MS12 levels. Samples with MS2 level will only be used for identification.
Requantification
This optional step fills values that are missing from individual samples after linking, by targeted extraction from each sample’s (aligned) mzML file with OpenMS FeatureFinderMetaboIdent. Enable it with --requantification.
💡 This has been adapted from UmetaFlow.
Annotation and linking run exactly as without requantification, so the observed matrix is the same as in a run without --requantification. Requantification then works on a copy of the linked consensus map:
- For each sample, every consensus feature without a handle from that sample becomes one target. The target m/z is the consensus m/z. The retention-time window is centred on the midpoint of the minimum and maximum RT of the feature’s handles and is
span + 2 x --requantification_rt_marginwide (30 s by default, the linker’slink:rt_tol; it must be greater than 0). FeatureFinderMetaboIdentextracts the targets. A sample without targets skips this step. When the tool succeeds, a target without a candidate stays missing asmissing_no_candidate; it is never filled. This includes a target whose RT window contains no non-empty MS1 spectrum, which the tool logs asCould not find any points for chromatogram. When no target of a sample yields any candidate,FeatureFinderMetaboIdent3.6.0 instead fails with exit status 8, a status it also uses for unrelated errors. The pipeline therefore treats exit status 8 as an empty result only for this recognised outcome: no feature file was written, the log reportsFound 0 feature candidates in total.and0 features left after selection of best candidates., its only error is the internal empty-range error that follows from the empty result, and it contains noCould not find any points for chromatogrammessage. Then all targets of the sample stay missing (missing_no_candidate). Every other failure stops the pipeline: exit status 8 together withCould not find any points for chromatogram(this happens when no target yields a candidate and at least one target’s RT window contains no non-empty MS1 spectrum, for example a window outside the run’s RT range or a sample whose MS1 spectra are empty), a failed elution-model imputation fit, a malformed library, or any other error. The outcome for a target whose RT window has no non-empty MS1 spectrum therefore depends on the other targets of the sample: it stays missing if any of them yields a candidate, and it stops the pipeline otherwise. “All targets absent” is therefore supported only when the extraction itself was valid, so that genuine extraction or configuration failures are reported instead of silently becoming missing values.- Every candidate goes through hard quality checks. A candidate is accepted only if all of them pass; otherwise the cell stays missing and the first failing check is reported:
malformed_qc_metadata: required FeatureFinderMetaboIdent metadata are missing or inconsistent, or the candidate is shared by several targets;existing_signal_overlap: an original feature of the same sample has its monoisotopic or any isotope-trace m/z within half of--extract_mz_window_featurefindermetaboident_openmsof the target m/z and its RT inside the candidate’s integration interval;no_peak_at_apex: there is no MS1 peak near the target m/z in the apex spectrum;apex_outside_target_window;model_status_not_valid: the elution model fit did not succeed. Only0 (valid)model areas are used, and--model_no_imputation_featurefindermetaboident_openmsistrueby default;low_apex_signal_fraction: fewer than--requantification_min_apex_signal_fraction(default 0.3) of the MS1 scans within 3 s of the apex have signal. The default was calibrated on a single dataset; see the limitations below;shared_candidate_signal: two candidates of the same sample cover the same peak;duplicate_feature_identity: the fill’s feature ID collides with an existing one.
- Each accepted fill is inserted as one feature handle into exactly the consensus feature that requested it. No consensus feature is moved, merged or relinked.
The sample ID used by the pipeline (meta.id, and the sample column of the requantification tables) is the base name of the sample’s mzML file, not the sample column of the samplesheet; the matrix and mask columns are named after the mzML file (<base name>.mzML). A sample’s column in the consensus map is identified by the IDs of its features. A sample without any features has no handles in the consensus map; its column is identified instead by the unique ID of its feature map together with the MS run path that the linker recorded for it (not by the sample ID). Every consensus feature then becomes a target for that sample, so its extraction and quality control take time and memory in proportion to the full number of consensus features (about 2-3 times a typical sample on the test data). Because the sample has no original features, existing_signal_overlap cannot reject any of its candidates; all other checks apply unchanged. The pipeline stops with an error, listing every consensus column, if a sample’s column cannot be identified unambiguously.
PYOPENMS_GAPFILLCONSENSUS holds the whole consensus map and an integrity snapshot of it in memory, about 0.4 KB per consensus handle. With the default process_single resources this covers roughly 14 million handles on the first attempt and about 29 million on the retry (a handle is one observed or gap-filled value; e.g. 1,000 samples × 40,000 consensus features with about half the values present is about 20 million handles, which needs the retry). For larger cohorts, give it more memory with a custom config:
process { withName: 'PYOPENMS_GAPFILLCONSENSUS' { memory = 32.GB }}The gap-filled matrix mixes two estimators (FeatureFinderMetabo areas for observed values, FeatureFinderMetaboIdent model areas for fills; see output) and no global intensity correction is applied. Use the requantification mask and provenance tables to separate or weight the filled values.
Known limitations:
- The quality-control default
--requantification_min_apex_signal_fraction 0.3was calibrated on one positive-ionisation, three-sample dataset (the nf-core test data). The 97.6 % precision of accepted fills is an internal leave-one-out/decoy control estimate on that dataset, not an independent validation. Scan rate, chromatography and instrument may change the appropriate threshold, so it is configurable. No real negative-mode data were used for calibration; the negative-mode tests use synthetic data and only validate code paths and charge handling. - On the test data, with the default
--detect_peak_width_featurefindermetaboident_openms 60, about 28 % of the features that are truly present in a sample yield no candidate, and the overlap check falsely rejects about 18 % of true fills (2.2 % at 15 s). Retuning this default is deferred. existing_signal_overlapalso checks the isotope traces of the original features. On leave-one-out controls on the test data the isotope-trace check removed 0.4% of true fills and 35% of decoy fills that passed every other check, so it is kept as a specificity filter.
Identification
Identification can be enable using --identification parameter.
We support both formula and structural predictions using SIRIUS (enable using --run_sirius and --sirius_runfid) as well as analogue search using MS2Query (enable using --run_ms2query).
⚠️
--sirius_runfidmust be always use together with--run_sirius. Ifsirius_runfidis used SIRIUS username and password must be provided using--sirius_emailandsirius_password
Another important parameter is --ms2_collection_model. This can be set to either paired or separate. If the dataset contains any file with only MS2 separate is perfered. Otherwise paired moode can be used.
The difference between these two modes is mainly related to how the quantification and outputting is performed. In the separate mode, all the samples (regardless of the MS levels) will be aligned first before performing quantification. In this mode, feature detection will not be performed on MS2 files.
In contrast, in the paired mode, all the files will be first subjected to feature detection and alignment.
💡 If you want to perform feature detection on MS2 files, set their level to MS12 and use the
pairedmode.
Performance specific parameters
For larger datasets one can split certain calculations. We support for split feature grouping and identification.
-
For feature grouping, simply set
--parallel_linkingand use--algorithm_nr_partitions_featurelinkerunlabeledkd_openmsto set the number of partitions. -
For identification, one can split MS2 mapping using
--split_consensus_partsto perform MS2-feature mapping in parallel. Also parameter--mgf_splitmgf_pyopenmscan be used to split the mgf files into multiple chunks and each chunk will be run separately. It defaults to1, which means no splitting. MS2Query uses the chunks whenever the value is above1. SIRIUS uses them only when--sirius_splitis also set, so--sirius_splitalone runs SIRIUS as a single task; set both, for example--sirius_split --mgf_splitmgf_pyopenms 8.
Running the pipeline
The typical command for running the pipeline is as follows:
nextflow run nf-core/metaboigniter --input ./samplesheet.csv --outdir ./results -profile dockerThis will launch the pipeline with the docker configuration profile. See below for more information about profiles.
Note that the pipeline will create the following files in your working directory:
work # Directory containing the nextflow working files<OUTDIR> # Finished results in specified location (defined with --outdir).nextflow_log # Log file from Nextflow# Other nextflow hidden files, eg. history of pipeline runs and old logs.If you wish to repeatedly use the same parameters for multiple runs, rather than specifying each flag in the command, you can specify these in a params file.
Pipeline settings can be provided in a yaml or json file via -params-file <file>.
Do not use -c <file> to specify parameters as this will result in errors. Custom config files specified with -c must only be used for tuning process resource specifications, other infrastructural tweaks (such as output directories), or module arguments (args).
The above pipeline run specified with a params file in yaml format:
nextflow run nf-core/metaboigniter -profile docker -params-file params.yamlwith:
input: './samplesheet.csv'outdir: './results/'<...>You can also generate such YAML/JSON files via nf-core/launch.
From Nextflow 26.04 the strict syntax parser is the default, and it no longer converts command-line values: --identification true reaches the pipeline as the text "true". Parameter validation therefore rejects boolean and numeric parameters given on the command line (Value is [string] but should be [boolean]). Set those parameters in a params file instead, where YAML/JSON keep their types:
identification: truerequantification: truesplit_consensus_parts: 20String parameters such as --input and --outdir can still be given on the command line.
Updating the pipeline
When you run the above command, Nextflow automatically pulls the pipeline code from GitHub and stores it as a cached version. When running the pipeline after this, it will always use the cached version if available - even if the pipeline has been updated since. To make sure that you’re running the latest version of the pipeline, make sure that you regularly update the cached version of the pipeline:
nextflow pull nf-core/metaboigniterReproducibility
It is a good idea to specify the pipeline version when running the pipeline on your data. This ensures that a specific version of the pipeline code and software are used when you run your pipeline. If you keep using the same tag, you’ll be running the same version of the pipeline, even if there have been changes to the code since.
First, go to the nf-core/metaboigniter releases page and find the latest pipeline version - numeric only (eg. 1.3.1). Then specify this when running the pipeline with -r (one hyphen) - eg. -r 1.3.1. Of course, you can switch to another version by changing the number after the -r flag.
This version number will be logged in reports when you run the pipeline, so that you’ll know what you used when you look back in the future. For example, at the bottom of the MultiQC reports.
To further assist in reproducibility, you can use share and reuse parameter files to repeat pipeline runs with the same settings without having to write out a command with every single parameter.
If you wish to share such profile (such as upload as supplementary material for academic publications), make sure to NOT include cluster specific paths to files, nor institutional specific profiles.
Core Nextflow arguments
These options are part of Nextflow and use a single hyphen (pipeline parameters use a double-hyphen)
-profile
Use this parameter to choose a configuration profile. Profiles can give configuration presets for different compute environments.
Several generic profiles are bundled with the pipeline which instruct the pipeline to use software packaged using different methods (Docker, Singularity, Podman, Shifter, Charliecloud, Apptainer, Conda) - see below.
We highly recommend the use of Docker or Singularity containers for full pipeline reproducibility, however when this is not possible, Conda is also supported.
The pipeline also dynamically loads configurations from https://github.com/nf-core/configs when it runs, making multiple config profiles for various institutional clusters available at run time. For more information and to check if your system is supported, please see the nf-core/configs documentation.
Note that multiple profiles can be loaded, for example: -profile test,docker - the order of arguments is important!
They are loaded in sequence, so later profiles can overwrite earlier profiles.
If -profile is not specified, the pipeline will run locally and expect all software to be installed and available on the PATH. This is not recommended, since it can lead to different results on different machines dependent on the computer environment.
test- A profile with a complete configuration for automated testing
- Includes links to test data so needs no other parameters
docker- A generic configuration profile to be used with Docker
singularity- A generic configuration profile to be used with Singularity
podman- A generic configuration profile to be used with Podman
shifter- A generic configuration profile to be used with Shifter
charliecloud- A generic configuration profile to be used with Charliecloud
apptainer- A generic configuration profile to be used with Apptainer
wave- A generic configuration profile to enable Wave containers. Use together with one of the above (requires Nextflow
24.03.0-edgeor later).
- A generic configuration profile to enable Wave containers. Use together with one of the above (requires Nextflow
conda- A generic configuration profile to be used with Conda. Please only use Conda as a last resort i.e. when it’s not possible to run the pipeline with Docker, Singularity, Podman, Shifter, Charliecloud, or Apptainer.
-resume
Specify this when restarting a pipeline. Nextflow will use cached results from any pipeline steps where the inputs are the same, continuing from where it got to previously. For input to be considered the same, not only the names must be identical but the files’ contents as well. For more info about this parameter, see this blog post.
You can also supply a run name to resume a specific run: -resume [run-name]. Use the nextflow log command to show previous run names.
-c
Specify the path to a specific config file (this is a core Nextflow command). See the nf-core website documentation for more information.
Custom configuration
Resource requests
Whilst the default requirements set within the pipeline will hopefully work for most people and with most input data, you may find that you want to customise the compute resources that the pipeline requests. Each step in the pipeline has a default set of requirements for number of CPUs, memory and time. For most of the pipeline steps, if the job exits with any of the error codes specified here it will automatically be resubmitted with higher resources request (2 x original, then 3 x original). If it still fails after the third attempt then the pipeline execution is stopped.
To change the resource requests, please see the max resources and customise process resources section of the nf-core website.
Custom Containers
In some cases, you may wish to change the container or conda environment used by a pipeline steps for a particular tool. By default, nf-core pipelines use containers and software from the biocontainers or bioconda projects. However, in some cases the pipeline specified version maybe out of date.
To use a different container from the default container or conda environment specified in a pipeline, please see the updating tool versions section of the nf-core website.
Custom Tool Arguments
A pipeline might not always support every possible argument or option of a particular tool used in pipeline. Fortunately, nf-core pipelines provide some freedom to users to insert additional parameters that the pipeline does not include by default.
To learn how to provide additional arguments to a particular tool of the pipeline, please see the customising tool arguments section of the nf-core website.
nf-core/configs
In most cases, you will only need to create a custom config as a one-off but if you and others within your organisation are likely to be running nf-core pipelines regularly and need to use the same settings regularly it may be a good idea to request that your custom config file is uploaded to the nf-core/configs git repository. Before you do this please can you test that the config file works with your pipeline of choice using the -c parameter. You can then create a pull request to the nf-core/configs repository with the addition of your config file, associated documentation file (see examples in nf-core/configs/docs), and amending nfcore_custom.config to include your custom profile.
See the main Nextflow documentation for more information about creating your own configuration files.
If you have any questions or issues please send us a message on Slack on the #configs channel.
Running in the background
Nextflow handles job submissions and supervises the running jobs. The Nextflow process must run until the pipeline is finished.
The Nextflow -bg flag launches Nextflow in the background, detached from your terminal so that the workflow does not stop if you log out of your session. The logs are saved to a file.
Alternatively, you can use screen / tmux or similar tool to create a detached session which you can log back into at a later time.
Some HPC setups also allow you to run nextflow within a cluster job submitted your job scheduler (from where it submits more jobs).
Nextflow memory requirements
In some cases, the Nextflow Java virtual machines can start to request a large amount of memory.
We recommend adding the following line to your environment to limit this (typically in ~/.bashrc or ~./bash_profile):
NXF_OPTS='-Xms1g -Xmx4g'