From 0e5ffce2068df24aab9faffceaec1d49e279c1ff Mon Sep 17 00:00:00 2001 From: MattWellie Date: Sat, 6 Jun 2026 13:34:20 +1000 Subject: [PATCH 1/5] chrM removal on MT -> VCF export --- .../annotated_vcf_into_matrixtable.py | 6 +++++- src/talos/annotation_scripts/create_roi_from_gff3.py | 2 +- .../extract_fragmented_vcf_from_mt.py | 11 +++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py b/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py index 037a9ef5..fca46bfa 100755 --- a/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py +++ b/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py @@ -191,7 +191,11 @@ def annotate_all_transcript_consequences( mane[x.transcript]['mane_id'], MISSING_STRING, ), - gene_id=ensgs[mt.locus.contig].get(x.gene, x.gene), + gene_id=hl.if_else( + ensgs.contains(mt.locus.contig), + ensgs[mt.locus.contig].get(x.gene, x.gene), + x.gene, + ), ), mt.transcript_consequences, ), diff --git a/src/talos/annotation_scripts/create_roi_from_gff3.py b/src/talos/annotation_scripts/create_roi_from_gff3.py index 69a6d6ea..168f2c81 100755 --- a/src/talos/annotation_scripts/create_roi_from_gff3.py +++ b/src/talos/annotation_scripts/create_roi_from_gff3.py @@ -159,7 +159,7 @@ def cli_main(): parser.add_argument( '--merged_output', help='Path to output file, regions merged', - required=False, + required=True, ) parser.add_argument( '--flanking', diff --git a/src/talos/cpg_internal_scripts/extract_fragmented_vcf_from_mt.py b/src/talos/cpg_internal_scripts/extract_fragmented_vcf_from_mt.py index b39a2a01..a72d34fd 100755 --- a/src/talos/cpg_internal_scripts/extract_fragmented_vcf_from_mt.py +++ b/src/talos/cpg_internal_scripts/extract_fragmented_vcf_from_mt.py @@ -54,6 +54,8 @@ }, } +CANONICAL_CONTIGS = {f'chr{x}' for x in list(range(1, 23))} | {'chrX', 'chrY'} + def filter_mt_to_sgids( mt: hl.MatrixTable, @@ -84,6 +86,12 @@ def filter_mt_to_sgids( return mt.filter_rows(hl.agg.any(mt.GT.is_non_ref())) +def filter_mt_to_contigs(mt: hl.MatrixTable) -> hl.MatrixTable: + """Strict filter to just the non-Mito contigs.""" + contig_literal = hl.literal(CANONICAL_CONTIGS) + return mt.filter_rows(contig_literal.contains(mt.locus.contig)) + + def main( mt_path: str, sg_id_file: str, @@ -109,6 +117,9 @@ def main( # filter the MT to a specific set of SG IDs mt = filter_mt_to_sgids(mt, sg_id_file) + # filter out chrM in this context + mt = filter_mt_to_contigs(mt) + # replace the existing INFO block to just have AC/AN/AF - no other carry-over. Allow for this to be missing. if 'AF' not in mt.info: mt = hl.variant_qc(mt) From 93d3b418a34aa2dfe8d922fb1c9346d8b1f63454 Mon Sep 17 00:00:00 2001 From: MattWellie Date: Sat, 6 Jun 2026 13:38:22 +1000 Subject: [PATCH 2/5] just do this here --- src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py b/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py index fca46bfa..fe39ea25 100755 --- a/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py +++ b/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py @@ -278,6 +278,8 @@ def main( # read the VCF into a MatrixTable mt = hl.import_vcf(vcf_path, array_elements_required=False, force_bgz=True, block_size=20) + mt = mt.filter_rows(mt.locus.contig == 'chrM', keep=False) + # checkpoint locally to make everything downstream faster mt = mt.checkpoint(checkpoint or 'checkpoint.ht', overwrite=True) From 1b4355eeb4c0658f57567c3991fd0386d7826121 Mon Sep 17 00:00:00 2001 From: MattWellie Date: Sat, 6 Jun 2026 14:14:47 +1000 Subject: [PATCH 3/5] remove that bit --- src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py b/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py index fe39ea25..fca46bfa 100755 --- a/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py +++ b/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py @@ -278,8 +278,6 @@ def main( # read the VCF into a MatrixTable mt = hl.import_vcf(vcf_path, array_elements_required=False, force_bgz=True, block_size=20) - mt = mt.filter_rows(mt.locus.contig == 'chrM', keep=False) - # checkpoint locally to make everything downstream faster mt = mt.checkpoint(checkpoint or 'checkpoint.ht', overwrite=True) From c04eebd77f7f451013302841c9abe92d179a6b01 Mon Sep 17 00:00:00 2001 From: MattWellie Date: Sat, 6 Jun 2026 14:22:31 +1000 Subject: [PATCH 4/5] back in for now --- src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py b/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py index fca46bfa..fe39ea25 100755 --- a/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py +++ b/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py @@ -278,6 +278,8 @@ def main( # read the VCF into a MatrixTable mt = hl.import_vcf(vcf_path, array_elements_required=False, force_bgz=True, block_size=20) + mt = mt.filter_rows(mt.locus.contig == 'chrM', keep=False) + # checkpoint locally to make everything downstream faster mt = mt.checkpoint(checkpoint or 'checkpoint.ht', overwrite=True) From 8429ebbcd7a7c6e34c1bf6a0287b44222a0bcfc9 Mon Sep 17 00:00:00 2001 From: MattWellie Date: Sat, 6 Jun 2026 14:23:47 +1000 Subject: [PATCH 5/5] back out again --- src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py b/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py index fe39ea25..fca46bfa 100755 --- a/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py +++ b/src/talos/annotation_scripts/annotated_vcf_into_matrixtable.py @@ -278,8 +278,6 @@ def main( # read the VCF into a MatrixTable mt = hl.import_vcf(vcf_path, array_elements_required=False, force_bgz=True, block_size=20) - mt = mt.filter_rows(mt.locus.contig == 'chrM', keep=False) - # checkpoint locally to make everything downstream faster mt = mt.checkpoint(checkpoint or 'checkpoint.ht', overwrite=True)