Differential abundance analysis for feature/ observation matrices from platforms such as RNA-seq
Help improve this workflow!
This workflow has been published but could be further improved with some additional meta data:- Keyword(s) in categories input, output
You can help improve this workflow by suggesting the addition or removal of keywords, suggest changes and report issues, or request to become a maintainer of the Workflow .
Introduction
nf-core/differentialabundance is a bioinformatics pipeline that can be used to analyse data represented as matrices, comparing groups of observations to generate differential statistics and downstream analyses. The initial feature set is built around RNA-seq, but we anticipate rapid expansion to include other platforms.
The pipeline is built using Nextflow , a workflow tool to run tasks across multiple compute infrastructures in a very portable manner. It uses Docker/Singularity containers making installation trivial and results highly reproducible. The Nextflow DSL2 implementation of this pipeline uses one container per process which makes it much easier to maintain and update software dependencies. Where possible, these processes have been submitted to and installed from nf-core/modules in order to make them available to all nf-core pipelines, and to everyone within the Nextflow community!
On release, automated continuous integration tests run the pipeline on a full-sized dataset on the AWS cloud infrastructure. This ensures that the pipeline runs on AWS, has sensible resource allocation defaults set to run on real-world datasets, and permits the persistent storage of results to benchmark between pipeline releases and other analysis sources.The results obtained from the full-sized test can be viewed on the nf-core website .
Pipeline summary
-
Optionally generate a list of genomic feature annotations using the input GTF file (if a table is not explicitly supplied).
-
Cross-check matrices, sample annotations, feature set and contrasts to ensure consistency.
-
Run differential analysis over all contrasts specified.
-
Optionally run a differential gene set analysis.
-
Generate exploratory and differential analysis plots for interpretation.
-
Optionally build and (if specified) deploy a Shiny app for fully interactive mining of results.
-
Build an HTML report based on R markdown, with interactive plots (where possible) and tables.
Quick Start
-
Install
Nextflow
(>=22.10.1
) -
Install any of
Docker
,Singularity
(you can follow this tutorial ),Podman
,Shifter
orCharliecloud
for full pipeline reproducibility (you can useConda
both to install Nextflow itself and also to manage software within pipelines. Please only use it within pipelines as a last resort; see docs ) . -
Download the pipeline and test it on a minimal dataset with a single command:
nextflow run nf-core/differentialabundance -profile test,YOURPROFILE --outdir <OUTDIR>
Note that some form of configuration will be needed so that Nextflow knows how to fetch the required software. This is usually done in the form of a config profile (
YOURPROFILE
in the example command above). You can chain multiple config profiles in a comma-separated string.-
The pipeline comes with config profiles called
docker
,singularity
,podman
,shifter
,charliecloud
andconda
which instruct the pipeline to use the named tool for software management. For example,-profile test,docker
. -
Please check nf-core/configs to see if a custom config file to run nf-core pipelines already exists for your Institute. If so, you can simply use
-profile <institute>
in your command. This will enable eitherdocker
orsingularity
and set the appropriate execution settings for your local compute environment. -
If you are using
singularity
, please use thenf-core download
command to download images first, before running the pipeline. Setting theNXF_SINGULARITY_CACHEDIR
orsingularity.cacheDir
Nextflow options enables you to store and re-use the images from a central location for future pipeline runs. -
If you are using
conda
, it is highly recommended to use theNXF_CONDA_CACHEDIR
orconda.cacheDir
settings to store the environments in a central location for future pipeline runs.
-
-
Start running your own analysis!
RNA-seq:
nextflow run nf-core/differentialabundance \
--input samplesheet.csv \
--contrasts contrasts.csv \
--matrix assay_matrix.tsv \
--gtf mouse.gtf \
--outdir <OUTDIR> \
-profile rnaseq,<docker/singularity/podman/shifter/charliecloud/conda/institute>
Affymetrix microarray:
nextflow run nf-core/differentialabundance \
--input samplesheet.csv \
--contrasts contrasts.csv \
--affy_cel_files_archive cel_files.tar \
--outdir <OUTDIR> \
-profile affy,<docker/singularity/podman/shifter/charliecloud/conda/institute>
Reporting
The pipeline reports its outcomes in two forms.
Markdown-derived HTML report
The primary workflow output is an HTML-format report produced from an R markdown template . This leverages helper functions from shinyngs to produce rich plots and tables, but does not provide significant interactivity.
Shiny-based data mining app
A second optional output is produced by leveraging shinyngs to build an interactive Shiny application. This allows more interaction with the data, setting of thresholds etc.
By default the application is provided as an R script and associated serialised data structure, which you can use to quickly start the application locally. With proper configuration the app can also be deployed to shinyapps.io - though this requires you to have an account on that service (free tier available).
Documentation
The nf-core/differentialabundance pipeline comes with documentation about the pipeline usage , parameters and output .
Credits
nf-core/differentialabundance was originally written by Jonathan Manning ( @pinin4fjords ) and Oskar Wacker ( @WackerO ). Jonathan Manning is an employee of Healx, an AI-powered, patient-inspired tech company, accelerating the discovery and development of treatments for rare diseases. We are grateful for their support of open science in this project.
We thank the many members of the nf-core community who assisted with this pipeline, often by reviewing module pull requests including but not limited to:
Contributions and Support
If you would like to contribute to this pipeline, please see the contributing guidelines .
For further information or help, don't hesitate to get in touch on the
Slack
#differentialabundance
channel
(you can join with
this invite
).
Citations
If you use nf-core/differentialabundance for your analysis, please cite it using the following doi: 10.5281/zenodo.7568000 .
An extensive list of references for the tools used by the pipeline can be found in the
CITATIONS.md
file.
This pipeline uses code and infrastructure developed and maintained by the nf-core community, reused here under the MIT license .
You can cite the
nf-core
publication as follows:
The nf-core framework for community-curated bioinformatics pipelines.
Philip Ewels, Alexander Peltzer, Sven Fillinger, Harshil Patel, Johannes Alneberg, Andreas Wilm, Maxime Ulysse Garcia, Paolo Di Tommaso & Sven Nahnsen.
Nat Biotechnol. 2020 Feb 13. doi: 10.1038/s41587-020-0439-x .
Code Snippets
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | """ function find_column_number { file=\$1 column=\$2 head -n 1 \$file | tr '\\t' '\\n' | grep -n "^\${column}\$" | awk -F':' '{print \$1}' } id_col=\$(find_column_number $tsv $id) symbol_col=\$(find_column_number $tsv $symbol) outfile=\$(echo $tsv | sed 's/\\(.*\\)\\..*/\\1/').chip echo -e "Probe Set ID\\tGene Symbol\\tGene Title" > \${outfile}.tmp tail -n +2 $tsv | awk -F'\\t' -v id=\$id_col -v symbol=\$symbol_col '{print \$id"\\t"\$symbol"\\tNA"}' >> \${outfile}.tmp mv \${outfile}.tmp \${outfile} cat <<-END_VERSIONS > versions.yml "${task.process}": bash: \$(echo \$(bash --version | grep -Eo 'version [[:alnum:].]+' | sed 's/version //')) END_VERSIONS """ |
27 28 29 30 31 32 33 34 35 36 37 38 39 | """ gtf2featureAnnotation.R \\ --gtf-file $gtf \\ --output-file ${prefix}.anno.tsv \\ $reference_cdna \\ $args cat <<-END_VERSIONS > versions.yml "${task.process}": r-base: \$(echo \$(R --version 2>&1) | sed 's/^.*R version //; s/ .*\$//') atlas-gene-annotation-manipulation: 1.1.0 END_VERSIONS """ |
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | """ cls_file=${prefix}.cls column_number=\$(cat $samples | head -n 1 | tr '$separator' "\\n" | grep -En "^$variable" | awk -F':' '{print \$1}') classes=\$(tail -n +2 $samples | awk -F'$separator' '{print \$'\$column_number'}') unique_classes=\$(echo -e "\$classes" | awk '!x[\$0]++') echo -e "\$(echo -e \"\$classes\" | wc -l) \$(echo -e \"\$unique_classes\" | wc -l) 1" > \$cls_file echo -e "#\$(echo -e \"\$unique_classes\" | tr '\\n' ' ')" | sed "s/ \$//" >> \$cls_file echo -e "\$classes" | tr '\\n' ' ' | sed "s/ \$//" >> \$cls_file echo -e "\\n" >> \$cls_file cat <<-END_VERSIONS > versions.yml "${task.process}": bash: \$(echo \$(bash --version | grep -Eo 'version [[:alnum:].]+' | sed 's/version //')) END_VERSIONS """ |
26 27 28 29 30 31 32 33 34 35 36 37 38 39 | """ n_columns=\$(head -n 1 $tabular | tr "$separator" "\\n" | wc -l) n_lines=\$(wc -l < $tabular) gct_file=${prefix}.gct echo -e "#1.2\$(printf '\\t%.0s' {1..\$n_columns})\\n\$((n_lines-1))\\t\$((n_columns-1))\$(printf '\\t%.0s' {1..\$((n_columns-1))})" > \$gct_file echo -e "NAME\\tDESCRIPTION\\t\$(head -n 1 $tabular | cut -f1 -d\$'$separator' --complement | awk -F'$separator' 'BEGIN { OFS = "\\t"}; {\$1=\$1}1' )" >> \$gct_file cat $tabular | tail -n +2 | awk -F'$separator' 'BEGIN { OFS = "\\t"} {\$1=\$1"\\tNA"}1' >> \$gct_file cat <<-END_VERSIONS > versions.yml "${task.process}": bash: \$(echo \$(bash --version | grep -Eo 'version [[:alnum:].]+' | sed 's/version //')) END_VERSIONS """ |
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | """ # Run GSEA gsea-cli GSEA \\ -res $gct \\ -cls ${cls}#${target}_versus_${reference} \\ -gmx $gene_sets \\ $chip_command \\ -out . \\ --rpt_label $rpt_label \\ $args # Un-timestamp the outputs for path consistency mv ${rpt_label}.Gsea.*/* . timestamp=\$(cat *.rpt | grep producer_timestamp | awk '{print \$2}') for pattern in _\${timestamp} .\${timestamp}; do find . -name "*\${pattern}*" | sed "s|^\\./||" | while read -r f; do mv \$f \${f//\$pattern/} done done sed -i.bak "s/[_\\.]\$timestamp//g" *.rpt *.html && rm *.bak # Prefix files that currently lack it ls -p | grep -v / | grep -v "$prefix" | while read -r f; do mv \$f ${prefix}\${f} sed -i.bak "s/\$f/${prefix}\${f}/g" *.rpt *.html && rm *.bak done cat <<-END_VERSIONS > versions.yml "${task.process}": gsea: $VERSION END_VERSIONS """ |
23 24 25 26 27 28 29 30 31 32 33 | """ gunzip \\ -f \\ $args \\ $archive cat <<-END_VERSIONS > versions.yml "${task.process}": gunzip: \$(echo \$(gunzip --version 2>&1) | sed 's/^.*(gzip) //; s/ Copyright.*\$//') END_VERSIONS """ |
37 38 39 40 41 42 43 | """ touch $gunzip cat <<-END_VERSIONS > versions.yml "${task.process}": gunzip: \$(echo \$(gunzip --version 2>&1) | sed 's/^.*(gzip) //; s/ Copyright.*\$//') END_VERSIONS """ |
57 58 59 60 61 62 | """ } else { render_cmd = "rmarkdown::render('${prefix}.Rmd')" } """ |
90 | """ |
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | """ cp $feature_meta fixed_$feature_meta sed -i.bak s/${params.features_name_col}/gene_name/ fixed_$feature_meta make_app_from_files.R \\ --sample_metadata $sample \\ --feature_metadata fixed_$feature_meta \\ --assay_files ${assay_files.join(',')} \\ --contrast_file $contrasts \\ --contrast_stats_assay $contrast_stats_assay \\ --differential_results ${differential_results.join(',')} \\ --output_dir $prefix \\ $args \\ cat <<-END_VERSIONS > versions.yml "${task.process}": r-base: \$(echo \$(R --version 2>&1) | sed 's/^.*R version //; s/ .*\$//') r-shinyngs: \$(Rscript -e "library(shinyngs); cat(as.character(packageVersion('shinyngs')))") END_VERSIONS """ |
27 28 29 30 31 32 33 34 35 36 37 38 39 | """ differential_plots.R \\ --differential_file "$differential_result" \\ --feature_metadata "$feature_meta" \\ --outdir "$prefix" \\ $args cat <<-END_VERSIONS > versions.yml "${task.process}": r-base: \$(echo \$(R --version 2>&1) | sed 's/^.*R version //; s/ .*\$//') r-shinyngs: \$(Rscript -e "library(shinyngs); cat(as.character(packageVersion('shinyngs')))") END_VERSIONS """ |
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | """ exploratory_plots.R \\ --sample_metadata "$sample" \\ --feature_metadata "$feature_meta" \\ --assay_files "${assay_files.join(',')}" \\ --contrast_variable "${meta.id}" \\ --outdir "$prefix" \\ $args cat <<-END_VERSIONS > versions.yml "${task.process}": r-base: \$(echo \$(R --version 2>&1) | sed 's/^.*R version //; s/ .*\$//') r-shinyngs: \$(Rscript -e "library(shinyngs); cat(as.character(packageVersion('shinyngs')))") END_VERSIONS """ |
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | """ validate_fom_components.R \\ --sample_metadata "$sample" \\ $feature \\ --assay_files "${assay_files.join(',')}" \\ --contrasts_file "$contrasts" \\ --output_directory "$prefix" \\ $args cat <<-END_VERSIONS > versions.yml "${task.process}": r-base: \$(echo \$(R --version 2>&1) | sed 's/^.*R version //; s/ .*\$//') r-shinyngs: \$(Rscript -e "library(shinyngs); cat(as.character(packageVersion('shinyngs')))") END_VERSIONS """ |
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | """ mkdir $prefix ## Ensures --strip-components only applied when top level of tar contents is a directory ## If just files or multiple directories, place all in prefix if [[ \$(tar -taf ${archive} | grep -o -P "^.*?\\/" | uniq | wc -l) -eq 1 ]]; then tar \\ -C $prefix --strip-components 1 \\ -xavf \\ $args \\ $archive \\ $args2 else tar \\ -C $prefix \\ -xavf \\ $args \\ $archive \\ $args2 fi cat <<-END_VERSIONS > versions.yml "${task.process}": untar: \$(echo \$(tar --version 2>&1) | sed 's/^.*(GNU tar) //; s/ Copyright.*\$//') END_VERSIONS """ |
54 55 56 57 58 59 60 61 62 | """ mkdir $prefix touch ${prefix}/file.txt cat <<-END_VERSIONS > versions.yml "${task.process}": untar: \$(echo \$(tar --version 2>&1) | sed 's/^.*(GNU tar) //; s/ Copyright.*\$//') END_VERSIONS """ |
Support
- Future updates
Related Workflows





