Skip to content

Commit

Permalink
Rename the threshold variables [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
abhi18av committed Jul 8, 2024
1 parent cac19d9 commit 2be9944
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion bin/fastq_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
if m:
mapped_p = float(m[1])

if int(wgsmetrics.loc[0, 'MEDIAN_COVERAGE']) >= args['median_coverage_cutoff']:
if int(wgsmetrics.loc[0, 'MEDIAN_COVERAGE']) >= args['cutoff_median_coverage']:
coverage_threshold_met = 1
else:
coverage_threshold_met = 0
Expand Down
14 changes: 7 additions & 7 deletions bin/sample_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
parser.add_argument('--wgsmetrics_file', dest='wgsmetrics_file', required=True, metavar='wgsmetrics_file', type=str, help='The WGS metrics file')
parser.add_argument('--ntmfraction_file', dest='ntmfraction_file', required=True, metavar='ntmfraction_file', type=str, help='The NTM fraction file')

parser.add_argument('--median_coverage_cutoff', metavar='median_coverage_cutoff', default=10, type=float, help='The median coverage cutoff threshold')
parser.add_argument('--breadth_of_coverage_cutoff', metavar='breadth_of_coverage_cutoff', default=0.9, type=float, help='The breadth of coverage cutoff threshold')
parser.add_argument('--ntm_fraction_cutoff', metavar='ntm_fraction_cutoff', default=0.2, type=float, help='The NTM fraction cutoff threshold')
parser.add_argument('--cutoff_median_coverage', metavar='cutoff_median_coverage', default=10, type=float, help='The median coverage cutoff threshold')
parser.add_argument('--cutoff_breadth_of_coverage', metavar='cutoff_breadth_of_coverage', default=0.9, type=float, help='The breadth of coverage cutoff threshold')
parser.add_argument('--cutoff_ntm_fraction', metavar='cutoff_ntm_fraction', default=0.2, type=float, help='The NTM fraction cutoff threshold')

## NOTE: This is computed by the multiple_infection_filter script
# parser.add_argument('--rel_abundance_cutoff', metavar='rel_abundance_cutoff', default=0.8, type=float, help='The relative abundance cutoff threshold')
# parser.add_argument('--cutoff_rel_abundance', metavar='cutoff_rel_abundance', default=0.8, type=float, help='The relative abundance cutoff threshold')

args = vars(parser.parse_args())

Expand All @@ -46,17 +46,17 @@
if m:
mapped_p = float(m[1])

if int(wgsmetrics.loc[0, 'MEDIAN_COVERAGE']) >= args['median_coverage_cutoff']:
if int(wgsmetrics.loc[0, 'MEDIAN_COVERAGE']) >= args['cutoff_median_coverage']:
coverage_threshold_met = 1
else:
coverage_threshold_met = 0

if float(wgsmetrics.loc[0, 'PCT_1X']) >= args['breadth_of_coverage_cutoff']:
if float(wgsmetrics.loc[0, 'PCT_1X']) >= args['cutoff_breadth_of_coverage']:
breadth_of_coverage_threshold_met = 1
else:
breadth_of_coverage_threshold_met = 0

if ntm_fraction <= args['ntm_fraction_cutoff']:
if ntm_fraction <= args['cutoff_ntm_fraction']:
ntm_fraction_threshold_met = 1
else:
ntm_fraction_threshold_met = 0
Expand Down
4 changes: 2 additions & 2 deletions bin/variant_table_to_fasta.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def main(args):
for idx, l in enumerate(table_file):
l = l.strip().split('\t')
l = [i.replace('*', '-').replace('.', '-') for i in l]
if l.count('-')/len(l) < (1-args.site_representation_cutoff):
if l.count('-')/len(l) < (1-args.cutoff_site_representation):
table.append(l)
else:
pass
Expand All @@ -24,7 +24,7 @@ def main(args):
parser = argparse.ArgumentParser(description='tbprofiler script',formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('table', type=str, help='The input table to convert (stdin if empty)')
parser.add_argument('output_fasta', type=str, help='The output fasta file')
parser.add_argument('site_representation_cutoff', type=float, help='Minimum fraction of samples that need to have a call at a site before it is considered')
parser.add_argument('cutoff_site_representation', type=float, help='Minimum fraction of samples that need to have a call at a site before it is considered')
parser.set_defaults(func=main)
args = parser.parse_args()
args.func(args)
12 changes: 6 additions & 6 deletions default_params.config
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ ref_gvcf_tbi = "${projectDir}/resources/ref_gvcfs/LineagesAndOutgroupV2.g.vcf.g
// ##### QC THRESHOLDS #####

//The median coverage required to process the sample
median_coverage_cutoff = 10
cutoff_median_coverage = 10

//The breadth of coverage required to process the sample
breadth_of_coverage_cutoff = 0.90
cutoff_breadth_of_coverage = 0.90

//The relative abundunce of the majority strain required to process the sample
rel_abundance_cutoff = 0.80
cutoff_rel_abundance = 0.80

//The maximum fraction of NTM DNA allowed to process the sample
ntm_fraction_cutoff = 0.20
cutoff_ntm_fraction = 0.20

// The minimum fraction of samples that need to have a call at a site before the site is considered in phylogeny
site_representation_cutoff = 0.95
cutoff_site_representation = 0.95


// p-value below which binominal strand bias is considered significant
strand_bias_cutoff = 0.05
cutoff_strand_bias = 0.05

// ##### Partial workflows #####

Expand Down
2 changes: 1 addition & 1 deletion modules/gatk/variants_to_table.nf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ process GATK_VARIANTS_TO_TABLE {
variant_table_to_fasta.py !{joint_name}.!{prefix}.table \
!{joint_name}.!{prefix}.fa \
!{params.site_representation_cutoff}
!{params.cutoff_site_representation}
'''

stub:
Expand Down
2 changes: 1 addition & 1 deletion modules/utils/multiple_infection_filter.nf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ process UTILS_MULTIPLE_INFECTION_FILTER {
script:

"""
multiple_infection_filter.py per_sample_results ${params.rel_abundance_cutoff}
multiple_infection_filter.py per_sample_results ${params.cutoff_rel_abundance}
"""

stub:
Expand Down
2 changes: 1 addition & 1 deletion modules/utils/reformat_lofreq.nf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ process UTILS_REFORMAT_LOFREQ {
${sampleName}.lofreq.reformat.vcf
reduce_strand_bias.py \\
${params.strand_bias_cutoff} \\
${params.cutoff_strand_bias} \\
${sampleName}.lofreq.reformat.vcf \\
${sampleName}.lofreq.reformat.corrected.vcf
"""
Expand Down
6 changes: 3 additions & 3 deletions modules/utils/sample_stats.nf
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ process UTILS_SAMPLE_STATS {
--samtoolsstats_file ${samtoolsStats} \\
--wgsmetrics_file ${wgsMetrics} \\
--ntmfraction_file ${ntmFraction} \\
--median_coverage_cutoff ${params.median_coverage_cutoff} \\
--breadth_of_coverage_cutoff ${params.breadth_of_coverage_cutoff} \\
--ntm_fraction_cutoff ${params.ntm_fraction_cutoff}
--cutoff_median_coverage ${params.cutoff_median_coverage} \\
--cutoff_breadth_of_coverage ${params.cutoff_breadth_of_coverage} \\
--cutoff_ntm_fraction ${params.cutoff_ntm_fraction}
"""

}
10 changes: 5 additions & 5 deletions params/params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ vcf_name : "joint"
# ##### QC THRESHOLDS #####

#The median coverage required to process the sample
median_coverage_cutoff : 10
cutoff_median_coverage : 10

#The breadth of coverage required to process the sample
breadth_of_coverage_cutoff : 0.90
cutoff_breadth_of_coverage : 0.90

#The relative abundunce of the majority strain required to process the sample
rel_abundance_cutoff : 0.80
cutoff_rel_abundance : 0.80

#The maximum fraction of NTM DNA allowed to process the sample
ntm_fraction_cutoff : 0.20
cutoff_ntm_fraction : 0.20

# The minimum fraction of samples that need to have a call at a site before the site is considered in phylogeny
site_representation_cutoff : 0.95
cutoff_site_representation : 0.95


# ##### Partial workflows #####
Expand Down

0 comments on commit 2be9944

Please sign in to comment.