Skip to content

Commit

Permalink
Merge pull request #124 from martinghunt/expose_filter_opts
Browse files Browse the repository at this point in the history
Expose filter opts
  • Loading branch information
martinghunt authored Jun 13, 2024
2 parents 589c2a4 + d67edd4 commit 70874d1
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 3 deletions.
7 changes: 7 additions & 0 deletions python/clockwork/tasks/variant_call_one_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,11 @@ def run(options):
debug=options.debug,
keep_bam=options.keep_bam,
trim_reads=not options.no_trim,
minos_filter_min_dp=options.filter_min_dp,
minos_filter_min_frs=options.filter_min_frs,
minos_filter_min_gcp=options.filter_min_gcp,
minos_filter_max_dp=options.filter_max_dp,
gvcf_to_fasta_ignore_minos_pass=options.fasta_allow_minos_filter_fail,
gvcf_to_fasta_min_frs=options.fasta_min_frs,
gvcf_to_fasta_min_dp=options.fasta_min_dp,
)
11 changes: 9 additions & 2 deletions python/clockwork/var_call_one_sample_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ def run(
debug=False,
keep_bam=False,
trim_reads=True,
minos_filter_min_dp=2,
minos_filter_min_frs=0.9,
minos_filter_min_gcp=0.5,
minos_filter_max_dp=3.0,
gvcf_to_fasta_ignore_minos_pass=False,
gvcf_to_fasta_min_frs=0.9,
gvcf_to_fasta_min_dp=2,
):
if len(reads1_list) != len(reads2_list):
raise Exception(
Expand Down Expand Up @@ -153,7 +160,7 @@ def run(
minos_vcf_has_vars = False
else:
minos_dir = os.path.join(outdir, "minos")
cmd = f"minos adjudicate --reads {rmdup_bam} {minos_dir} {refdir.ref_fasta} {samtools_vcf} {cortex_vcf}"
cmd = f"minos adjudicate --filter_min_dp {minos_filter_min_dp} --filter_min_frs {minos_filter_min_frs} --filter_min_gcp {minos_filter_min_gcp} --filter_max_dp {minos_filter_max_dp} --reads {rmdup_bam} {minos_dir} {refdir.ref_fasta} {samtools_vcf} {cortex_vcf}"
utils.syscall(cmd)
os.rename(os.path.join(minos_dir, "final.vcf"), final_vcf)
if not debug:
Expand All @@ -165,7 +172,7 @@ def run(
)
if not debug:
os.unlink(samtools_gvcf)
gvcf.gvcf_to_fasta(final_gvcf, f"{final_gvcf}.fasta")
gvcf.gvcf_to_fasta(final_gvcf, f"{final_gvcf}.fasta", require_minos_pass=gvcf_to_fasta_ignore_minos_pass, min_frs=gvcf_to_fasta_min_frs, min_dp=gvcf_to_fasta_min_dp)

if not (keep_bam or debug):
os.unlink(rmdup_bam)
Expand Down
47 changes: 47 additions & 0 deletions python/scripts/clockwork
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,53 @@ subparser_variant_call_one_sample.add_argument(
action="store_true",
help="Skip read trimming stage at start of pipeline",
)
subparser_variant_call_one_sample.add_argument(
"--filter_min_dp",
type=int,
default=2,
help="Minimum depth filter cutoff (same as minos option --filter_min_dp) in final VCF file [%(default)s]",
metavar="INT",
)
subparser_variant_call_one_sample.add_argument(
"--filter_min_frs",
type=float,
default=0.9,
help="Minimum FRS filter cutoff (same as minos option --filter_min_frs) in final VCF file [%(default)s]",
metavar="FLOAT",
)
subparser_variant_call_one_sample.add_argument(
"--filter_min_gcp",
type=float,
default=0.5,
help="Minimum GCP filter cutoff (same as minos option --filter_min_gcp) in final VCF file [%(default)s]",
metavar="FLOAT",
)
subparser_variant_call_one_sample.add_argument(
"--filter_max_dp",
type=float,
default=3.0,
help="Determines maximum depth filter cutoff (same as minos option --filter_max_dp) in final VCF file. Using a value of 'x' here sets the cutoff to be more than x standard deviations from the mean read depth [%(default)s]",
metavar="FLOAT",
)
subparser_variant_call_one_sample.add_argument(
"--fasta_allow_minos_filter_fail",
action="store_true",
help="When making consensus fasta, ignore whether or not PASS is in the FILTER column of minos calls. Default is to put an N whenever there is a filter fail",
)
subparser_variant_call_one_sample.add_argument(
"--fasta_min_frs",
type=float,
help="When making consensus fasta, minimum fraction of reads (FRS) required supporting the call. If FRS is less than the given value, then N is added to the FASTA [%(default)s]",
default=0.9,
metavar="FLOAT",
)
subparser_variant_call_one_sample.add_argument(
"--fasta_min_dp",
type=int,
help="When making consensus fasta, minimum total read depth. If depth is less than this, then N is added to the FASTA [%(default)s]",
default=2,
metavar="INT",
)
subparser_variant_call_one_sample.add_argument(
"ref_dir", help="Directory of reference files, made by clockwork reference_prepare"
)
Expand Down
2 changes: 1 addition & 1 deletion scripts/install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,4 @@ pip3 install .

#________________________ minos _____________________________#
pip3 install 'cluster_vcf_records==0.13.3'
pip3 install git+https://github.com/iqbal-lab-org/minos@v0.12.5
pip3 install git+https://github.com/iqbal-lab-org/minos@v0.12.6

0 comments on commit 70874d1

Please sign in to comment.