From d67edd40d82d04f7f824e0c65f1c821cc8ee161a Mon Sep 17 00:00:00 2001 From: Martin Hunt Date: Thu, 13 Jun 2024 17:44:45 +0100 Subject: [PATCH] Expose minos and fasta filter/mask options --- .../tasks/variant_call_one_sample.py | 7 +++ .../clockwork/var_call_one_sample_pipeline.py | 11 ++++- python/scripts/clockwork | 47 +++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/python/clockwork/tasks/variant_call_one_sample.py b/python/clockwork/tasks/variant_call_one_sample.py index 18716b0..6100909 100644 --- a/python/clockwork/tasks/variant_call_one_sample.py +++ b/python/clockwork/tasks/variant_call_one_sample.py @@ -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, ) diff --git a/python/clockwork/var_call_one_sample_pipeline.py b/python/clockwork/var_call_one_sample_pipeline.py index c0123c6..1e1a0f2 100644 --- a/python/clockwork/var_call_one_sample_pipeline.py +++ b/python/clockwork/var_call_one_sample_pipeline.py @@ -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( @@ -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: @@ -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) diff --git a/python/scripts/clockwork b/python/scripts/clockwork index 4130fd8..f7017b0 100755 --- a/python/scripts/clockwork +++ b/python/scripts/clockwork @@ -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" )