Skip to content

Commit c1e587a

Browse files
Merge pull request #510 from antoniasaracco/decoupler_2
Add Decoupler
2 parents ecfdc89 + c3ed815 commit c1e587a

32 files changed

+1419
-77
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
### Added
99

10+
-[[#510]](https://github.com/nf-core/differentialabundance/pull/510) - Add decoupler module to differential functional enrichment subworkflow. ([@antoniasaracco](https://github.com/antoniasaracco), review by [@pinin4fjords](https://github.com/pinin4fjords) and [@grst](https://github.com/grst)).
11+
1012
- [[#473](https://github.com/nf-core/differentialabundance/pull/473)] - Allow formula-based contrasts in DESEQ2. ([@atrigila](https://github.com/atrigila), review by [@pinin4fjords](https://github.com/pinin4fjords) and [@grst](https://github.com/grst)).
1113
- [[#443](https://github.com/nf-core/differentialabundance/pull/443)] - Add toolsheet-related implementations. ([@suzannejin](https://github.com/suzannejin), review by [@pinin4fjords](https://github.com/pinin4fjords), [@mirpedrol](https://github.com/mirpedrol) and [@JoseEspinosa](https://github.com/JoseEspinosa))
1214
- [[#450](https://github.com/nf-core/differentialabundance/pull/441)] - Allow usage of strings for makeContrasts in DREAM. ([@atrigila](https://github.com/atrigila), review by [@pinin4fjords](https://github.com/pinin4fjords), [@suzannejin](https://github.com/suzannejin) and [@grst](https://github.com/grst)).

conf/modules.config

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,34 @@ process {
464464
].join(' ').trim() }
465465
}
466466

467+
withName: DECOUPLER_DECOUPLER {
468+
ext.prefix = {
469+
def method = meta.params.differential_method ?: meta.differential_method ?: "unknown"
470+
def prefix = "${method}_${meta.id}"
471+
return prefix
472+
}
473+
ext.args = {
474+
def features_id = meta.params?.features_id_col ?: 'gene_id'
475+
def features_symbol = meta.params?.features_name_col ?: 'gene_name'
476+
def min_n = meta.params?.decoupler_min_n ?: 5
477+
def methods = meta.params?.decoupler_methods ?: 'mlm'
478+
479+
"--min_n ${min_n} --transpose TRUE --ensembl_ids TRUE --methods ${methods} --features_id_col ${features_id} --features_symbol_col ${features_symbol} --column ${params.differential_fc_column}"
480+
}
481+
publishDir = [
482+
[
483+
path: { "${params.outdir}/tables/decoupler" },
484+
mode: params.publish_dir_mode,
485+
pattern: '*.tsv'
486+
],
487+
[
488+
path: { "${params.outdir}/plots/decoupler" },
489+
mode: params.publish_dir_mode,
490+
pattern: '*_estimate_decoupler_plot.png'
491+
]
492+
]
493+
}
494+
467495
// ==================================================================================
468496
// plotting and reports
469497
// ==================================================================================

conf/test.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,8 @@ params {
5555

5656
// Other
5757
round_digits = 3
58+
59+
// DECOUPLER
60+
decoupler_network = 'https://github.com/nf-core/test-datasets/raw/differentialabundance/modules_testdata/progeny/mouse_network.tsv'
61+
5862
}

conf/test_rnaseq_dream.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,7 @@ params {
5555

5656
// Other
5757
round_digits = 3
58+
59+
// DECOUPLER
60+
decoupler_network = 'https://github.com/nf-core/test-datasets/raw/differentialabundance/modules_testdata/progeny/mouse_network.tsv'
5861
}

conf/test_rnaseq_limma.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,7 @@ params {
6161

6262
// Other
6363
round_digits = 3
64+
65+
// DECOUPLER
66+
decoupler_network = 'https://github.com/nf-core/test-datasets/raw/differentialabundance/modules_testdata/progeny/mouse_network.tsv'
6467
}

docs/output.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ Stand-alone graphical outputs are placed in this directory. They may be useful i
4949
- `[contrast]/[norm_function].normalized_mean_variance_relationship.png`: Plots of log intensity vs mean log intensity after normalization of each contrast level.
5050
- `[contrast]/[norm_function].normalized_distributions.png`: A plot of sample distributions after normalization.
5151
- `[contrast]/raw_distributions.png`: A plot of sample distributions without normalization.
52-
53-
</details>
52+
- `decoupler/`: Directory containing plots of decoupler results - `[differential_method]_[contrast_name]_[decoupler_method]_estimate_decoupler_plot.png`: contains the plot for the estimated activity scores for each regulator (rows) across all samples (columns).
53+
</details>
5454

5555
Most plots are included in the HTML report (see above), but are also included in static files in this folder to facilitate use in external reporting.
5656

@@ -78,6 +78,9 @@ Most plots are included in the HTML report (see above), but are also included in
7878
- `gprofiler2/`: Directory containing tables of differential gene set analyis from gprofiler2 (where enabled)
7979
- `[contrast]/[contrast].gprofiler2.all_enriched_pathways.tsv`: A gprofiler2 report table for all enrichment results
8080
- `[contrast]/[contrast].gprofiler2.[source].sub_enriched_pathways.tsv`: A gprofiler2 report table of enriched pathways from one specific source/database, e.g. REAC
81+
- `decoupler/`: Directory containing tables of decoupler results
82+
- `[differential_method]_[contrast_name]_[decoupler_method]_estimate_decoupler.tsv`: contains the estimated activity scores for each regulator (rows) across all samples (columns).
83+
- `[differential_method]_[contrast_name]_[decoupler_method]_pvals_decoupler.tsv`: contains the associated p-values for those activity scores, when the method supports statistical significance estimation.
8184
- `proteus/`: If `--study_type maxquant`: Directory containing abundance values produced by the proteus module which is used for processing MaxQuant input. Files are prefixed with the associated contrast and chosen normalization function (if any).
8285
- `[contrast]/[norm_function].normalized_proteingroups_tab.tsv`: Abundance table after normalization.
8386
- `[contrast]/raw_proteingroups_tab.tsv`: Abundance table without normalization.

docs/usage.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,53 @@ By default the analysis will be run with a background list of genes that passed
410410

411411
Check the [pipeline webpage](https://nf-co.re/differentialabundance/parameters#gprofiler2) for a full listing of the relevant parameters.
412412

413+
### Decoupler
414+
415+
[Decoupler](https://decoupler-py.readthedocs.io/en/latest/index.html) `decoupler.decouple` is a Python function that infers biological regulator activities—such as transcription factor or pathway activity—from omics data using multiple statistical enrichment methods. It takes as input a gene expression matrix and a prior knowledge network linking regulators to target genes, and applies one or more methods (e.g., ULM, MLM, wsum) to estimate regulator activity scores across samples. The function supports optional consensus scoring and outputs method-specific activity estimates and p-values, making it a versatile tool for activity inference in both bulk and single-cell datasets. If you want to see the full list of available methods and functions, refer to the functions's [official guide]("https://decoupler-py.readthedocs.io/en/latest/generated/decoupler.decouple.html#decoupler.decouple").
416+
417+
This tool is turned off by default, to turn it on set the parameter `functional_method` to `decoupler`.
418+
419+
#### Input Files
420+
421+
Decoupler needs a matrix (mat) of molecular readouts (gene expression, logFC, p-values, etc.) and a network (net) that relates target features (genes, proteins, etc.) to “source” biological entities (pathways, transcription factors, molecular processes, etc.).
422+
423+
- The matrix will be taken from the results of the differential expression analysis performed by DESeq2, limma, propr, or variancePartition.
424+
425+
- The network file must be provided explicitly via the '--decoupler_network' parameter. This file should be in long format and contain at least the source and target columns, with optional weight and sign columns describing the strength and direction of each interaction.
426+
427+
#### Parameters
428+
429+
The Decoupler module includes a min_n parameter to fine-tune its behavior.
430+
431+
- `--decoupler_min_n`: This parameter controls the minimum number of targets a regulator (source) must have in the network to be included in the analysis. Any regulator with fewer than min_n targets will be removed from the network before activity inference is performed.
432+
433+
By default, `--decoupler_min_n` is set to 5, meaning all sources with at least one target will be evaluated. You can increase this value to filter out poorly supported regulators and reduce noise.
434+
435+
Example: setting `--decoupler_min_n 5` will ensure that only regulators with at least 5 target genes are considered.
436+
437+
- `--decoupler_methods`: This parameter lets you specify which statistical methods decoupler will use to estimate regulator activities. Decoupler supports multiple methods, each using a different algorithm or statistical approach. You can specify one or more methods by passing them as a comma-separated list.
438+
439+
Example: `--decoupler_methods` mlm,ulsm
440+
441+
##### Network Sources
442+
443+
You can obtain regulatory networks from well-established databases and tools. Common examples include:
444+
445+
- DoRothEA – transcription factor-target interactions (TFs) [DoRothEA](https://www.bioconductor.org/packages/release/data/experiment/html/dorothea.html)
446+
447+
- CollecTRI – curated transcriptional regulatory interactions (TFs) [CollectTRI] (https://github.com/saezlab/CollecTRI)
448+
449+
- PROGENy – pathway-responsive gene signatures (pathways) [PROGENy] (https://saezlab.github.io/progeny/)
450+
451+
If you want to see the full list of available methods and functions, refer to the functions's [official guide] (https://decoupler-py.readthedocs.io/en/latest/notebooks/benchmark.html#Multiple-networks).
452+
453+
**Note**: Then resources mentioned above are provided only for human or mouse datasets. Please ensure your organism is compatible before enabling this module or provide a custom, species-specific dataset.
454+
455+
```bash
456+
--functional_method decoupler \
457+
--decoupler_network network.tsv
458+
```
459+
413460
## Running the pipeline
414461

415462
The typical command for running the pipeline is as follows:

modules.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
"git_sha": "100b1dc1ece11cf8d4fec100314d616a66a60875",
4141
"installed_by": ["differential_functional_enrichment"]
4242
},
43+
"decoupler/decoupler": {
44+
"branch": "master",
45+
"git_sha": "202bddf7ffabd0d53e4c0ecc6b1ab526020a9744",
46+
"installed_by": ["differential_functional_enrichment"]
47+
},
4348
"deseq2/differential": {
4449
"branch": "master",
4550
"git_sha": "2e24bf8b6b045e1cf56a2907306b008113a686d0",
@@ -141,7 +146,7 @@
141146
},
142147
"differential_functional_enrichment": {
143148
"branch": "master",
144-
"git_sha": "4006954b7bfbbc61c7d5fb009319ed536d2ffca4",
149+
"git_sha": "202bddf7ffabd0d53e4c0ecc6b1ab526020a9744",
145150
"installed_by": ["subworkflows"]
146151
},
147152
"utils_nextflow_pipeline": {

modules/nf-core/decoupler/decoupler/environment.yml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/nf-core/decoupler/decoupler/main.nf

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)