TileDB-VCF

TileDB-VCF

Guides an AI agent in storing and querying genomic variant calls with TileDB-VCF: ingesting VCF files, region and sample queries, QC and exports, locally or in the cloud.

Skill files2 files

references/

SKILL.md283 lines
1
---
2
name: tiledbvcf
3
description: Stores and retrieves genomic variant calls with TileDB-VCF. Use for indexed single-sample VCF/BCF ingestion, incremental cohorts, region and sample queries, streaming results, allele statistics, QC, and VCF/BCF export locally or through TileDB Cloud.
4
license: MIT license
5
compatibility: Requires a native TileDB-VCF installation and Python 3.9-3.12 for the reviewed Conda builds. bcftools compresses/indexes input fixtures. Installation and remote storage need network access; TileDB Cloud needs its Python client, account token, and storage permissions.
6
metadata:
7
version: "1.3"
8
skill-author: Jeremy Leipzig
9
last-reviewed: "2026-10-01"
10
upstream-version: "TileDB-VCF 0.40.3; tiledb-cloud 0.14.4"
11
---
12
13
# TileDB-VCF
14
15
## When to use
16
17
Use for cohort variant storage, incremental sample ingestion, interval queries, and
18
exporting subsets for downstream genomics. TileDB-VCF stores records; it does not
19
perform joint variant calling, association testing, normalization, or population
20
structure adjustment. Dataset size alone does not determine whether cloud execution
21
is appropriate: benchmark the intended sample, region, and attribute workload.
22
23
This skill targets released **TileDB-VCF 0.40.3**. Native Python/CLI checks used two
24
synthetic single-sample VCFs on macOS ARM64. Cloud client **0.14.4** contracts were
25
checked against its released wheel and mocked dispatch; hosted queries and jobs
26
were not executed. See [installation and verification notes](references/verification.md).
27
28
## Install and verify the native stack
29
30
The `tiledbvcf` Python distribution is not published on PyPI at this review. The
31
official **`tiledb` Conda channel** supplies `tiledbvcf-py` 0.40.3 for macOS ARM64,
32
macOS x86-64, and Linux x86-64, with Python 3.9-3.12 builds. `tiledb` on PyPI is
33
TileDB-Py and does not install TileDB-VCF. Native Apple Silicon no longer requires
34
forcing `CONDA_SUBDIR=osx-64`.
35
36
For the tested macOS ARM64 environment, pins below avoid versioned-library import
37
failures in the otherwise successful current Conda solve:
38
39
```bash
40
conda create -n tiledb-vcf -c tiledb -c conda-forge \
41
python=3.12 tiledbvcf-py=0.40.3 \
42
azure-core-cpp=1.16.2 azure-storage-blobs-cpp=12.16.0 \
43
azure-storage-files-datalake-cpp=12.14.0 capnproto=1.4.0 c-blosc2=2.23.1
44
conda activate tiledb-vcf
45
python -c 'import tiledbvcf; print(tiledbvcf.version)'
46
tiledbvcf version
47
```
48
49
The equivalent Micromamba solve/install was executed. These extra ABI pins are a
50
verified macOS ARM64 workaround, not a claim about all platforms. Preserve the
51
resolved environment for production. Other-platform installation and official
52
Docker images are alternatives documented upstream, not tested here.
53
54
## Prepare and create a cohort
55
56
1. Record reference assembly, contig naming/lengths, callers, normalization rules,
57
sample identity, and file checksums. Do not mix assemblies or assume `1` and
58
`chr1` are equivalent. Confirm compatible headers across inputs.
59
2. Each input must contain **one sample**, be coordinate sorted, and have an index.
60
Use BGZF-compressed VCF or BCF with a matching `.csi`/`.tbi`. Inspect
61
`bcftools query -l sample1.vcf.gz`; filenames are not sample identifiers.
62
3. Create the dataset explicitly, then ingest. Opening `mode="w"` alone does not
63
create its schema. Materialize frequently read fields at creation time.
64
4. Validate a small known interval and a round-trip export before scaling.
65
66
For existing sorted plain-text VCFs (run once per input; output names must be new):
67
68
```bash
69
bcftools view -Oz -o sample1.vcf.gz sample1.vcf
70
bcftools index -c sample1.vcf.gz
71
bcftools view -Oz -o sample2.vcf.gz sample2.vcf
72
bcftools index -c sample2.vcf.gz
73
```
74
75
The following local examples were exercised with sample IDs `S1` and `S2`, contig
76
`chr1`, and coordinates 1-100; substitute the verified IDs and intervals in real data.
77
78
```python
79
import tiledbvcf
80
81
uri = "cohort"
82
config = {"sm.compute_concurrency_level": "2", "sm.io_concurrency_level": "2"}
83
with tiledbvcf.Dataset(uri, mode="w", tiledb_config=config) as ds:
84
ds.create_dataset(extra_attrs=["fmt_GT", "fmt_DP"])
85
ds.ingest_samples(
86
["sample1.vcf.gz"], threads=2, total_memory_budget_mb=512
87
)
88
89
# Incremental ingestion uses the existing dataset; do not call create_dataset again.
90
with tiledbvcf.Dataset(uri, mode="w", tiledb_config=config) as ds:
91
ds.ingest_samples(
92
["sample2.vcf.gz"], threads=2, total_memory_budget_mb=512
93
)
94
```
95
96
The schema-v4 data array has `contig`, start-coordinate, and sample **dimensions**;
97
headers and optional statistics are separate arrays in the dataset group. Fields
98
not explicitly materialized remain in the INFO/FORMAT payloads. Query names such
99
as `pos_start` need not match raw storage column names.
100
101
Upstream supports parallel thread/process ingestion. Assign distinct sample work
102
and coordinate lifecycle/maintenance operations; do not blindly re-ingest samples.
103
`resume=True` supports interrupted ingestion, not arbitrary duplicate correction.
104
105
## Query completely and interpret coordinates correctly
106
107
| Surface | Coordinate convention |
108
| --- | --- |
109
| Python `regions=["chr1:10-14"]` | 1-based, closed interval |
110
| Returned `pos_start`, `pos_end` | 1-based, inclusive record endpoints |
111
| BED input and `query_bed_start`, `query_bed_end` | 0-based, half-open |
112
| `read_variant_stats()` / `read_allele_count()` column `pos` in 0.40.3 | **0-based**; add one before joining to VCF POS |
113
114
Queries return **overlapping records**, not just records starting inside the
115
interval. A deletion spanning positions 10-14 appears in `chr1:14-14`, with
116
`pos_start=10`. For BED `[13,14)`, the equivalent string is `chr1:14-14`.
117
The Python region parser requires explicit `contig:start-end`; bare `"chr1"`
118
is rejected in this release. Use a known contig length for a whole-contig query.
119
120
```python
121
cfg = tiledbvcf.ReadConfig(memory_budget_mb=128, tiledb_config=config)
122
attrs = ["sample_name", "contig", "pos_start", "pos_end", "alleles", "fmt_GT"]
123
with tiledbvcf.Dataset(uri, cfg=cfg) as ds:
124
assert {"S1", "S2"}.issubset(ds.samples())
125
assert set(attrs).issubset(ds.attributes())
126
for batch in ds.read_iter(
127
attrs=attrs, regions=["chr1:1-100"], samples=["S1", "S2"]
128
):
129
print(batch) # Replace with a bounded consumer or partitioned output.
130
```
131
132
- `read()` returns a pandas DataFrame; `read_arrow()` returns a PyArrow Table.
133
Either can return only the first memory-limited batch. Continue with
134
`continue_read()` / `continue_read_arrow()` until `read_completed()`, or use
135
`read_iter()` for ordinary DataFrame queries. Avoid concatenating all batches
136
when the result cannot fit in memory.
137
- `ReadConfig(memory_budget_mb=...)` controls reads; use
138
`ingest_samples(total_memory_budget_mb=...)` for writes. A read budget is not
139
a process RSS cap. `limit` truncates total output; it is not a pagination size.
140
- `sample_partition=(0, 2)` selects partition zero of two. Likewise,
141
`region_partition=(index, number_of_partitions)` partitions query regions;
142
these tuples are not coordinate bounds, tile extents, or sample capacities.
143
- **0.40.3 retains BED selection state** when a later call omits `bed_file`.
144
Open a fresh `Dataset` for an independent query when changing BED/region inputs.
145
- `fmt_GT` contains allele indices: 0 refers to REF, positive values index ALT,
146
and -1 means missing. Preserve multiallelic identity and ploidy; do not treat
147
every positive integer as a biallelic dosage or missing calls as reference.
148
The integer list alone does not encode the original phased GT string.
149
150
## Export and validate
151
152
```python
153
from pathlib import Path
154
155
Path("exported").mkdir(exist_ok=True)
156
with tiledbvcf.Dataset(uri, cfg=cfg) as ds:
157
ds.export(
158
samples=["S1"], regions=["chr1:1-100"],
159
output_format="v", output_dir="exported",
160
)
161
```
162
163
Python export formats: `v` VCF, `z` compressed VCF, `u` uncompressed BCF, `b`
164
compressed BCF. `merge=False` writes per-sample files; `merge=True` requires a
165
combined `output_path`. A combined export is not joint calling. Re-index exported
166
files before indexed downstream access. Compare sample IDs, contigs, record
167
counts, alleles, INFO/FORMAT values, and missing/phased genotypes; semantic
168
round-trip preservation does not imply byte-identical compression or headers.
169
170
The CLI accepts positional sample paths or `--samples-file` (one URI per line),
171
not a comma-separated `--samples` argument:
172
173
```bash
174
tiledbvcf create --uri cli_cohort
175
tiledbvcf store --uri cli_cohort --threads 2 --total-memory-budget-mb 512 \
176
-- sample1.vcf.gz sample2.vcf.gz
177
tiledbvcf list --uri cli_cohort
178
tiledbvcf stat --uri cli_cohort
179
tiledbvcf export --uri cli_cohort --regions chr1:1-100 \
180
--sample-names S1,S2 -Ot --tsv-fields 'SAMPLE,CHR,POS,REF,ALT,F:GT' \
181
--output-path variants.tsv
182
```
183
184
`--` protects positional paths from variable-length options such as
185
`--tiledb-config`. Check expected artifacts and sample counts as well as the exit
186
code: an invalid store command returned exit zero while printing an error in the
187
reviewed CLI. TSV fields use `F:GT` for FORMAT/GT and `I:DP` for INFO/DP.
188
189
## Cohort statistics and QC
190
191
```python
192
with tiledbvcf.Dataset(uri, cfg=cfg) as ds:
193
stats = ds.read_variant_stats(regions=["chr1:1-100"], drop_ref=True)
194
stats["vcf_pos"] = stats["pos"] + 1
195
print(stats[["contig", "vcf_pos", "alleles", "ac", "an", "af"]])
196
197
qc = tiledbvcf.sample_qc(uri, samples=["S1"], config=config)
198
print(qc)
199
```
200
201
Statistics arrays are enabled by default at creation; older/disabled arrays may
202
not support these operations. `read_variant_stats` has no `samples` argument.
203
The older `read_allele_frequency(dataset_uri, region)` wrapper accepts a single
204
region and delegates to the deprecated singular argument; prefer the Dataset
205
method above. `sample_qc` uses `dataset_uri`, not `uri`, as its first argument.
206
207
The `ac`, `an`, and `af` values summarize the ingested cohort, not a selected
208
ancestry or query sample subset. A `read(samples=[...], set_af_filter=">0.6")`
209
filter still used cohort AF in the tested release. Compute subgroup frequencies
210
from correctly selected calls with explicit missingness, ploidy, callable-region,
211
and gVCF reference-block policies. Use an appropriate called-allele denominator,
212
not universally `2 * number_of_samples`; a missing VCF record is not proof of a
213
homozygous-reference call. QC metrics and sparse storage do not establish GWAS
214
readiness or scientific validity.
215
216
## Object storage and TileDB Cloud
217
218
Direct storage uses `s3://bucket/path`, `azure://container/path`, or
219
`gcs://bucket/path`, supported by the installed TileDB backend and its provider
220
credentials. This does not automatically distribute the computation. Use the
221
provider's credential chain or scoped configuration, and verify access to both
222
the dataset and source indexes. A TileDB Cloud token is distinct from bucket
223
credentials. Remote storage examples below are illustrative, source-verified,
224
and not authenticated end-to-end tests.
225
226
Install `tiledb-cloud==0.14.4` in a compatible environment. Its `life-sciences`
227
extra adds TileDB-SOMA, **not TileDB-VCF**. Supply `TILEDB_REST_TOKEN` through the
228
execution environment before importing the client; `TILEDB_REST_HOST` selects a
229
custom deployment if required. Do not embed tokens in code or print configuration.
230
231
```python
232
# Illustrative: requires an accessible registered cohort and a billing namespace.
233
import tiledb.cloud
234
import tiledb.cloud.vcf
235
236
cloud_cfg = tiledb.cloud.Config()
237
with tiledbvcf.Dataset("tiledb://my-namespace/cohort", tiledb_config=cloud_cfg) as ds:
238
sample_names = ds.samples()
239
240
result = tiledb.cloud.vcf.read(
241
dataset_uri="tiledb://my-namespace/cohort",
242
config=cloud_cfg, attrs=["sample_name", "pos_start", "fmt_GT"],
243
regions=["chr1:1-100"], samples=sample_names[:2],
244
num_region_partitions=1, namespace="my-namespace", max_workers=2,
245
)
246
frame = result.to_pandas() # read returns an Arrow table, not a DataFrame.
247
```
248
249
Distributed reads assemble an Arrow result and may use significant worker/client
250
memory. Bound the requested regions/samples and worker count; partitioning does
251
not make the final concatenated result memory-free. This is SDK task execution,
252
not a paginated VCF REST-list API.
253
254
```python
255
# Illustrative, mutating cloud job: use only for an authorized ingestion task.
256
submission = tiledb.cloud.vcf.ingest(
257
dataset_uri="s3://my-bucket/cohort",
258
sample_list_uri="s3://my-bucket/inputs/sample-uris.txt",
259
namespace="my-namespace", acn="registered-storage-role",
260
register_name="cohort", max_samples=2,
261
ingest_resources={"cpu": "2", "memory": "4Gi"},
262
)
263
print(submission["graph_id"])
264
```
265
266
Use exactly one of `search_uri`, `sample_list_uri`, or `metadata_uri`; file-search
267
patterns apply to `search_uri`. Registration requires the access credential name
268
(`acn`). `vcf.ingest` submits asynchronously and returns
269
`{"status": "started", "graph_id": ...}`; track that graph to terminal success
270
and verify ingested samples before claiming completion. There is no released
271
`ingest_vcf_dataset(source=..., output=...)` API. Pricing, availability, security
272
controls, and deployment obligations require the current account/service terms.
273
274
## Official references
275
276
- [TileDB-VCF 0.40.3 release](https://github.com/TileDB-Inc/TileDB-VCF/releases/tag/0.40.3)
277
- [Dataset API](https://tiledb-inc.github.io/TileDB-VCF/documentation/reference/Dataset.html)
278
- [Ingestion](https://tiledb-inc.github.io/TileDB-VCF/documentation/how-to/ingest-samples.html)
279
- [Large queries](https://tiledb-inc.github.io/TileDB-VCF/documentation/how-to/handle-large-queries.html)
280
- [Cloud storage](https://tiledb-inc.github.io/TileDB-VCF/documentation/how-to/work-with-cloud-object-stores.html)
281
- [TileDB Cloud client release](https://pypi.org/project/tiledb-cloud/0.14.4/)
282
- [Verification details and known release issues](references/verification.md)
283

© Jeremy Leipzig · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…