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

Add tb grading rules bed #366

Merged
merged 5 commits into from
Nov 7, 2024
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `get_taxon` to methods
- Added `streptococcus` and `streptococcus_pyogenes` workflows and profiles to configs
- Added ska filepath to yaml
- Added optional read downsampling using seqtk.
- Added optional read downsampling using seqtk
- Added `tbGradingRulesBed` to IGV track

### Fixed

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ $(STREP_CGMLST_DIR)/alleles_rereffed: | $(STREP_CGMLST_DIR)/alleles/index.html

MTUBE_GENOMES_DIR := $(ASSETS_DIR)/genomes/mycobacterium_tuberculosis
MTUBE_TBDB_DIR := $(ASSETS_DIR)/tbdb
MTUBE_TBPROFILER_DBS_DIR := $(ASSETS_DIR)/tbprofiler_dbs
MTUBE_TB_INFO_DIR := $(ASSETS_DIR)/tb_info
MTUBE_REFSEQ_ACC := GCF_000195955.2

mtuberculosis_all: mtuberculosis_download_reference mtuberculosis_faidx_reference mtuberculosis_bwaidx_reference mtuberculosis_converged_who_fohm_tbdb mtuberculosis_bgzip_bed mtuberculosis_index_bed
Expand Down Expand Up @@ -786,10 +786,10 @@ $(MTUBE_GENOMES_DIR)/$(MTUBE_REFSEQ_ACC).fasta.bwt: $(MTUBE_GENOMES_DIR)/$(MTUBE

mtuberculosis_converged_who_fohm_tbdb: $(MTUBE_TBDB_DIR)/converged_who_fohm_tbdb.variables.json

$(MTUBE_TBDB_DIR)/converged_who_fohm_tbdb.variables.json: $(MTUBE_TBPROFILER_DBS_DIR)/converged_who_fohm_tbdb.csv
$(MTUBE_TBDB_DIR)/converged_who_fohm_tbdb.variables.json: $(MTUBE_TB_INFO_DIR)/csv/converged_who_fohm_tbdb.csv
$(call log_message,"Creating WHO FoHM TBDB ...")
cd $(MTUBE_TBDB_DIR) \
&& cp $(MTUBE_TBPROFILER_DBS_DIR)/converged_who_fohm_tbdb.csv $(MTUBE_TBDB_DIR) \
&& cp $(MTUBE_TB_INFO_DIR)/csv/converged_who_fohm_tbdb.csv $(MTUBE_TBDB_DIR) \
&& singularity exec --bind $(MNT_ROOT) $(CONTAINER_DIR)/tb-profiler.sif \
tb-profiler create_db --prefix converged_who_fohm_tbdb --dir $(MTUBE_TBDB_DIR) \
--match_ref $(MTUBE_GENOMES_DIR)/GCF_000195955.2.fasta --csv converged_who_fohm_tbdb.csv \
Expand Down
5 changes: 5 additions & 0 deletions assets/tb_info/bed/tb_grading_rules.bed
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NC_000962.3 761325 761405 RRDR rpob rifampicin
NC_000962.3 7563 7565 MFX_gyrA88 gyrA MFX
NC_000962.3 7581 7583 MFX_gyrA94 gyrA MFX
NC_000962.3 4326003 4327472 LOF_ethA ethA ethionamide
NC_000962.3 4407527 4408201 LOF_gid gid streptomycin
File renamed without changes.
4 changes: 3 additions & 1 deletion configs/nextflow.base.config
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,13 @@ profiles {
params.species = 'mycobacterium tuberculosis'
params.speciesDir = 'mtuberculosis'
params.resistantLociName = 'resistance_loci'
params.gradingLociName = 'grading_loci'
params.referenceGenome = "${params.root}/assets/genomes/mycobacterium_tuberculosis/GCF_000195955.2.fasta"
params.referenceGenomeIdx = "${params.root}/assets/genomes/mycobacterium_tuberculosis/GCF_000195955.2.fasta.fai"
params.referenceGenomeGff = "${params.root}/assets/genomes/mycobacterium_tuberculosis/GCF_000195955.2.gff"
params.coreLociBed = "${params.root}/assets/cgmlst/mycobacterium_tuberculosis/bed/GCF_000195955.2.bed"
params.tbdbBed = "${params.root}/assets/tbprofiler_dbs/bed/converged_who_fohm_tbdb.bed.gz"
params.tbGradingRulesBed = "${params.root}/assets/tb_info/bed/tb_grading_rules.bed"
params.tbdbBed = "${params.root}/assets/tbdb/converged_who_fohm_tbdb.bed.gz"
params.tbdbBedIdx = "${params.tbdbBed}.tbi"
params.targetSampleSize = null
}
Expand Down
4 changes: 3 additions & 1 deletion configs/nextflow.ci.config
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ profiles {
params.species = 'mycobacterium tuberculosis'
params.speciesDir = 'mtuberculosis'
params.resistantLociName = 'resistance_loci'
params.gradingLociName = 'grading_loci'
params.referenceGenome = "${params.root}/assets/genomes/mycobacterium_tuberculosis/GCF_000195955.2.fasta"
params.referenceGenomeIdx = "${params.root}/assets/genomes/mycobacterium_tuberculosis/GCF_000195955.2.fasta.fai"
params.referenceGenomeGff = "${params.root}/assets/genomes/mycobacterium_tuberculosis/GCF_000195955.2.gff"
params.coreLociBed = "${params.root}/assets/cgmlst/mycobacterium_tuberculosis/bed/GCF_000195955.2.bed"
params.tbdbBed = "${params.root}/assets/tbprofiler_dbs/bed/converged_who_fohm_tbdb.bed.gz"
params.tbGradingRulesBed = "${params.root}/assets/tb_info/bed/tb_grading_rules.bed"
params.tbdbBed = "${params.root}/assets/tbdb/converged_who_fohm_tbdb.bed.gz"
params.tbdbBedIdx = "${params.tbdbBed}.tbi"
params.targetSampleSize = null
}
Expand Down
4 changes: 3 additions & 1 deletion configs/nextflow.dev.config
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ profiles {
params.speciesDir = 'mtuberculosis'
params.symlinkDir = "/access/jasen/mtuberculosis/"
params.resistantLociName = 'resistance_loci'
params.gradingLociName = 'grading_loci'
params.referenceGenome = "${params.root}/assets/genomes/mycobacterium_tuberculosis/GCF_000195955.2.fasta"
params.referenceGenomeIdx = "${params.root}/assets/genomes/mycobacterium_tuberculosis/GCF_000195955.2.fasta.fai"
params.referenceGenomeGff = "${params.root}/assets/genomes/mycobacterium_tuberculosis/GCF_000195955.2.gff"
params.coreLociBed = "${params.root}/assets/cgmlst/mycobacterium_tuberculosis/bed/GCF_000195955.2.bed"
params.tbdbBed = "${params.root}/assets/tbprofiler_dbs/bed/converged_who_fohm_tbdb.bed.gz"
params.tbGradingRulesBed = "${params.root}/assets/tb_info/bed/tb_grading_rules.bed"
params.tbdbBed = "${params.root}/assets/tbdb/converged_who_fohm_tbdb.bed.gz"
params.tbdbBedIdx = "${params.tbdbBed}.tbi"
params.targetSampleSize = null
}
Expand Down
4 changes: 3 additions & 1 deletion configs/nextflow.hopper.config
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ profiles {
params.species = 'mycobacterium tuberculosis'
params.speciesDir = 'mtuberculosis'
params.resistantLociName = 'resistance_loci'
params.gradingLociName = 'grading_loci'
params.symlinkDir = "/access/jasen/mtuberculosis/"
params.referenceGenome = "${params.root}/assets/genomes/mycobacterium_tuberculosis/GCF_000195955.2.fasta"
params.referenceGenomeIdx = "${params.root}/assets/genomes/mycobacterium_tuberculosis/GCF_000195955.2.fasta.fai"
params.referenceGenomeGff = "${params.root}/assets/genomes/mycobacterium_tuberculosis/GCF_000195955.2.gff"
params.coreLociBed = "${params.root}/assets/cgmlst/mycobacterium_tuberculosis/bed/GCF_000195955.2.bed"
params.tbdbBed = "${params.root}/assets/tbprofiler_dbs/bed/converged_who_fohm_tbdb.bed.gz"
params.tbGradingRulesBed = "${params.root}/assets/tb_info/bed/tb_grading_rules.bed"
params.tbdbBed = "${params.root}/assets/tbdb/converged_who_fohm_tbdb.bed.gz"
params.tbdbBedIdx = "${params.tbdbBed}.tbi"
params.targetSampleSize = null
}
Expand Down
4 changes: 3 additions & 1 deletion configs/nextflow.ngp.config
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ profiles {
params.species = 'mycobacterium tuberculosis'
params.speciesDir = 'mtuberculosis'
params.resistantLociName = 'resistance_loci'
params.gradingLociName = 'grading_loci'
params.referenceGenome = "${params.root}/assets/genomes/mycobacterium_tuberculosis/GCF_000195955.2.fasta"
params.referenceGenomeIdx = "${params.root}/assets/genomes/mycobacterium_tuberculosis/GCF_000195955.2.fasta.fai"
params.referenceGenomeGff = "${params.root}/assets/genomes/mycobacterium_tuberculosis/GCF_000195955.2.gff"
params.coreLociBed = "${params.root}/assets/cgmlst/mycobacterium_tuberculosis/bed/GCF_000195955.2.bed"
params.tbdbBed = "${params.root}/assets/tbprofiler_dbs/bed/converged_who_fohm_tbdb.bed.gz"
params.tbGradingRulesBed = "${params.root}/assets/tb_info/bed/tb_grading_rules.bed"
params.tbdbBed = "${params.root}/assets/tbdb/converged_who_fohm_tbdb.bed.gz"
params.tbdbBedIdx = "${params.tbdbBed}.tbi"
params.targetSampleSize = null
}
Expand Down
14 changes: 7 additions & 7 deletions workflows/bacterial_base.nf
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ workflow CALL_BACTERIAL_BASE {
// Create channel for reads
ch_raw_input
.map{ row -> get_reads(row) }
.set{ ch_reads }
.set{ ch_raw_reads }

// downsample reads
seqtk_sample( ch_reads.map(row -> [row[0], row[1], params.targetSampleSize]) ).reads
.concat( ch_reads ) // add raw reads channel
seqtk_sample( ch_raw_reads.map(row -> [row[0], row[1], params.targetSampleSize]) ).reads
.concat( ch_raw_reads ) // add raw reads channel
.first() // if seqtk was not run the first row is the raw reads
.set { ch_reads } // overwrite reads channel
.set{ ch_sampled_reads } // create sampled reads channel

// reads trim and clean and recreate reads channel if the reads were trimmed
assembly_trim_clean(ch_reads.join(ch_meta)).set { ch_clean_reads_w_meta }
assembly_trim_clean(ch_sampled_reads.join(ch_meta)).set { ch_clean_reads_w_meta }
Channel.empty()
.mix( ch_reads, ch_clean_reads_w_meta ) // if samples are trimmed
.tap{ ch_reads } // overwrite reads channel
.mix( ch_sampled_reads, ch_clean_reads_w_meta ) // if samples are trimmed
.tap{ ch_reads } // create reads channel
.join( ch_meta ) // add meta info
.set{ ch_reads_w_meta } // write as temp channel

Expand Down
51 changes: 22 additions & 29 deletions workflows/mycobacterium_tuberculosis.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,24 @@ nextflow.enable.dsl=2

include { get_meta } from '../methods/get_sample_data.nf'
include { get_reads } from '../methods/get_sample_data.nf'
include { annotate_delly } from '../nextflow-modules/modules/prp/main.nf'
include { bracken } from '../nextflow-modules/modules/bracken/main.nf'
include { create_analysis_result } from '../nextflow-modules/modules/prp/main.nf'
include { add_igv_track as add_variant_igv_track} from '../nextflow-modules/modules/prp/main.nf'
include { add_igv_track as add_locus_igv_track } from '../nextflow-modules/modules/prp/main.nf'
include { create_cdm_input } from '../nextflow-modules/modules/prp/main.nf'
include { create_yaml } from '../nextflow-modules/modules/yaml/main.nf'
include { export_to_cdm } from '../nextflow-modules/modules/cmd/main.nf'
include { kraken } from '../nextflow-modules/modules/kraken/main.nf'
include { mykrobe } from '../nextflow-modules/modules/mykrobe/main.nf'
include { post_align_qc } from '../nextflow-modules/modules/prp/main.nf'
include { snippy } from '../nextflow-modules/modules/snippy/main.nf'
include { tbprofiler as tbprofiler_mergedb } from '../nextflow-modules/modules/tbprofiler/main.nf'
include { CALL_BACTERIAL_BASE } from '../workflows/bacterial_base.nf'
include { annotate_delly } from '../nextflow-modules/modules/prp/main.nf'
include { bracken } from '../nextflow-modules/modules/bracken/main.nf'
include { create_analysis_result } from '../nextflow-modules/modules/prp/main.nf'
include { add_igv_track as add_tbdb_bed_track } from '../nextflow-modules/modules/prp/main.nf'
include { add_igv_track as add_grading_bed_track } from '../nextflow-modules/modules/prp/main.nf'
include { create_cdm_input } from '../nextflow-modules/modules/prp/main.nf'
include { create_yaml } from '../nextflow-modules/modules/yaml/main.nf'
include { export_to_cdm } from '../nextflow-modules/modules/cmd/main.nf'
include { kraken } from '../nextflow-modules/modules/kraken/main.nf'
include { mykrobe } from '../nextflow-modules/modules/mykrobe/main.nf'
include { post_align_qc } from '../nextflow-modules/modules/prp/main.nf'
include { snippy } from '../nextflow-modules/modules/snippy/main.nf'
include { tbprofiler as tbprofiler_mergedb } from '../nextflow-modules/modules/tbprofiler/main.nf'
include { CALL_BACTERIAL_BASE } from '../workflows/bacterial_base.nf'

workflow CALL_MYCOBACTERIUM_TUBERCULOSIS {
// Create channel for sample metadata
Channel.fromPath(params.csv)
.splitCsv(header:true)
.tap{ ch_raw_input }
.map{ row -> get_meta(row) }
.set{ ch_meta }

// Create channel for reads
ch_raw_input
.map{ row -> get_reads(row) }
.set{ ch_reads }
// set input data
inputSamples = file(params.csv, checkIfExists: true)

// load references
referenceGenome = file(params.referenceGenome, checkIfExists: true)
Expand All @@ -41,11 +32,12 @@ workflow CALL_MYCOBACTERIUM_TUBERCULOSIS {
coreLociBed = file(params.coreLociBed, checkIfExists: true)
tbdbBed = file(params.tbdbBed, checkIfExists: true)
tbdbBedIdx = file(params.tbdbBedIdx, checkIfExists: true)
tbGradingRulesBed = file(params.tbGradingRulesBed, checkIfExists: true)

main:
ch_versions = Channel.empty()

CALL_BACTERIAL_BASE( coreLociBed, referenceGenome, referenceGenomeDir, ch_meta, ch_reads )
CALL_BACTERIAL_BASE( coreLociBed, referenceGenome, referenceGenomeDir, inputSamples )

CALL_BACTERIAL_BASE.out.assembly.set{ch_assembly}
CALL_BACTERIAL_BASE.out.reads.set{ch_reads}
Expand Down Expand Up @@ -104,10 +96,11 @@ workflow CALL_MYCOBACTERIUM_TUBERCULOSIS {
}

// Add IGV annotation tracks
add_locus_igv_track(create_analysis_result.out.json, params.tbdbBed, params.resistantLociName)
add_tbdb_bed_track(create_analysis_result.out.json, params.tbdbBed, params.resistantLociName)
add_grading_bed_track(add_tbdb_bed_track.out.json, params.tbGradingRulesBed, params.gradingLociName)

// Create yaml for uploading results to Bonsai
create_yaml(add_locus_igv_track.out.json.join(ch_sourmash).join(ch_ska), params.speciesDir)
create_yaml(add_grading_bed_track.out.json.join(ch_sourmash).join(ch_ska), params.speciesDir)

ch_quast
.join(ch_qc)
Expand All @@ -125,7 +118,7 @@ workflow CALL_MYCOBACTERIUM_TUBERCULOSIS {
ch_versions = ch_versions.mix(tbprofiler_mergedb.out.versions)

emit:
pipeline_result = add_locus_igv_track.out.json
pipeline_result = add_grading_bed_track.out.json
cdm = export_to_cdm.out.cdm
yaml = create_yaml.out.yaml
versions = ch_versions
Expand Down
Loading