Skip to content

Commit 814f95a

Browse files
authored
Merge pull request #195 from nf-core/194-add-blacklist-support
Add support for blacklist files
2 parents f02473e + 77a5652 commit 814f95a

File tree

9 files changed

+65
-57
lines changed

9 files changed

+65
-57
lines changed

conf/igenomes_ignored.config

Lines changed: 0 additions & 9 deletions
This file was deleted.

conf/modules.config

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,17 @@ process {
524524
]
525525
}
526526

527+
withName: BLACKLIST {
528+
ext.args = { "-v" }
529+
ext.prefix = { "${meta.id}_${meta.tool}" }
530+
ext.suffix = "blacklist.bed"
531+
publishDir = [
532+
path: { "${params.outdir}/3_bsj_detection/tools/${meta.tool}/blacklist" },
533+
mode: params.publish_dir_mode,
534+
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
535+
]
536+
}
537+
527538
withName: FILTER_BSJS {
528539
ext.args = { "-v FS='\\t' -v OFS='\\t' '{ if (\$5 >= ${params.bsj_reads}) { print } }'" }
529540
ext.suffix = { "${meta.tool}.filtered.bed" }

conf/test_igenomes.config

Lines changed: 0 additions & 27 deletions
This file was deleted.

main.nf

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ include { getGenomeAttribute } from './subworkflows/local/utils_nfcore_circ
2727
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2828
*/
2929

30-
params.fasta = getGenomeAttribute('fasta')
31-
params.gtf = getGenomeAttribute('gtf')
32-
params.bwa = getGenomeAttribute('bwa')
33-
params.star = getGenomeAttribute('star')
34-
params.bowtie = getGenomeAttribute('bowtie')
35-
params.bowtie2 = getGenomeAttribute('bowtie2')
36-
params.mature = getGenomeAttribute('mature')
30+
params.fasta = getGenomeAttribute('fasta')
31+
params.gtf = getGenomeAttribute('gtf')
32+
params.bwa = getGenomeAttribute('bwa')
33+
params.star = getGenomeAttribute('star')
34+
params.bowtie = getGenomeAttribute('bowtie')
35+
params.bowtie2 = getGenomeAttribute('bowtie2')
36+
params.mature = getGenomeAttribute('mature')
37+
params.blacklist = getGenomeAttribute('blacklist')
3738
/*
3839
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3940
RUN MAIN WORKFLOW
@@ -95,6 +96,7 @@ workflow NFCORE_CIRCRNA {
9596
//
9697
ch_fasta = Channel.value([[id: "fasta"], file(params.fasta, checkIfExists: true)])
9798
ch_gtf = Channel.value([[id: "gtf"], file(params.gtf, checkIfExists: true)])
99+
ch_blacklist = params.blacklist ? Channel.value(file(params.blacklist, checkIfExists: true)) : Channel.empty()
98100
ch_mature = params.mature ? Channel.value([[id: "mature"], file(params.mature, checkIfExists: true)]) : Channel.empty()
99101
ch_phenotype = params.phenotype ? Channel.value([[id: "phenotype"], file(params.phenotype, checkIfExists: true)]) : Channel.empty()
100102
ch_annotation = params.annotation
@@ -109,6 +111,7 @@ workflow NFCORE_CIRCRNA {
109111
ch_phenotype,
110112
ch_fasta,
111113
ch_gtf,
114+
ch_blacklist,
112115
ch_mature,
113116
ch_annotation,
114117
ch_versions,

modules/local/combinebeds/filter/templates/filter.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,31 @@ def format_yaml_like(data: dict, indent: int = 0) -> str:
2828
yaml_str += f"{spaces}{key}: {value}\\n"
2929
return yaml_str
3030

31+
# Versions
32+
33+
versions = {
34+
"${task.process}": {
35+
"python": platform.python_version(),
36+
"polars": pl.__version__,
37+
"upsetplot": upsetplot.__version__,
38+
"matplotlib": matplotlib.__version__
39+
}
40+
}
41+
42+
with open("versions.yml", "w") as f:
43+
f.write(format_yaml_like(versions))
44+
45+
# Parameters
46+
3147
max_shift = int("${max_shift}")
3248
consider_strand = "${consider_strand}" == "true"
3349
min_tools = int("${min_tools}")
3450
min_samples = int("${min_samples}")
3551
meta_id = "${meta.id}"
3652
prefix = "${prefix}"
3753

54+
# Logic
55+
3856
df = pl.scan_csv("*.bed",
3957
separator="\\t",
4058
has_header=False,
@@ -67,8 +85,13 @@ def format_yaml_like(data: dict, indent: int = 0) -> str:
6785
df_filtered = df_aggregated[(df_aggregated["n_tools"] >= min_tools) & (df_aggregated["n_samples"] >= min_samples)]
6886
df_filtered = df_filtered[["chr", "start", "end", "name", "score", "strand"]]
6987

88+
if len(df_filtered) == 0:
89+
exit(0)
90+
7091
df_filtered.to_csv("${prefix}.${suffix}", sep="\\t", header=False, index=False)
7192

93+
# Plots
94+
7295
for col in ["samples", "tools"]:
7396
series = df_aggregated[col]
7497
if series.explode().nunique() <= 1:
@@ -100,17 +123,3 @@ def format_yaml_like(data: dict, indent: int = 0) -> str:
100123

101124
with open(f"{prefix}_{col}.upset_mqc.json", "w") as f:
102125
f.write(json.dumps(multiqc, indent=4))
103-
104-
# Versions
105-
106-
versions = {
107-
"${task.process}": {
108-
"python": platform.python_version(),
109-
"polars": pl.__version__,
110-
"upsetplot": upsetplot.__version__,
111-
"matplotlib": matplotlib.__version__
112-
}
113-
}
114-
115-
with open("versions.yml", "w") as f:
116-
f.write(format_yaml_like(versions))

nextflow.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ params {
4141
genome = null
4242
igenomes_base = 's3://ngi-igenomes/igenomes/'
4343
igenomes_ignore = false
44+
blacklist = null
4445
bowtie = null
4546
bowtie2 = null
4647
bwa = null

nextflow_schema.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,16 @@
319319
"help_text": "This parameter is *mandatory* if `--genome` is not specified. Needs to contain the following attributes: `gene_id`, `transcript_id` and `gene_name`.",
320320
"pattern": "\\.gtf$"
321321
},
322+
"blacklist": {
323+
"type": "string",
324+
"fa_icon": "fas fa-ban",
325+
"format": "file-path",
326+
"exists": true,
327+
"mimetype": "text/plain",
328+
"pattern": "^\\S+\\.bed$",
329+
"description": "Path to blacklist bed file.",
330+
"default": null
331+
},
322332
"mature": {
323333
"type": "string",
324334
"description": "Path to FASTA file with mature miRNAs. This parameter needs to be specified to perform miRNA interaction analyses.",

subworkflows/local/bsj_detection.nf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ include { GAWK as EXTRACT_COUNTS } from '../../modul
33
include { CSVTK_JOIN as COMBINE_COUNTS_PER_TOOL } from '../../modules/nf-core/csvtk/join'
44
include { GAWK as FILTER_BSJS } from '../../modules/nf-core/gawk'
55
include { GAWK as BED_ADD_SAMPLE_TOOL } from '../../modules/nf-core/gawk'
6+
include { BEDTOOLS_INTERSECT as BLACKLIST } from '../../modules/nf-core/bedtools/intersect'
67
include { COMBINEBEDS_READS } from '../../modules/local/combinebeds/reads'
78
include { COMBINEBEDS_FILTER as COMBINE_TOOLS_PER_SAMPLE } from '../../modules/local/combinebeds/filter'
89
include { COMBINEBEDS_SHIFTS as INVESTIGATE_SHIFTS } from '../../modules/local/combinebeds/shifts'
@@ -28,6 +29,7 @@ workflow BSJ_DETECTION {
2829
reads
2930
ch_fasta
3031
ch_gtf
32+
ch_blacklist
3133
ch_annotation
3234
bowtie_index
3335
bowtie2_index
@@ -109,6 +111,12 @@ workflow BSJ_DETECTION {
109111
ch_bsj_bed_per_sample_tool = ch_bsj_bed_per_sample_tool
110112
.filter{ _meta, bed -> !bed.isEmpty() }
111113

114+
if (params.blacklist) {
115+
BLACKLIST( ch_bsj_bed_per_sample_tool.combine(ch_blacklist), [[], []] )
116+
ch_versions = ch_versions.mix(BLACKLIST.out.versions)
117+
ch_bsj_bed_per_sample_tool = BLACKLIST.out.intersect
118+
}
119+
112120
//
113121
// Analyze read-level agreement
114122
//

workflows/circrna/main.nf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ workflow CIRCRNA {
3939
ch_phenotype
4040
ch_fasta
4141
ch_gtf
42+
ch_blacklist
4243
ch_mature
4344
ch_annotation
4445
ch_versions
@@ -108,6 +109,7 @@ workflow CIRCRNA {
108109
FASTQC_TRIMGALORE.out.reads,
109110
ch_fasta,
110111
ch_gtf,
112+
ch_blacklist,
111113
ch_annotation,
112114
bowtie_index,
113115
bowtie2_index,

0 commit comments

Comments
 (0)