Skip to content
Draft
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed link to example contranst file in the usage documentation ([#236](https://github.com/nf-core/crisprseq/pull/236))
- Fixed bug in Bowtie alignment for guide libraries ([#247](https://github.com/nf-core/crisprseq/pull/247))
- Sample names instead of conditions are used in the MAGeCK output ([#252](https://github.com/nf-core/crisprseq/pull/252))
- Supports precomputed count matrices without a samplesheet, interpreting contrast file entries as samples instead of conditions ([#260](https://github.com/nf-core/crisprseq/pull/260))

### General

Expand Down
4 changes: 3 additions & 1 deletion docs/usage/screening.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ BAGEL2 and DrugZ. You can run any of these modules by providing a contrast file
- `--drugz` for DrugZ
- `--bagel2` for BAGEL2

The contrast file must contain the headers "reference" and "treatment". These two columns should be separated with a semicolon (;) and contain the `csv` extension. You can also integrate several samples/conditions by comma-separating them in each column. Please find an example below:
The contrast file must contain the headers "reference" and "treatment". These two columns should be separated with a semicolon (;) and contain the `csv` extension. You can also integrate several conditions by comma-separating them in each column. Please find an example below:

| reference | treatment |
| ----------------- | --------------------- |
Expand All @@ -91,6 +91,8 @@ The contrast file must contain the headers "reference" and "treatment". These tw

A full example can be found [here](https://raw.githubusercontent.com/nf-core/test-datasets/crisprseq/testdata/rra_contrasts.txt).

When providing a precomputed count matrix with `--count_table`, the contrast file must list sample names (not conditions). Use the exact sample labels from the count table header, and if you want to group multiple samples, separate them with commas within each column.

#### Venn diagram

Running MAGeCK MLE and BAGEL2 with a contrast file will also output a Venn diagram showing common genes having an FDR < 0.1.
Expand Down
2 changes: 1 addition & 1 deletion subworkflows/local/utils_nfcore_crisprseq_pipeline/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ workflow INITIALISATION_CHANNEL_CREATION_SCREENING {
ch_hgnc = Channel.fromPath("$projectDir/assets/hgnc_complete_set.txt", checkIfExists: true).first()

if(params.mle_control_sgrna) {
ch_mle_control_sgrna = Channel.fromPath(params.mle_control_sgrna)
ch_mle_control_sgrna = Channel.value(file(params.mle_control_sgrna, checkIfExists: true))
} else {
ch_mle_control_sgrna = []
}
Expand Down
48 changes: 29 additions & 19 deletions workflows/crisprseq_screening.nf
Original file line number Diff line number Diff line change
Expand Up @@ -235,35 +235,45 @@ workflow CRISPRSEQ_SCREENING {

if (params.contrasts) {

// Map each condition in the samplesheet to the list of sample ids belonging to that condition
ch_samplesheet
.map { meta, _fastq -> [meta.condition, meta] }
.groupTuple(by: 0) // Group by condition
.map { condition, metas -> [condition, metas.collect { it.id }]}
.set { ch_samplesheet_conditions } // tuples (condition, [sample_id1, sample_id2, ...])

// Map each contrast in the contrasts file to a the list of treatment / reference conditions to compare
Channel
.fromPath(params.contrasts)
.splitCsv(header:true, sep:';')
.map { line -> [
id: "${line.treatment.replace(",", "_")}_vs_${line.reference.replace(",", "_")}",
treatment: line.treatment.split(','),
reference: line.reference.split(',')
treatment: line.treatment,
reference: line.reference
]
}
.set { ch_contrasts } // maps [id: "...", treatment: [cond1, ...], reference: [cond2, ...]]

// Map each contrast to the corresponding sample ids for treatment and reference, and then combine with the count table
ch_contrasts
.combine(ch_samplesheet_conditions.collect(flat: false).map{ it -> [it] }) // combine each contrast element with a single-element list containing all (condition, [sample_ids]) tuples
.map { contrast_meta, all_conditions ->
def treatment_samples = all_conditions.find { it[0] in contrast_meta.treatment } // Find samples for each condition
def reference_samples = all_conditions.find { it[0] in contrast_meta.reference }
return [ id: contrast_meta.id, treatment: treatment_samples[1].join(","), reference: reference_samples[1].join(",") ]
} // emits maps: [id: "...", treatment: "sample1,sample2", reference: "sample3,sample4"]
.combine(ch_counts)
.set{ ch_contrasts_counts } // tuples (contrast_map, counts) with each contrast combined with the count table
if (params.count_table) {

// When the count table is provided, we assume that the sample IDs in the contrasts file correspond to the sample IDs in the count table
ch_contrasts
.combine(ch_counts)
.set{ ch_contrasts_counts } // tuples (contrast_map, counts) with each contrast combined with the count table

} else {

// Map each condition in the samplesheet to the list of sample ids belonging to that condition
ch_samplesheet
.map { meta, _fastq -> [meta.condition, meta] }
.groupTuple(by: 0) // Group by condition
.map { condition, metas -> [condition, metas.collect { it.id }]}
.set { ch_samplesheet_conditions } // tuples (condition, [sample_id1, sample_id2, ...])

// Map each contrast to the corresponding sample ids for treatment and reference, and then combine with the count table
ch_contrasts
.combine(ch_samplesheet_conditions.collect(flat: false).map{ it -> [it] }) // combine each contrast element with a single-element list containing all (condition, [sample_ids]) tuples
.map { contrast_meta, all_conditions ->
def treatment_samples = all_conditions.find { it[0] in contrast_meta.treatment.split(',') } // Find samples for each condition
def reference_samples = all_conditions.find { it[0] in contrast_meta.reference.split(',') }
return [ id: contrast_meta.id, treatment: treatment_samples[1].join(","), reference: reference_samples[1].join(",") ]
} // emits maps: [id: "...", treatment: "sample1,sample2", reference: "sample3,sample4"]
.combine(ch_counts)
.set{ ch_contrasts_counts } // tuples (contrast_map, counts) with each contrast combined with the count table
}
}

if (params.rra) {
Expand Down