fix: preserve '*' spanning deletion alleles at read time (#65)#104
Open
jmg421 wants to merge 1 commit into
Open
fix: preserve '*' spanning deletion alleles at read time (#65)#104jmg421 wants to merge 1 commit into
jmg421 wants to merge 1 commit into
Conversation
…r#65) VCFs containing '*' (spanning deletion) alleles are now read with a CharacterList ALT column, preserving the '*' character. Previously, .formatALT() converted '*' to an empty string to fit into DNAStringSet, but this made it impossible to write valid VCF output — IGV/htsjdk would reject files with empty alleles. The fix treats '*' as a structural/special allele (like '<DEL>'), which causes .isStructural() to return TRUE and the ALT to be stored as a CharacterList. This is semantically correct per the VCF spec: '*' represents a spanning deletion and is not a DNA sequence. For VCFs without '*' alleles, behavior is unchanged (DNAStringSetList). This supersedes the write-path-only fix in PR Bioconductor#103, which could only handle the multi-allele case. With this read-time fix, both single '*' and multi-allele '*' are correctly round-tripped. Closes Bioconductor#65
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fully fixes #65. Supersedes #103 (which only addressed the write-path).
readVcf()now preserves*(spanning deletion) alleles instead of erasing them, enabling faithful VCF round-trips for files containing spanning deletions.Problem
*in VCF ALT fields represents a spanning deletion allele (VCF spec §1.4.2). At read time,.formatALT()converted*to an empty string ("") to fit intoDNAStringSet(since*is not a valid DNA character). At write time, this empty string produced malformed VCF output likeCA,,TTAinstead ofCA,*,TTA, causing IGV/htsjdk to reject the file.Root Cause (per @hpages' analysis in the issue thread)
*is not a DNA sequence — it's a special VCF allele that cannot be stored inDNAStringSet. The package's architecture stores ALT as eitherDNAStringSetList(normal alleles) orCharacterList(structural/special alleles).*should be in the latter category.Fix
One line change: added
grepl("*", x, fixed=TRUE)to.isStructural()inAllUtilities.R. This causes VCFs containing*alleles to be stored with aCharacterListALT column (same treatment as<DEL>,], etc.), preserving the*through read/write.Also removed the now-unnecessary
flat[grepl("*", flat, fixed=TRUE)] <- ""conversion in.formatALT().Behavior Change
*alt()returnsDNAStringSetList*alt()returnsDNAStringSetListwith""for*alt()returnsCharacterListwith"*"preserved**correctly writtenThis is consistent with how structural variants (
<DEL>, breakends) are already handled —alt()is aCharacterListand the special alleles are preserved.Testing
CA,*,TTA→ read → write →CA,*,TTA✓*allele round-trips correctly*still useDNAStringSetList(no change)Agentic tooling disclosure
This PR was produced with the assistance of Kiro CLI (Amazon's AI coding agent). All changes were reviewed and verified by the author.