78cdae7249c8609dcbc743e996ea7e5eec33d75a max Mon Aug 17 08:15:39 2026 -0700 lrSv: fix off-by-one anchor base in deletion coordinates across converters, refs #38099 VCF/pangenome deletions carry a non-deleted anchor (padding) base at POS. Several lrSv converters set chromStart = pos-1, which includes that anchor, so each deletion was 1 bp too wide on the left and svLen was 1 too big. Callsets handled this inconsistently, so the same deletion appeared at offset coordinates and failed to merge in lrSvAll. For deletions only (INS/INV/CPX unchanged), advance chromStart past the anchor so the interval covers exactly the deleted bases (svLen == |SVLEN|). Verified against the hg38 reference: the old left base is present in both REF and ALT (i.e. retained by the sample), so it should not be inside the deletion. Fixed 11 converters: lrSv1kLin1218VcfToBed, lrSv1kgOntVcfToBed, lrSvGustafsonVcfToBed, lrSvGa4kSvVcfToBed, lrSvDecodeVcfToBed, lrSvAou1kCsvToBed, lrSvColorsDbSvVcfToBed, lrSvCardBbToBed, lrSvAprVcfToBed, lrSvCpc1VcfToBed, lrSvVcfToBed (generic, used by han945). Left unchanged, verified already anchor-correct: hgsvc3 and hgsvc2 (0-based source), hprc2v21 (Ro converter prefix-trims), noyvert/tommoJp (POS is the first deleted base), chirmade101 (1-based-closed source). Rebuilt all affected bigBeds (hg38 + hs1 where present) and the lrSvAll merge: 3,111,026 -> 2,963,093 rows as ~148k duplicate deletions now merge. diff --git src/hg/makeDb/doc/hg38/lrSv.txt src/hg/makeDb/doc/hg38/lrSv.txt index baf01e9c450..32d0c41e267 100644 --- src/hg/makeDb/doc/hg38/lrSv.txt +++ src/hg/makeDb/doc/hg38/lrSv.txt @@ -1,18 +1,42 @@ # 2026-03-25 Claude max # Long-read structural variants supertrack + +# ------------------------------------------------------------------------- +# COORDINATE CONVENTION (deletions): a deletion's BED interval must cover +# exactly the deleted reference bases, so chromEnd - chromStart == |SVLEN|. +# A VCF/pangenome deletion is written REF="", ALT="", +# with POS = the 1-based anchor base. That anchor is present in BOTH REF and ALT +# (the sample keeps it), so it is NOT deleted. The deleted region starts at the +# base after the anchor, so chromStart = pos (0-based of pos+1), NOT pos-1. +# Using pos-1 draws the deletion 1 bp too wide on the left and inflates svLen by +# one. Insertions/inversions/complex keep the anchor position (pos-1): an +# insertion has no deleted span and its anchor is the attach point. +# +# 2026-08 Claude max: fixed a pos-1 off-by-one in the DEL branch of 11 +# converters (lrSv1kLin1218, lrSv1kgOnt, lrSvGustafson, lrSvGa4kSv, lrSvDecode, +# lrSvAou1kCsv, lrSvColorsDbSv, lrSvCard, lrSvApr, lrSvCpc1, and the generic +# lrSvVcfToBed used by han945), refs #38099. Already anchor-correct and left +# alone: hgsvc3/hgsvc2 (0-based source), hprc2v21 (Ro converter prefix-trims), +# noyvert/tommoJp (POS is the first deleted base), chirmade101 (1-based-closed +# source). Verified per record (span == |SVLEN|) and against the hg38 reference +# (the old left base equals the anchor present in REF and ALT). Rebuilt all +# affected bigBeds (hg38 + hs1 where present); the lrSvAll merge dropped from +# 3,111,026 to 2,963,093 rows as duplicate deletions merged. +# ------------------------------------------------------------------------- + # First subtrack: Han 945 - SVs from 945 Han Chinese individuals # Paper: Gong et al. 2025, Nat Commun, PMID 39929826 # Data: OMIX repository, NGDC # Download VCF mkdir -p /hive/data/genomes/hg38/bed/lrSv/han945 cd /hive/data/genomes/hg38/bed/lrSv/han945 # VCF was downloaded from OMIX (accession OED00945268) # File: OED00945268_Han_945samples_SV.vcf.gz # 111,288 SVs: 49,518 DEL, 42,300 INS, 13,503 DUP, 5,595 INV, 372 TRA # Site-only VCF (no per-sample genotypes), merged with SURVIVOR v1.0.6 # Convert VCF to BED and build bigBed python3 ~/kent/src/hg/makeDb/scripts/lrSv/lrSvVcfToBed.py \