feat: Add VCF export support for SNP call datasets (GH-1054)#1197
Open
khushthecoder wants to merge 7 commits intomalariagen:masterfrom
Open
feat: Add VCF export support for SNP call datasets (GH-1054)#1197khushthecoder wants to merge 7 commits intomalariagen:masterfrom
khushthecoder wants to merge 7 commits intomalariagen:masterfrom
Conversation
Adds a VcfConverter mixin following the existing PlinkConverter pattern: - New VcfConverter class in malariagen_data/anoph/to_vcf.py with snp_calls_to_vcf() method for exporting SNP calls to VCF format - Streams data in chunks to keep memory usage low on large datasets - Explicitly decodes byte-backed allele values to prevent artifacts - Uses snp_calls() as data source to preserve multiallelic sites - Integrated into AnophelesDataResource via MRO - Tests follow the test_plink_converter pattern Closes malariagen#1054
variant_contig stores integer indices (dtype u1), not string names. The check 'contig_chunk.dtype.kind == "S"' was never true, so CHROM values were written as '0', '1', '2' instead of actual contig names like '2R', '2L', '3R'. Fix: Use ds.attrs['contigs'] to map integer indices to contig names, following the established pattern in snp_frq.py and aim_data.py. Also: - Add ##contig header lines for VCF spec compliance - Update test to verify CHROM values match actual contig names
Contributor
Author
|
@jonbrenas — All checks, including the recent pre-commit / ruff-format linting steps, are now passing perfectly. The codebase correctly handles byte- decoding without native dependencies and handles chunk-streaming with minimal memory overhead, thoroughly validated by the new tests. Could you please take a look when you have a moment? Let me know if you need any final tweaks. |
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.
Fix: #1054 — SNP calls to VCF export
Summary
Adds support for exporting SNP call datasets to Variant Call Format (VCF), enabling interoperability with common genomics tools and workflows such as
bcftools,GATK, and R pipelines.Changes
VcfConvertermixin following the existingPlinkConverterpatternsnp_calls_to_vcf()to export SNP calls directly to.vcfformatb'A'-style artifacts in the outputsnp_calls()as the data source so that multiallelic sites are preserved (standard for VCF)AnophelesDataResourcevia the existing cooperative MROvcf_params.pyfollowing theplink_params.pypattern for type-annotated parameterstest_plink_converterpattern to verify output structure, header correctness, sample ID matching, variant positions, and overwrite behaviorFiles Changed
malariagen_data/anoph/to_vcf.pyVcfConvertermixin withsnp_calls_to_vcf()malariagen_data/anoph/vcf_params.pymalariagen_data/anopheles.pyVcfConvertertests/anoph/test_vcf_converter.pyNotes
overwriteparameter controls whether existing output files are regenerated or reused