alterlab-tiledbvcf
Store and query genomic variant data at scale with TileDB-VCF — ingest VCF/BCF into compressed TileDB arrays, add samples incrementally, run fast parallel region/sample queries, and export back to VCF. Use when managing population-genomics variant datasets that are too large for
Install
npx skills add https://github.com/AlterLab-IEU/AlterLab-Academic-Skills/tree/main/skills/bioinformatics/alterlab-tiledbvcf
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install alterlab-ieu-alterlab-academic-skills@llmmart
git clone https://github.com/AlterLab-IEU/AlterLab-Academic-Skills.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole alterlab-ieu/alterlab-academic-skills collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
TileDB-VCF
Overview
TileDB-VCF is a high-performance C++ library with Python and CLI interfaces for efficient storage and retrieval of genomic variant-call data. Built on TileDB's sparse array technology, it enables scalable ingestion of VCF/BCF files, incremental sample addition without expensive merging operations, and efficient parallel queries of variant data stored locally or in the cloud.
When to Use This Skill
This skill should be used when:
- Building a queryable, compressed variant store from many single-sample VCF/BCF files (cohort/population datasets too large for flat VCF)
- Incrementally adding new samples to an existing store without re-merging
- Querying specific genomic regions across many samples (region/sample-partitioned reads)
- Exporting region/sample subsets back to VCF/BCF for downstream tools
- Working with variant data on cloud storage (S3, Azure, GCS) or TileDB Cloud
- Prototyping or teaching scalable genomics-variant workflows
Does NOT Trigger
| Scenario | Use Instead |
|---|---|
| Reading, filtering, or iterating a handful of VCF/BAM files in Python (pysam/htslib) | alterlab-pysam |
| Producing the VCFs in the first place (FASTQ -> alignment -> variant calling) | alterlab-nf-core-sarek |
| Clinical interpretation or population frequency of a specific variant | alterlab-clinvar / alterlab-gnomad |
| General chunked array storage for non-variant data (images, tensors, matrices) | alterlab-zarr |
| Out-of-core dataframe analytics on an exported table | alterlab-polars / alterlab-dask |
Quick Start
Installation
Preferred method: conda/mamba from the tiledb channel. tiledbvcf-py is NOT on PyPI, conda-forge, or bioconda — it ships from the tiledb Anaconda channel, with native osx-arm64 builds (no Rosetta/CONDA_SUBDIR workaround needed on Apple Silicon). The current release is 0.40.3 (April 2026), built for linux-64, osx-64 and osx-arm64 on Python 3.9–3.12. There is no 3.13 build, so pin the interpreter when creating the environment — a default conda create that resolves to a newer Python will report the package as unavailable rather than explaining why.
# Native Apple Silicon (osx-arm64) — also works on osx-64 / linux-64
conda create -n tiledb-vcf -c conda-forge -c tiledb \
python=3.12 tiledbvcf-py=0.40 pandas pyarrow numpy
conda activate tiledb-vcf
Alternative: Docker images (pulls the CLI/Python interface; latest tag tracks current release)
docker pull tiledb/tiledbvcf-py # Python interface
docker pull tiledb/tiledbvcf-cli # Command-line interface
Basic Examples
Create and populate a dataset:
import tiledbvcf
# Create a new dataset
ds = tiledbvcf.Dataset(uri="my_dataset", mode="w",
cfg=tiledbvcf.ReadConfig(memory_budget_mb=1024))
# Ingest VCF files (must be single-sample with indexes)
# Requirements:
# - VCFs must be single-sample (not multi-sample)
# - Must have indexes: .csi (bcftools) or .tbi (tabix)
ds.ingest_samples(["sample1.vcf.gz", "sample2.vcf.gz"])
Query variant data:
# Open existing dataset for reading
ds = tiledbvcf.Dataset(uri="my_dataset", mode="r")
# Query specific regions and samples
df = ds.read(
attrs=["sample_name", "pos_start", "pos_end", "alleles", "fmt_GT"],
regions=["chr1:1000000-2000000", "chr2:500000-1500000"],
samples=["sample1", "sample2", "sample3"]
)
print(df.head())
Export to VCF:
import os
# Export two VCF samples
ds.export(
regions=["chr21:8220186-8405573"],
samples=["HG00101", "HG00097"],
output_format="v",
output_dir=os.path.expanduser("~"),
)
Core Capabilities
1. Dataset Creation and Ingestion
Create TileDB-VCF datasets and incrementally ingest variant data from multiple VCF/BCF files. This is appropriate for building population genomics databases and cohort studies.
Requirements:
- Single-sample VCFs only: Multi-sample VCFs are not supported
- Index files required: VCF/BCF files must have indexes (.csi or .tbi)
Common operations:
- Create new datasets with optimized array schemas
- Ingest single or multiple VCF/BCF files in parallel
- Add new samples incrementally without re-processing existing data
- Configure memory usage and compression settings
- Handle various VCF formats and INFO/FORMAT fields
- Resume interrupted ingestion processes
- Validate data integrity during ingestion
2. Efficient Querying and Filtering
Query variant data with high performance across genomic regions, samples, and variant attributes. This is appropriate for association studies, variant discovery, and population analysis.
Common operations:
- Query specific genomic regions (single or multiple)
- Filter by sample names or sample groups
- Extract specific variant attributes (position, alleles, genotypes, quality)
- Access INFO and FORMAT fields efficiently
- Combine spatial and attribute-based filtering
- Stream large query results
- Perform aggregations across samples or regions
3. Data Export and Interoperability
Export data in various formats for downstream analysis or integration with other genomics tools. This is appropriate for sharing datasets, creating analysis subsets, or feeding other pipelines.
Common operations:
- Export to standard VCF/BCF formats
- Generate TSV files with selected fields
- Create sample/region-specific subsets
- Maintain data provenance and metadata
- Lossless data export preserving all annotations
- Compressed output formats
- Streaming exports for large datasets
4. Population Genomics Workflows
TileDB-VCF excels at large-scale population genomics analyses requiring efficient access to variant data across many samples and genomic regions.
Common workflows:
- Genome-wide association studies (GWAS) data preparation
- Rare variant burden testing
- Population stratification analysis
- Allele frequency calculations across populations
- Quality control across large cohorts
- Variant annotation and filtering
- Cross-population comparative analysis
Key Concepts
Array Schema and Data Model
TileDB-VCF Data Model:
- Variants stored as sparse arrays with genomic coordinates as dimensions
- Samples stored as attributes allowing efficient sample-specific queries
- INFO and FORMAT fields preserved with original data types
- Automatic compression and chunking for optimal storage
Schema Configuration:
# Partition a large read across region/sample space
config = tiledbvcf.ReadConfig(
memory_budget_mb=2048, # memory budget in MB
region_partition=(0, 10), # (partition_index, num_partitions) over regions
sample_partition=(0, 4), # (partition_index, num_partitions) over samples
)
Coordinate Systems and Regions
Critical: TileDB-VCF uses 1-based genomic coordinates following VCF standard:
- Positions are 1-based (first base is position 1)
- Ranges are inclusive on both ends
- Region "chr1:1000-2000" includes positions 1000-2000 (1001 bases total)
Region specification formats:
# Single region
regions = ["chr1:1000000-2000000"]
# Multiple regions
regions = ["chr1:1000000-2000000", "chr2:500000-1500000"]
# Whole chromosome
regions = ["chr1"]
Note: regions= strings are always 1-based inclusive — a start <= 0 raises "Regions must be 1-based". There is no implicit BED-style conversion. To use 0-based half-open BED intervals, pass a BED file via read(bed_file="regions.bed", ...) instead of the regions= list.
Memory Management
Performance considerations:
- Set appropriate memory budget based on available system memory
- Use streaming queries for very large result sets
- Partition large ingestions to avoid memory exhaustion
- Configure tile cache for repeated region access
- Use parallel ingestion for multiple files
- Optimize region queries by combining nearby regions
Cloud Storage Integration
TileDB-VCF seamlessly works with cloud storage:
# S3 dataset
ds = tiledbvcf.Dataset(uri="s3://bucket/dataset", mode="r")
# Azure Blob Storage
ds = tiledbvcf.Dataset(uri="azure://container/dataset", mode="r")
# Google Cloud Storage
ds = tiledbvcf.Dataset(uri="gcs://bucket/dataset", mode="r")
Common Pitfalls
- Memory exhaustion during ingestion: Use appropriate memory budget and batch processing for large VCF files
- Inefficient region queries: Combine nearby regions instead of many separate queries
- Missing sample names: Ensure sample names in VCF headers match query sample specifications
- Coordinate system confusion: Remember TileDB-VCF uses 1-based coordinates like VCF standard
- Large result sets: Use streaming or pagination for queries returning millions of variants
- Cloud permissions: Ensure proper authentication for cloud storage access
- Concurrent access: Multiple writers to the same dataset can cause corruption—use appropriate locking
CLI Usage
TileDB-VCF provides a command-line interface with the following subcommands:
Available Subcommands:
create- Creates an empty TileDB-VCF datasetstore- Ingests samples into a TileDB-VCF datasetexport- Exports data from a TileDB-VCF datasetlist- Lists all sample names present in a TileDB-VCF datasetstat- Prints high-level statistics about a TileDB-VCF datasetutils- Utils for working with a TileDB-VCF datasetversion- Print the version information and exit
# Create empty dataset
tiledbvcf create --uri my_dataset
# Ingest samples (requires single-sample VCFs with indexes)
tiledbvcf store --uri my_dataset --samples sample1.vcf.gz,sample2.vcf.gz
# Export data
tiledbvcf export --uri my_dataset \
--regions "chr1:1000000-2000000" \
--sample-names "sample1,sample2"
# List all samples
tiledbvcf list --uri my_dataset
# Show dataset statistics
tiledbvcf stat --uri my_dataset
Advanced Features
These are methods on the Dataset object (open in mode="r"), not top-level tiledbvcf functions. There is no read_allele_frequency or sample_qc function — use the methods below.
Allele counts / frequencies
ds = tiledbvcf.Dataset(uri="my_dataset", mode="r")
# Internal allele-count (AC) array, returned as a pandas DataFrame
ac_df = ds.read_allele_count(region="chr1:1000000-2000000")
# Apply an allele-frequency filter at read time on a normal read()
df = ds.read(
attrs=["sample_name", "pos_start", "alleles", "fmt_GT"],
regions=["chr1:1000000-2000000"],
set_af_filter="<0.01", # keep variants with AF below threshold
)
Variant statistics (QC)
# Internal variant-stats array (per-variant aggregate stats) as a DataFrame
stats_df = ds.read_variant_stats(region="chr1:1000000-2000000")
Note: read_allele_count and read_variant_stats require the dataset to have been
ingested with the corresponding internal arrays enabled (the default in recent versions).
TileDB config passthrough
# Pass raw TileDB Embedded config keys (e.g. cloud creds, cache sizing)
config = tiledbvcf.ReadConfig(
memory_budget_mb=4096,
tiledb_config={
"sm.tile_cache_size": "1000000000",
"vfs.s3.region": "us-east-1",
},
)
Resources
- TileDB-VCF GitHub (source, issues, releases): https://github.com/TileDB-Inc/TileDB-VCF
- Population Genomics Guide (Academy): https://cloud.tiledb.com/academy/structure/life-sciences/population-genomics/
- Python API reference: https://tiledb-inc.github.io/TileDB-VCF/documentation/reference/Dataset.html
- TileDB Cloud (managed, distributed): https://cloud.tiledb.com
Scaling to TileDB-Cloud
When workloads outgrow single-node processing (roughly: > 1000 samples, > 100 GB of VCF, or a need for distributed compute / shared access), the same datasets can be ingested and queried on TileDB Cloud via tiledb-cloud-py. The local tiledbvcf API stays the same; the cloud package adds distributed orchestration.
Setup
pip install "tiledb-cloud[life-sciences]" # cloud client with genomics extras
export TILEDB_REST_TOKEN="your_api_token" # auth is automatic from this env var
Distributed ingest and read. The cloud VCF entry points live in tiledb.cloud.vcf:
tiledb.cloud.vcf.ingest(...)— distributed ingestion into atiledb://namespace/datasetURItiledb.cloud.vcf.build_read_dag(...)— builds a distributed read DAG over regions/samples
Exact signatures and resource arguments change between releases, so consult the current Cloud API reference rather than hard-coding them: https://cloud.tiledb.com/academy/structure/life-sciences/population-genomics/api-reference/cloud/
Cloud-hosted datasets are still opened with the normal tiledbvcf.Dataset API by passing a tiledb:// URI plus a tiledb_config carrying credentials:
import tiledbvcf
cfg = {"rest.token": "your_api_token"} # or rely on TILEDB_REST_TOKEN
ds = tiledbvcf.Dataset("tiledb://TileDB-Inc/gvcf-1kg-dragen-v376",
mode="r", tiledb_config=cfg)
df = ds.read(
attrs=["sample_name", "fmt_GT", "fmt_AD", "fmt_DP"],
regions=["chr13:32396898-32397044", "chr13:32398162-32400268"],
samples=ds.samples(),
)
Files (alterlab-academic-skills)
-
evals
-
evals.json 4.6 KB
{ "skill": "alterlab-tiledbvcf", "evals": [ { "id": "ingest-and-create-dataset", "prompt": "I have 200 single-sample bgzipped VCFs from a cohort and I want to load them into one scalable, compressed store I can query later, and be able to add more samples next month without rebuilding everything.", "expected_output": "Invokes alterlab-tiledbvcf: creates a Dataset in mode='w', ingests with ds.ingest_samples([...]), notes the requirement that VCFs be single-sample and have .tbi/.csi indexes, and highlights incremental sample addition without re-merging existing data.", "assertions": [ { "type": "should_trigger", "value": true }, { "type": "output_contains", "value": "ingest_samples" }, { "type": "behavior", "value": "Creates a write-mode Dataset, ingests single-sample indexed VCFs, and emphasizes incremental sample addition without re-processing." } ] }, { "id": "region-sample-query", "prompt": "From my TileDB-VCF store I need the genotypes for three specific samples across two genomic regions on chr1 and chr2, returned as a dataframe with sample name, position, and alleles.", "expected_output": "Invokes alterlab-tiledbvcf: opens the Dataset in mode='r' and calls ds.read with attrs (sample_name, pos_start, pos_end, alleles, fmt_GT), a regions list, and a samples list to get the filtered dataframe. Region/sample parallel query.", "assertions": [ { "type": "should_trigger", "value": true }, { "type": "output_contains", "value": "regions" }, { "type": "behavior", "value": "Uses ds.read with attrs, a regions list, and a samples list to retrieve the filtered genotype dataframe." } ] }, { "id": "export-subset-to-vcf", "prompt": "I want to pull just two samples (HG00101 and HG00097) over a single region on chr21 back out of my TileDB-VCF dataset as a standard VCF file to hand off to a collaborator's pipeline.", "expected_output": "Invokes alterlab-tiledbvcf: uses ds.export with regions, samples, output_format='v', and output_dir to write a standard VCF subset for interoperability. Export/interoperability capability.", "assertions": [ { "type": "should_trigger", "value": true }, { "type": "output_contains", "value": "export" }, { "type": "behavior", "value": "Uses ds.export with regions/samples and output_format='v' to produce a standard VCF subset." } ] }, { "id": "coordinate-system-clarification", "prompt": "When I query region chr1:1000-2000 in TileDB-VCF, exactly which positions does that include? I keep getting confused about whether it's 0-based or 1-based.", "expected_output": "Invokes alterlab-tiledbvcf: clarifies that TileDB-VCF uses 1-based, inclusive coordinates following the VCF standard, so chr1:1000-2000 covers positions 1000 through 2000 (1001 bases), unlike 0-based half-open BED conventions.", "assertions": [ { "type": "should_trigger", "value": true }, { "type": "output_contains", "value": "1-based" }, { "type": "behavior", "value": "Explains TileDB-VCF's 1-based inclusive coordinate system and that chr1:1000-2000 spans 1001 bases." } ] }, { "id": "near-miss-pysam", "prompt": "I just have a single multi-sample VCF file and I want to iterate over its records one at a time, pull the genotype and DP for each sample at each variant, and write a filtered VCF keeping only PASS sites.", "expected_output": "Should NOT trigger alterlab-tiledbvcf. Streaming/iterating a single VCF/BAM file record-by-record (VariantFile, per-record FORMAT access, filtered writing) is alterlab-pysam territory. TileDB-VCF is for scalable array-backed stores of many single-sample VCFs, not direct iteration over one flat multi-sample VCF.", "assertions": [ { "type": "should_not_trigger", "value": true }, { "type": "output_contains", "value": "pysam" } ] }, { "id": "near-miss-pydeseq2", "prompt": "I have a gene-level RNA-seq count matrix and a sample condition table. Run differential expression between treated and control and give me log2 fold changes and adjusted p-values.", "expected_output": "Should NOT trigger alterlab-tiledbvcf. Bulk RNA-seq differential expression (count matrix, design, DESeq2-style log2FC and padj) is alterlab-pydeseq2 territory and has nothing to do with variant-call storage. TileDB-VCF stores and queries genomic variants, not expression counts.", "assertions": [ { "type": "should_not_trigger", "value": true }, { "type": "output_contains", "value": "pydeseq2" } ] } ] }
-
-
SKILL.md 14 KB
--- name: alterlab-tiledbvcf description: Store and query genomic variant data at scale with TileDB-VCF — ingest VCF/BCF into compressed TileDB arrays, add samples incrementally, run fast parallel region/sample queries, and export back to VCF. Use when managing population-genomics variant datasets that are too large for flat VCF, building joint variant stores, or querying thousands of samples by region. Part of the AlterLab Academic Skills suite. license: MIT allowed-tools: Read Write Edit Bash(python:*) Bash(uv:*) compatibility: "tiledbvcf-py is distributed via the `tiledb` conda channel (not PyPI/conda-forge/bioconda); current release 0.40.3 (2026-04), built for linux-64, osx-64 and osx-arm64 on Python 3.9-3.12 (no 3.13 build, no Windows, no linux-aarch64). Local VCF stores work offline. TileDB Cloud features require a TileDB Cloud account and TILEDB_REST_TOKEN." metadata: skill-author: AlterLab version: "1.1.0" last_updated: "2026-09-23" --- # TileDB-VCF ## Overview TileDB-VCF is a high-performance C++ library with Python and CLI interfaces for efficient storage and retrieval of genomic variant-call data. Built on TileDB's sparse array technology, it enables scalable ingestion of VCF/BCF files, incremental sample addition without expensive merging operations, and efficient parallel queries of variant data stored locally or in the cloud. ## When to Use This Skill This skill should be used when: - Building a queryable, compressed variant store from many single-sample VCF/BCF files (cohort/population datasets too large for flat VCF) - Incrementally adding new samples to an existing store without re-merging - Querying specific genomic regions across many samples (region/sample-partitioned reads) - Exporting region/sample subsets back to VCF/BCF for downstream tools - Working with variant data on cloud storage (S3, Azure, GCS) or TileDB Cloud - Prototyping or teaching scalable genomics-variant workflows ### Does NOT Trigger | Scenario | Use Instead | |----------|-------------| | Reading, filtering, or iterating a handful of VCF/BAM files in Python (pysam/htslib) | `alterlab-pysam` | | Producing the VCFs in the first place (FASTQ -> alignment -> variant calling) | `alterlab-nf-core-sarek` | | Clinical interpretation or population frequency of a specific variant | `alterlab-clinvar` / `alterlab-gnomad` | | General chunked array storage for non-variant data (images, tensors, matrices) | `alterlab-zarr` | | Out-of-core dataframe analytics on an exported table | `alterlab-polars` / `alterlab-dask` | ## Quick Start ### Installation **Preferred method: conda/mamba from the `tiledb` channel.** `tiledbvcf-py` is NOT on PyPI, conda-forge, or bioconda — it ships from the `tiledb` Anaconda channel, with native `osx-arm64` builds (no Rosetta/`CONDA_SUBDIR` workaround needed on Apple Silicon). The current release is **0.40.3** (April 2026), built for `linux-64`, `osx-64` and `osx-arm64` on **Python 3.9–3.12**. There is no 3.13 build, so pin the interpreter when creating the environment — a default `conda create` that resolves to a newer Python will report the package as unavailable rather than explaining why. ```bash # Native Apple Silicon (osx-arm64) — also works on osx-64 / linux-64 conda create -n tiledb-vcf -c conda-forge -c tiledb \ python=3.12 tiledbvcf-py=0.40 pandas pyarrow numpy conda activate tiledb-vcf ``` **Alternative: Docker images** (pulls the CLI/Python interface; latest tag tracks current release) ```bash docker pull tiledb/tiledbvcf-py # Python interface docker pull tiledb/tiledbvcf-cli # Command-line interface ``` ### Basic Examples **Create and populate a dataset:** ```python import tiledbvcf # Create a new dataset ds = tiledbvcf.Dataset(uri="my_dataset", mode="w", cfg=tiledbvcf.ReadConfig(memory_budget_mb=1024)) # Ingest VCF files (must be single-sample with indexes) # Requirements: # - VCFs must be single-sample (not multi-sample) # - Must have indexes: .csi (bcftools) or .tbi (tabix) ds.ingest_samples(["sample1.vcf.gz", "sample2.vcf.gz"]) ``` **Query variant data:** ```python # Open existing dataset for reading ds = tiledbvcf.Dataset(uri="my_dataset", mode="r") # Query specific regions and samples df = ds.read( attrs=["sample_name", "pos_start", "pos_end", "alleles", "fmt_GT"], regions=["chr1:1000000-2000000", "chr2:500000-1500000"], samples=["sample1", "sample2", "sample3"] ) print(df.head()) ``` **Export to VCF:** ```python import os # Export two VCF samples ds.export( regions=["chr21:8220186-8405573"], samples=["HG00101", "HG00097"], output_format="v", output_dir=os.path.expanduser("~"), ) ``` ## Core Capabilities ### 1. Dataset Creation and Ingestion Create TileDB-VCF datasets and incrementally ingest variant data from multiple VCF/BCF files. This is appropriate for building population genomics databases and cohort studies. **Requirements:** - **Single-sample VCFs only**: Multi-sample VCFs are not supported - **Index files required**: VCF/BCF files must have indexes (.csi or .tbi) **Common operations:** - Create new datasets with optimized array schemas - Ingest single or multiple VCF/BCF files in parallel - Add new samples incrementally without re-processing existing data - Configure memory usage and compression settings - Handle various VCF formats and INFO/FORMAT fields - Resume interrupted ingestion processes - Validate data integrity during ingestion ### 2. Efficient Querying and Filtering Query variant data with high performance across genomic regions, samples, and variant attributes. This is appropriate for association studies, variant discovery, and population analysis. **Common operations:** - Query specific genomic regions (single or multiple) - Filter by sample names or sample groups - Extract specific variant attributes (position, alleles, genotypes, quality) - Access INFO and FORMAT fields efficiently - Combine spatial and attribute-based filtering - Stream large query results - Perform aggregations across samples or regions ### 3. Data Export and Interoperability Export data in various formats for downstream analysis or integration with other genomics tools. This is appropriate for sharing datasets, creating analysis subsets, or feeding other pipelines. **Common operations:** - Export to standard VCF/BCF formats - Generate TSV files with selected fields - Create sample/region-specific subsets - Maintain data provenance and metadata - Lossless data export preserving all annotations - Compressed output formats - Streaming exports for large datasets ### 4. Population Genomics Workflows TileDB-VCF excels at large-scale population genomics analyses requiring efficient access to variant data across many samples and genomic regions. **Common workflows:** - Genome-wide association studies (GWAS) data preparation - Rare variant burden testing - Population stratification analysis - Allele frequency calculations across populations - Quality control across large cohorts - Variant annotation and filtering - Cross-population comparative analysis ## Key Concepts ### Array Schema and Data Model **TileDB-VCF Data Model:** - Variants stored as sparse arrays with genomic coordinates as dimensions - Samples stored as attributes allowing efficient sample-specific queries - INFO and FORMAT fields preserved with original data types - Automatic compression and chunking for optimal storage **Schema Configuration:** ```python # Partition a large read across region/sample space config = tiledbvcf.ReadConfig( memory_budget_mb=2048, # memory budget in MB region_partition=(0, 10), # (partition_index, num_partitions) over regions sample_partition=(0, 4), # (partition_index, num_partitions) over samples ) ``` ### Coordinate Systems and Regions **Critical:** TileDB-VCF uses **1-based genomic coordinates** following VCF standard: - Positions are 1-based (first base is position 1) - Ranges are inclusive on both ends - Region "chr1:1000-2000" includes positions 1000-2000 (1001 bases total) **Region specification formats:** ```python # Single region regions = ["chr1:1000000-2000000"] # Multiple regions regions = ["chr1:1000000-2000000", "chr2:500000-1500000"] # Whole chromosome regions = ["chr1"] ``` **Note:** `regions=` strings are always 1-based inclusive — a start <= 0 raises "Regions must be 1-based". There is no implicit BED-style conversion. To use 0-based half-open BED intervals, pass a BED file via `read(bed_file="regions.bed", ...)` instead of the `regions=` list. ### Memory Management **Performance considerations:** 1. **Set appropriate memory budget** based on available system memory 2. **Use streaming queries** for very large result sets 3. **Partition large ingestions** to avoid memory exhaustion 4. **Configure tile cache** for repeated region access 5. **Use parallel ingestion** for multiple files 6. **Optimize region queries** by combining nearby regions ### Cloud Storage Integration TileDB-VCF seamlessly works with cloud storage: ```python # S3 dataset ds = tiledbvcf.Dataset(uri="s3://bucket/dataset", mode="r") # Azure Blob Storage ds = tiledbvcf.Dataset(uri="azure://container/dataset", mode="r") # Google Cloud Storage ds = tiledbvcf.Dataset(uri="gcs://bucket/dataset", mode="r") ``` ## Common Pitfalls 1. **Memory exhaustion during ingestion:** Use appropriate memory budget and batch processing for large VCF files 2. **Inefficient region queries:** Combine nearby regions instead of many separate queries 3. **Missing sample names:** Ensure sample names in VCF headers match query sample specifications 4. **Coordinate system confusion:** Remember TileDB-VCF uses 1-based coordinates like VCF standard 5. **Large result sets:** Use streaming or pagination for queries returning millions of variants 6. **Cloud permissions:** Ensure proper authentication for cloud storage access 7. **Concurrent access:** Multiple writers to the same dataset can cause corruption—use appropriate locking ## CLI Usage TileDB-VCF provides a command-line interface with the following subcommands: **Available Subcommands:** - `create` - Creates an empty TileDB-VCF dataset - `store` - Ingests samples into a TileDB-VCF dataset - `export` - Exports data from a TileDB-VCF dataset - `list` - Lists all sample names present in a TileDB-VCF dataset - `stat` - Prints high-level statistics about a TileDB-VCF dataset - `utils` - Utils for working with a TileDB-VCF dataset - `version` - Print the version information and exit ```bash # Create empty dataset tiledbvcf create --uri my_dataset # Ingest samples (requires single-sample VCFs with indexes) tiledbvcf store --uri my_dataset --samples sample1.vcf.gz,sample2.vcf.gz # Export data tiledbvcf export --uri my_dataset \ --regions "chr1:1000000-2000000" \ --sample-names "sample1,sample2" # List all samples tiledbvcf list --uri my_dataset # Show dataset statistics tiledbvcf stat --uri my_dataset ``` ## Advanced Features These are methods on the `Dataset` object (open in mode="r"), not top-level `tiledbvcf` functions. There is no `read_allele_frequency` or `sample_qc` function — use the methods below. ### Allele counts / frequencies ```python ds = tiledbvcf.Dataset(uri="my_dataset", mode="r") # Internal allele-count (AC) array, returned as a pandas DataFrame ac_df = ds.read_allele_count(region="chr1:1000000-2000000") # Apply an allele-frequency filter at read time on a normal read() df = ds.read( attrs=["sample_name", "pos_start", "alleles", "fmt_GT"], regions=["chr1:1000000-2000000"], set_af_filter="<0.01", # keep variants with AF below threshold ) ``` ### Variant statistics (QC) ```python # Internal variant-stats array (per-variant aggregate stats) as a DataFrame stats_df = ds.read_variant_stats(region="chr1:1000000-2000000") ``` Note: `read_allele_count` and `read_variant_stats` require the dataset to have been ingested with the corresponding internal arrays enabled (the default in recent versions). ### TileDB config passthrough ```python # Pass raw TileDB Embedded config keys (e.g. cloud creds, cache sizing) config = tiledbvcf.ReadConfig( memory_budget_mb=4096, tiledb_config={ "sm.tile_cache_size": "1000000000", "vfs.s3.region": "us-east-1", }, ) ``` ## Resources - TileDB-VCF GitHub (source, issues, releases): https://github.com/TileDB-Inc/TileDB-VCF - Population Genomics Guide (Academy): https://cloud.tiledb.com/academy/structure/life-sciences/population-genomics/ - Python API reference: https://tiledb-inc.github.io/TileDB-VCF/documentation/reference/Dataset.html - TileDB Cloud (managed, distributed): https://cloud.tiledb.com ## Scaling to TileDB-Cloud When workloads outgrow single-node processing (roughly: > 1000 samples, > 100 GB of VCF, or a need for distributed compute / shared access), the same datasets can be ingested and queried on TileDB Cloud via `tiledb-cloud-py`. The local `tiledbvcf` API stays the same; the cloud package adds distributed orchestration. **Setup** ```bash pip install "tiledb-cloud[life-sciences]" # cloud client with genomics extras export TILEDB_REST_TOKEN="your_api_token" # auth is automatic from this env var ``` **Distributed ingest and read.** The cloud VCF entry points live in `tiledb.cloud.vcf`: - `tiledb.cloud.vcf.ingest(...)` — distributed ingestion into a `tiledb://namespace/dataset` URI - `tiledb.cloud.vcf.build_read_dag(...)` — builds a distributed read DAG over regions/samples Exact signatures and resource arguments change between releases, so consult the current Cloud API reference rather than hard-coding them: https://cloud.tiledb.com/academy/structure/life-sciences/population-genomics/api-reference/cloud/ Cloud-hosted datasets are still opened with the normal `tiledbvcf.Dataset` API by passing a `tiledb://` URI plus a `tiledb_config` carrying credentials: ```python import tiledbvcf cfg = {"rest.token": "your_api_token"} # or rely on TILEDB_REST_TOKEN ds = tiledbvcf.Dataset("tiledb://TileDB-Inc/gvcf-1kg-dragen-v376", mode="r", tiledb_config=cfg) df = ds.read( attrs=["sample_name", "fmt_GT", "fmt_AD", "fmt_DP"], regions=["chr13:32396898-32397044", "chr13:32398162-32400268"], samples=ds.samples(), ) ```
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.