Skip to content

Allow users to skip updating aggregate stats when deleting samples#880

Open
alancleary wants to merge 6 commits intomainfrom
alancleary/delete-samples-skip-aggregate-stats
Open

Allow users to skip updating aggregate stats when deleting samples#880
alancleary wants to merge 6 commits intomainfrom
alancleary/delete-samples-skip-aggregate-stats

Conversation

@alancleary
Copy link
Copy Markdown
Member

Currently the delete samples code path is quite slow because all of the records for the samples being deleted need to be scanned so that the allele count and variant stats arrays can be updated. This PR adds a --skip-aggregate-stats flag to the delete CLI command and a skip_aggregate_stats parameter to Dataset.delete_samples() in the Python API to allow users to skip updating the allele count and variant stats arrays when deleting samples.

On a test dataset containing records from 50 VCFs, using this feature when deleting 2 samples changed the run-time from 22 minutes to less then 1 second.

…s classes

This can be used to note that the allele count and variant stats arrays weren't updated when a sample was deleted from the dataset. It notes this by adding the sample to the arrays' "skipped_delete_samples" metadata field, which can be used to update the stats at a later time as long as the dataset hasn't been consolidated and vacuumed.
…mples()

When this boolean is true, the skip_delete_sample() static method of the AlleleCount and VariantStats classes is called for each sample being deleted, instead of updating these stats arrays using the DeleteExporter.
…parameter

This parameter is passed to TileDBVCFDataset::delete_samples() when Writer::delete_samples() is called. A unit test was added to test the skip aggregate stats functionality in the TileDBVCFDataset class via the Writer class's skip_aggregate_stats ingestion parameter.
This allows users to use the skip aggregate stats functionality now available via the TileDBVCFDataset and Writer classes. CLI tests were added to cover this new flag.
This allows the Writer's skip_aggregate_stats ingestion parameter to be set via the C API.
… the Python API

This uses the tiledb_vcf_writer_set_skip_aggregate_stats hook in the C API to skip updating allele count and variant stats when deleting samples. Python tests were added to cover this new parameter.
@leipzig
Copy link
Copy Markdown
Member

leipzig commented Apr 1, 2026

can we make sure "double deletions" don't have unintended consequences, the second one should fail

Copy link
Copy Markdown

@spirpinias spirpinias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work, Alan. Much appreciate the haste!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants