Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

311 add module gsea #327

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions conf/test_experimental.config
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@ params {

// Exploratory
exploratory_main_variable = 'contrasts'

// Activate GSEA
gsea_run = true
gene_sets_files = 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/mus_musculus/gene_set_analysis/mh.all.v2022.1.Mm.symbols.gmt'

}
62 changes: 62 additions & 0 deletions subworkflows/local/enrichment/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@
include { MYGENE } from "../../../modules/nf-core/mygene/main.nf"
include { PROPR_GREA as GREA } from "../../../modules/local/propr/grea/main.nf"

include { GSEA_GSEA } from '../../../modules/nf-core/gsea/gsea/main.nf'
include { CUSTOM_TABULARTOGSEAGCT } from '../../../modules/nf-core/custom/tabulartogseagct/main.nf'
include { CUSTOM_TABULARTOGSEACLS } from '../../../modules/nf-core/custom/tabulartogseacls/main.nf'
include { TABULAR_TO_GSEA_CHIP } from '../../../modules/local/tabular_to_gsea_chip'

workflow ENRICHMENT {
take:
ch_tools // [ pathway_name, enrichment_map ]
ch_counts
ch_results_genewise
ch_results_genewise_filtered
ch_adjacency
ch_contrasts
ch_samplesheet
ch_featuresheet
ch_gene_sets
ch_versions
// TODO: add ch_gm when provided by user, etc.

main:
Expand Down Expand Up @@ -54,6 +64,58 @@ workflow ENRICHMENT {

// todo: add gsea here

// For GSEA, we need to convert normalised counts to a GCT format for
// input, and process the sample sheet to generate class definitions
// (CLS) for the variable used in each contrast

CUSTOM_TABULARTOGSEAGCT ( ch_counts )

// TODO: update CUSTOM_TABULARTOGSEACLS for value channel input per new
// guidlines (rather than meta usage employed here)
ch_contrasts_and_samples = ch_contrasts
.map{it[0]} // revert back to contrasts meta map
.combine( ch_samplesheet.map { it[1] } )

CUSTOM_TABULARTOGSEACLS(ch_contrasts_and_samples)

TABULAR_TO_GSEA_CHIP(
ch_featuresheet.map{ it[1] },
[params.features_id_col, params.features_name_col]
)

// The normalised matrix does not always have a contrast meta, so we
// need a combine rather than a join here
// Also add file name to metamap for easy access from modules.config

ch_gsea_inputs = CUSTOM_TABULARTOGSEAGCT.out.gct
.map{ it.tail() }
.combine(CUSTOM_TABULARTOGSEACLS.out.cls)
.map{ tuple(it[1], it[0], it[2]) }
.combine(ch_gene_sets)

GSEA_GSEA(
ch_gsea_inputs,
ch_gsea_inputs.map{ tuple(it[0].reference, it[0].target) }, // *
TABULAR_TO_GSEA_CHIP.out.chip.first()
)

// * Note: GSEA module currently uses a value channel for the mandatory
// non-file arguments used to define contrasts, hence the indicated
// usage of map to perform that transformation. An active subject of
// debate
GSEA_GSEA.out.report_tsvs_ref.view()
ch_gsea_results = GSEA_GSEA.out.report_tsvs_ref
.join(GSEA_GSEA.out.report_tsvs_target)

ch_enriched = ch_enriched.combine(ch_gsea_results)


// Record GSEA versions
ch_versions = ch_versions
.mix(TABULAR_TO_GSEA_CHIP.out.versions)
.mix(GSEA_GSEA.out.versions)


// ----------------------------------------------------
// Perform enrichment analysis with gprofiler2
// ----------------------------------------------------
Expand Down
10 changes: 9 additions & 1 deletion subworkflows/local/experimental/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ workflow EXPERIMENTAL {
take:
ch_contrasts // [ meta, contrast_variable, reference, target ]
ch_samplesheet // [ meta, samplesheet ]
ch_featuresheet // [ meta, featuresheet ]
ch_gene_sets
ch_counts // [ meta, counts]
ch_tools // [ pathway_name, differential_map, correlation_map, enrichment_map ]
ch_versions

main:

Expand Down Expand Up @@ -70,7 +73,12 @@ workflow EXPERIMENTAL {
ch_counts,
ch_results_genewise,
ch_results_genewise_filtered,
ch_adjacency
ch_adjacency,
ch_contrasts,
ch_samplesheet,
ch_featuresheet,
ch_gene_sets,
ch_versions
)
ch_enriched = ch_enriched.mix(ENRICHMENT.out.enriched)

Expand Down
5 changes: 4 additions & 1 deletion workflows/differentialabundance.nf
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,11 @@ workflow DIFFERENTIALABUNDANCE {
EXPERIMENTAL(
ch_contrasts,
VALIDATOR.out.sample_meta,
VALIDATOR.out.feature_meta,
ch_gene_sets,
CUSTOM_MATRIXFILTER.out.filtered,
ch_tools
ch_tools,
ch_versions
)

// TODO for the moment, these channels are allocated to not breaking the next part.
Expand Down
Loading