Skip to content
Merged
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
9 changes: 0 additions & 9 deletions conf/igenomes_ignored.config

This file was deleted.

11 changes: 11 additions & 0 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,17 @@ process {
]
}

withName: BLACKLIST {
ext.args = { "-v" }
ext.prefix = { "${meta.id}_${meta.tool}" }
ext.suffix = "blacklist.bed"
publishDir = [
path: { "${params.outdir}/3_bsj_detection/tools/${meta.tool}/blacklist" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
]
}

withName: FILTER_BSJS {
ext.args = { "-v FS='\\t' -v OFS='\\t' '{ if (\$5 >= ${params.bsj_reads}) { print } }'" }
ext.suffix = { "${meta.tool}.filtered.bed" }
Expand Down
27 changes: 0 additions & 27 deletions conf/test_igenomes.config

This file was deleted.

17 changes: 10 additions & 7 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ include { getGenomeAttribute } from './subworkflows/local/utils_nfcore_circ
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

params.fasta = getGenomeAttribute('fasta')
params.gtf = getGenomeAttribute('gtf')
params.bwa = getGenomeAttribute('bwa')
params.star = getGenomeAttribute('star')
params.bowtie = getGenomeAttribute('bowtie')
params.bowtie2 = getGenomeAttribute('bowtie2')
params.mature = getGenomeAttribute('mature')
params.fasta = getGenomeAttribute('fasta')
params.gtf = getGenomeAttribute('gtf')
params.bwa = getGenomeAttribute('bwa')
params.star = getGenomeAttribute('star')
params.bowtie = getGenomeAttribute('bowtie')
params.bowtie2 = getGenomeAttribute('bowtie2')
params.mature = getGenomeAttribute('mature')
params.blacklist = getGenomeAttribute('blacklist')
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RUN MAIN WORKFLOW
Expand Down Expand Up @@ -95,6 +96,7 @@ workflow NFCORE_CIRCRNA {
//
ch_fasta = Channel.value([[id: "fasta"], file(params.fasta, checkIfExists: true)])
ch_gtf = Channel.value([[id: "gtf"], file(params.gtf, checkIfExists: true)])
ch_blacklist = params.blacklist ? Channel.value(file(params.blacklist, checkIfExists: true)) : Channel.empty()
ch_mature = params.mature ? Channel.value([[id: "mature"], file(params.mature, checkIfExists: true)]) : Channel.empty()
ch_phenotype = params.phenotype ? Channel.value([[id: "phenotype"], file(params.phenotype, checkIfExists: true)]) : Channel.empty()
ch_annotation = params.annotation
Expand All @@ -109,6 +111,7 @@ workflow NFCORE_CIRCRNA {
ch_phenotype,
ch_fasta,
ch_gtf,
ch_blacklist,
ch_mature,
ch_annotation,
ch_versions,
Expand Down
37 changes: 23 additions & 14 deletions modules/local/combinebeds/filter/templates/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,31 @@ def format_yaml_like(data: dict, indent: int = 0) -> str:
yaml_str += f"{spaces}{key}: {value}\\n"
return yaml_str

# Versions

versions = {
"${task.process}": {
"python": platform.python_version(),
"polars": pl.__version__,
"upsetplot": upsetplot.__version__,
"matplotlib": matplotlib.__version__
}
}

with open("versions.yml", "w") as f:
f.write(format_yaml_like(versions))

# Parameters

max_shift = int("${max_shift}")
consider_strand = "${consider_strand}" == "true"
min_tools = int("${min_tools}")
min_samples = int("${min_samples}")
meta_id = "${meta.id}"
prefix = "${prefix}"

# Logic

df = pl.scan_csv("*.bed",
separator="\\t",
has_header=False,
Expand Down Expand Up @@ -67,8 +85,13 @@ def format_yaml_like(data: dict, indent: int = 0) -> str:
df_filtered = df_aggregated[(df_aggregated["n_tools"] >= min_tools) & (df_aggregated["n_samples"] >= min_samples)]
df_filtered = df_filtered[["chr", "start", "end", "name", "score", "strand"]]

if len(df_filtered) == 0:
exit(0)

df_filtered.to_csv("${prefix}.${suffix}", sep="\\t", header=False, index=False)

# Plots

for col in ["samples", "tools"]:
series = df_aggregated[col]
if series.explode().nunique() <= 1:
Expand Down Expand Up @@ -100,17 +123,3 @@ def format_yaml_like(data: dict, indent: int = 0) -> str:

with open(f"{prefix}_{col}.upset_mqc.json", "w") as f:
f.write(json.dumps(multiqc, indent=4))

# Versions

versions = {
"${task.process}": {
"python": platform.python_version(),
"polars": pl.__version__,
"upsetplot": upsetplot.__version__,
"matplotlib": matplotlib.__version__
}
}

with open("versions.yml", "w") as f:
f.write(format_yaml_like(versions))
1 change: 1 addition & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ params {
genome = null
igenomes_base = 's3://ngi-igenomes/igenomes/'
igenomes_ignore = false
blacklist = null
bowtie = null
bowtie2 = null
bwa = null
Expand Down
10 changes: 10 additions & 0 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,16 @@
"help_text": "This parameter is *mandatory* if `--genome` is not specified. Needs to contain the following attributes: `gene_id`, `transcript_id` and `gene_name`.",
"pattern": "\\.gtf$"
},
"blacklist": {
"type": "string",
"fa_icon": "fas fa-ban",
"format": "file-path",
"exists": true,
"mimetype": "text/plain",
"pattern": "^\\S+\\.bed$",
"description": "Path to blacklist bed file.",
"default": null
},
"mature": {
"type": "string",
"description": "Path to FASTA file with mature miRNAs. This parameter needs to be specified to perform miRNA interaction analyses.",
Expand Down
8 changes: 8 additions & 0 deletions subworkflows/local/bsj_detection.nf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include { GAWK as EXTRACT_COUNTS } from '../../modul
include { CSVTK_JOIN as COMBINE_COUNTS_PER_TOOL } from '../../modules/nf-core/csvtk/join'
include { GAWK as FILTER_BSJS } from '../../modules/nf-core/gawk'
include { GAWK as BED_ADD_SAMPLE_TOOL } from '../../modules/nf-core/gawk'
include { BEDTOOLS_INTERSECT as BLACKLIST } from '../../modules/nf-core/bedtools/intersect'
include { COMBINEBEDS_READS } from '../../modules/local/combinebeds/reads'
include { COMBINEBEDS_FILTER as COMBINE_TOOLS_PER_SAMPLE } from '../../modules/local/combinebeds/filter'
include { COMBINEBEDS_SHIFTS as INVESTIGATE_SHIFTS } from '../../modules/local/combinebeds/shifts'
Expand All @@ -28,6 +29,7 @@ workflow BSJ_DETECTION {
reads
ch_fasta
ch_gtf
ch_blacklist
ch_annotation
bowtie_index
bowtie2_index
Expand Down Expand Up @@ -109,6 +111,12 @@ workflow BSJ_DETECTION {
ch_bsj_bed_per_sample_tool = ch_bsj_bed_per_sample_tool
.filter{ _meta, bed -> !bed.isEmpty() }

if (params.blacklist) {
BLACKLIST( ch_bsj_bed_per_sample_tool.combine(ch_blacklist), [[], []] )
ch_versions = ch_versions.mix(BLACKLIST.out.versions)
ch_bsj_bed_per_sample_tool = BLACKLIST.out.intersect
}

//
// Analyze read-level agreement
//
Expand Down
2 changes: 2 additions & 0 deletions workflows/circrna/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ workflow CIRCRNA {
ch_phenotype
ch_fasta
ch_gtf
ch_blacklist
ch_mature
ch_annotation
ch_versions
Expand Down Expand Up @@ -108,6 +109,7 @@ workflow CIRCRNA {
FASTQC_TRIMGALORE.out.reads,
ch_fasta,
ch_gtf,
ch_blacklist,
ch_annotation,
bowtie_index,
bowtie2_index,
Expand Down