-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from broadinstitute/dp-demux
demux fixes
- Loading branch information
Showing
8 changed files
with
124 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
""" | ||
This is a basic framework for depleting human and other contaminant | ||
reads from NGS data. All non-human reads should remain behind. | ||
note: the length of runtime per step is highly variable depending on | ||
the size of the input data. Eventually replace with something TANGO-based. | ||
note: runtime and memory per step can be highly variable depending on | ||
the size of the input data. | ||
""" | ||
|
||
__author__ = 'Kristian Andersen <[email protected]>, Daniel Park <[email protected]>' | ||
|
@@ -20,64 +20,6 @@ rule all_deplete: | |
sample=read_samples_file(config["samples_depletion"])), | ||
params: LSF="-N" | ||
|
||
|
||
""" | ||
rule revert_bam: | ||
input: config["dataDir"]+'/'+config["subdirs"]["source"]+'/{sample}.bam' | ||
output: config["tmpDir"]+'/'+config["subdirs"]["depletion"]+'/{sample}.raw.bam' | ||
resources: mem=3 | ||
params: LSF=config.get('LSF_queues', {}).get('short', '-W 4:00'), | ||
logid="{sample}" | ||
run: | ||
makedirs(expand("{dir}/{subdir}", | ||
dir=[config["dataDir"],config["tmpDir"]], | ||
subdir=config["subdirs"]["depletion"])) | ||
shell("{config[binDir]}/read_utils.py revert_bam_picard {input} {output} --picardOptions SORT_ORDER=queryname SANITIZE=true") | ||
|
||
rule deplete_bmtagger: | ||
''' This step depletes human reads using BMTagger | ||
This sometimes takes just over 4 hrs for highly dense lanes | ||
''' | ||
input: config["tmpDir"]+'/'+config["subdirs"]["depletion"]+'/{sample}.raw.bam' | ||
# expand("{dbdir}/{db}.{suffix}", | ||
# dbdir=config["bmTaggerDbDir"], | ||
# db=config["bmTaggerDbs_remove"], | ||
# suffix=["bitmask","srprism.idx","srprism.map"]) | ||
output: config["tmpDir"]+ '/'+config["subdirs"]["depletion"]+'/{sample}.bmtagger_depleted.bam' | ||
resources: mem=10 | ||
params: LSF=config.get('LSF_queues', {}).get('long', '-q forest'), | ||
refDbs = expand("{dbdir}/{db}", dbdir=config["bmTaggerDbDir"], db=config["bmTaggerDbs_remove"]), | ||
logid="{sample}" | ||
shell: "{config[binDir]}/taxon_filter.py deplete_bam_bmtagger {input} {params.refDbs} {output}" | ||
|
||
rule rmdup_mvicuna: | ||
''' This step removes PCR duplicate reads using M-Vicuna (our custom | ||
tool included here). | ||
Unlike Picard MarkDuplicates, M-Vicuna does not require reads to be | ||
previously aligned. | ||
''' | ||
input: config["tmpDir"]+ '/'+config["subdirs"]["depletion"]+'/{sample}.bmtagger_depleted.bam' | ||
output: config["tmpDir"]+ '/'+config["subdirs"]["depletion"]+'/{sample}.rmdup.bam' | ||
resources: mem=3 | ||
params: LSF=config.get('LSF_queues', {}).get('short', '-W 4:00'), | ||
logid="{sample}" | ||
shell: "{config[binDir]}/read_utils.py rmdup_mvicuna_bam {input} {output}" | ||
|
||
rule deplete_blastn: | ||
''' This step depletes human reads using BLASTN, which is more sensitive, | ||
but much slower than BMTagger, so we run it last. | ||
This sometimes takes just over 4 hrs for highly dense lanes. | ||
''' | ||
input: config["tmpDir"] +'/'+config["subdirs"]["depletion"]+'/{sample}.rmdup.bam' | ||
output: config["dataDir"]+'/'+config["subdirs"]["depletion"]+'/{sample}.cleaned.bam' | ||
resources: mem=15 | ||
params: LSF=config.get('LSF_queues', {}).get('long', '-q forest'), | ||
refDbs = expand("{dbdir}/{db}", dbdir=config["blastDbDir"], db=config["blastDb_remove"]), | ||
logid="{sample}" | ||
shell: "{config[binDir]}/taxon_filter.py deplete_blastn_bam {input} {params.refDbs} {output}" | ||
""" | ||
|
||
|
||
rule depletion: | ||
''' Runs a full human read depletion pipeline and removes PCR duplicates | ||
''' | ||
|
@@ -96,7 +38,7 @@ rule depletion: | |
makedirs(expand("{dir}/{subdir}", | ||
dir=[config["dataDir"],config["tmpDir"]], | ||
subdir=config["subdirs"]["depletion"])) | ||
shell("{config[binDir]}/taxon_filter.py deplete_human {input} {params.revert_bam} {output} --bmtaggerDbs {params.bmtaggerDbs} --blastDbs {params.blastDbs}") | ||
shell("{config[binDir]}/taxon_filter.py deplete_human {input} {params.revert_bam} {output} --bmtaggerDbs {params.bmtaggerDbs} --blastDbs {params.blastDbs} --JVMmemory 15g") | ||
os.unlink(params.revert_bam) | ||
|
||
rule filter_to_taxon: | ||
|
@@ -124,16 +66,15 @@ def merge_one_per_sample_inputs(wildcards): | |
if 'seqruns_demux' not in config or not os.path.isfile(config['seqruns_demux']): | ||
return config["dataDir"]+'/'+config["subdirs"]["depletion"] +'/'+ wildcards.sample + '.' + wildcards.adjective + '.bam' | ||
runs = set() | ||
for flowcell in read_samples_file(config['seqruns_demux']): | ||
for lane in read_tab_file(flowcell): | ||
for well in read_tab_file(lane['barcode_file']): | ||
if well['sample'] == wildcards.sample: | ||
if wildcards.adjective=='raw': | ||
runs.add(os.path.join(config["dataDir"], config["subdirs"]["source"], | ||
get_run_id(well) +'.'+ lane['flowcell'] +'.'+ lane['lane'] + '.bam')) | ||
else: | ||
runs.add(os.path.join(config["dataDir"], config["subdirs"]["depletion"], | ||
get_run_id(well) +'.'+ lane['flowcell'] +'.'+ lane['lane'] +'.'+ wildcards.adjective + '.bam')) | ||
for lane in read_tab_file(config['seqruns_demux']): | ||
for well in read_tab_file(lane['barcode_file']): | ||
if well['sample'] == wildcards.sample: | ||
if wildcards.adjective=='raw': | ||
runs.add(os.path.join(config["dataDir"], config["subdirs"]["source"], | ||
get_run_id(well) +'.'+ lane['flowcell'] +'.'+ lane['lane'] + '.bam')) | ||
else: | ||
runs.add(os.path.join(config["dataDir"], config["subdirs"]["depletion"], | ||
get_run_id(well) +'.'+ lane['flowcell'] +'.'+ lane['lane'] +'.'+ wildcards.adjective + '.bam')) | ||
return sorted(runs) | ||
rule merge_one_per_sample: | ||
''' All of the above depletion steps are run once per flowcell per lane per | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
snakemake==3.2.1 | ||
yappi==0.94 | ||
boltons==15.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,3 @@ | |
|
||
biopython==1.64 | ||
pysam==0.8.1 | ||
boltons==15.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters