Communitygithub.com

tiledbvcf

使用 TileDB 高效儲存與檢索基因組變異資料。具備可擴展的 VCF/BCF 攝入、增量樣本添加、壓縮儲存、平行查詢及匯出功能,適用於群體基因組學。

tiledbvcf 是什麼?

TileDB-VCF 是一個高效能的 C++ 函式庫,並提供 Python 與 CLI 介面,專為基因組變異呼叫資料的儲存與檢索而設計。它基於 TileDB 的稀疏陣列技術,能夠可擴展地攝入 VCF/BCF 檔案,支援增量添加新樣本而無需耗費大量合併運算,並能對儲存在本地或雲端的變異資料執行高效率的平行查詢。此技能適用於學習 TileDB-VCF 概念、開發基因組學分析流程、處理中小型資料集(少於 1000 個樣本)、以及構建用於群體遺傳學研究的變異資料庫。它也支援常見的群體基因組學工作流程,例如全基因組關聯研究(GWAS)的資料準備和罕見變異負擔檢定。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/skills/tiledbvcf

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

TileDB-VCF

概述

TileDB-VCF 是一個高效能的 C++ 函式庫,並提供 Python 與 CLI 介面,用於高效儲存與檢索基因組變異呼叫資料。它建構在 TileDB 的稀疏陣列技術之上,能實現 VCF/BCF 檔案的可擴展攝入、無需昂貴合併操作的增量樣本添加,以及對儲存在本地或雲端的變異資料進行高效的平行查詢。

何時使用此技能

此技能應在以下情況下使用:

  • 學習 TileDB-VCF 的概念與工作流程
  • 用於基因組學分析與管線的原型開發
  • 處理小到中型資料集(< 1000 個樣本)
  • 需要將新樣本增量添加到現有資料集
  • 需要跨多個樣本高效查詢特定基因組區域
  • 處理雲端儲存的變異資料(S3、Azure、GCS)
  • 需要從大型 VCF 資料集中匯出子集
  • 為群體研究建立變異資料庫
  • 教育專案與方法開發
  • 變異資料操作對效能要求嚴苛

快速開始

安裝

建議方法:Conda/Mamba

# 如果您使用 M1 Mac,請輸入以下兩行
CONDA_SUBDIR=osx-64
conda config --env --set subdir osx-64

# 建立 conda 環境
conda create -n tiledb-vcf "python<3.10"
conda activate tiledb-vcf

# Mamba 是 conda 更快且更可靠的替代方案
conda install -c conda-forge mamba

# 安裝 TileDB-Py 和 TileDB-VCF,並與其他實用函式庫對齊
mamba install -y -c conda-forge -c bioconda -c tiledb tiledb-py tiledbvcf-py pandas pyarrow numpy

替代方案:Docker 映像檔

docker pull tiledb/tiledbvcf-py     # Python 介面
docker pull tiledb/tiledbvcf-cli    # 命令列介面

基本範例

建立並填充資料集:

import tiledbvcf

# 建立新資料集
ds = tiledbvcf.Dataset(uri="my_dataset", mode="w",
                      cfg=tiledbvcf.ReadConfig(memory_budget=1024))

# 攝入 VCF 檔案(必須是單樣本且附帶索引)
# 需求:
# - VCF 必須是單樣本(非多樣本)
# - 必須有索引:.csi(bcftools)或 .tbi(tabix)
ds.ingest_samples(["sample1.vcf.gz", "sample2.vcf.gz"])

查詢變異資料:

# 開啟現有資料集以供讀取
ds = tiledbvcf.Dataset(uri="my_dataset", mode="r")

# 查詢特定區域與樣本
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())

匯出為 VCF:

import os

# 匯出兩個 VCF 樣本
ds.export(
    regions=["chr21:8220186-8405573"],
    samples=["HG00101", "HG00097"],
    output_format="v",
    output_dir=os.path.expanduser("~"),
)

核心功能

1. 資料集建立與攝入

建立 TileDB-VCF 資料集,並從多個 VCF/BCF 檔案增量攝入變異資料。這適用於建立群體基因組學資料庫和群體研究。

需求:

  • 僅限單樣本 VCF:不支援多樣本 VCF
  • 需要索引檔案:VCF/BCF 檔案必須有索引(.csi 或 .tbi)

常見操作:

  • 使用最佳化的陣列綱要建立新資料集
  • 平行攝入單個或多個 VCF/BCF 檔案
  • 增量添加新樣本,無需重新處理現有資料
  • 設定記憶體使用量與壓縮設定
  • 處理各種 VCF 格式與 INFO/FORMAT 欄位
  • 恢復中斷的攝入程序
  • 在攝入期間驗證資料完整性

2. 高效查詢與過濾

跨基因組區域、樣本和變異屬性高效查詢變異資料。這適用於關聯研究、變異發現和群體分析。

常見操作:

  • 查詢特定基因組區域(單個或多個)
  • 依樣本名稱或樣本群組過濾
  • 提取特定的變異屬性(位置、對偶基因、基因型、品質)
  • 高效存取 INFO 與 FORMAT 欄位
  • 結合空間與基於屬性的過濾
  • 串流處理大型查詢結果
  • 跨樣本或區域執行聚合運算

3. 資料匯出與互通性

以多種格式匯出資料,以供下游分析或與其他基因組學工具整合。這適用於分享資料集、建立分析子集或提供給其他管線使用。

常見操作:

  • 匯出為標準 VCF/BCF 格式
  • 產生包含選取欄位的 TSV 檔案
  • 建立樣本/區域特定子集
  • 維護資料來源與中繼資料
  • 無損資料匯出,保留所有註釋
  • 壓縮輸出格式
  • 大型資料集的串流匯出

4. 群體基因組學工作流程

TileDB-VCF 擅長大規模群體基因組學分析,需要跨多個樣本和基因組區域高效存取變異資料。

常見工作流程:

  • 全基因組關聯研究(GWAS)資料準備
  • 罕見變異負擔檢定
  • 群體分層分析
  • 跨群體的對偶基因頻率計算
  • 大型群體的品質控制
  • 變異註釋與過濾
  • 跨群體比較分析

關鍵概念

陣列綱要與資料模型

TileDB-VCF 資料模型:

  • 變異以稀疏陣列形式儲存,基因組座標作為維度
  • 樣本以屬性形式儲存,允許高效的樣本特定查詢
  • INFO 與 FORMAT 欄位保留原始資料類型
  • 自動壓縮與分塊以達到最佳儲存

綱要配置:

# 具有特定切片範圍的自訂綱要
config = tiledbvcf.ReadConfig(
    memory_budget=2048,  # MB
    region_partition=(0, 3095677412),  # 完整基因組
    sample_partition=(0, 10000)  # 最多 1 萬個樣本
)

座標系統與區域

關鍵: TileDB-VCF 使用基於 1 的基因組座標,遵循 VCF 標準:

  • 位置是以 1 為基礎(第一個鹼基是位置 1)
  • 範圍在兩端均為包含
  • 區域 "chr1:1000-2000" 包含位置 1000-2000(總共 1001 個鹼基)

區域規格格式:

# 單一區域
regions = ["chr1:1000000-2000000"]

# 多個區域
regions = ["chr1:1000000-2000000", "chr2:500000-1500000"]

# 整條染色體
regions = ["chr1"]

# BED 風格(以 0 為基礎,半開區間,內部會轉換)
regions = ["chr1:999999-2000000"]  # 等同於以 1 為基礎的 chr1:1000000-2000000

記憶體管理

效能考量:

  1. 設定適當的記憶體預算,根據可用系統記憶體
  2. 對非常大的結果集使用串流查詢
  3. 將大型攝入工作劃分以避免記憶體耗盡
  4. 設定切片快取以進行重複區域存取
  5. 對多個檔案使用平行攝入
  6. 合併鄰近區域以最佳化區域查詢

雲端儲存整合

TileDB-VCF 可與雲端儲存無縫協作:

# S3 資料集
ds = tiledbvcf.Dataset(uri="s3://bucket/dataset", mode="r")

# Azure Blob 儲存體
ds = tiledbvcf.Dataset(uri="azure://container/dataset", mode="r")

# Google Cloud Storage
ds = tiledbvcf.Dataset(uri="gcs://bucket/dataset", mode="r")

常見陷阱

  1. 攝入期間記憶體耗盡: 為大型 VCF 檔案使用適當的記憶體預算和批次處理
  2. 無效率的區域查詢: 合併鄰近區域,而不是執行許多單獨查詢
  3. 缺少樣本名稱: 確保 VCF 標頭中的樣本名稱與查詢樣本規格相符
  4. 座標系統混淆: 記住 TileDB-VCF 使用以 1 為基礎的座標,如同 VCF 標準
  5. 大型結果集: 對返回數百萬個變異的查詢使用串流或分頁
  6. 雲端權限: 確保雲端儲存存取的正確身分驗證
  7. 並行存取: 多個寫入器同時寫入同一個資料集可能導致損毀 — 請使用適當的鎖定機制

CLI 使用

TileDB-VCF 提供命令列介面,包含以下子命令:

可用的子命令:

  • create - 建立一個空的 TileDB-VCF 資料集
  • store - 將樣本攝入到 TileDB-VCF 資料集中
  • export - 從 TileDB-VCF 資料集匯出資料
  • list - 列出 TileDB-VCF 資料集中存在的所有樣本名稱
  • stat - 列印 TileDB-VCF 資料集的高階統計資訊
  • utils - 用於處理 TileDB-VCF 資料集的工具
  • version - 列印版本資訊並退出
# 建立空的資料集
tiledbvcf create --uri my_dataset

# 攝入樣本(需要單樣本 VCF 及其索引)
tiledbvcf store --uri my_dataset --samples sample1.vcf.gz,sample2.vcf.gz

# 匯出資料
tiledbvcf export --uri my_dataset \
  --regions "chr1:1000000-2000000" \
  --sample-names "sample1,sample2"

# 列出所有樣本
tiledbvcf list --uri my_dataset

# 顯示資料集統計資訊
tiledbvcf stat --uri my_dataset

進階功能

對偶基因頻率分析

# 計算對偶基因頻率
af_df = tiledbvcf.read_allele_frequency(
    uri="my_dataset",
    regions=["chr1:1000000-2000000"],
    samples=["sample1", "sample2", "sample3"]
)

樣本品質控制

# 執行樣本 QC
qc_results = tiledbvcf.sample_qc(
    uri="my_dataset",
    samples=["sample1", "sample2"]
)

自訂配置

# 進階配置
config = tiledbvcf.ReadConfig(
    memory_budget=4096,
    tiledb_config={
        "sm.tile_cache_size": "1000000000",
        "vfs.s3.region": "us-east-1"
    }
)

資源

取得協助

開源 TileDB-VCF 資源

開源文件:

TileDB-Cloud 資源

針對大規模/生產級基因組學:

開始使用:

擴展至 TileDB-Cloud

當您的基因組學工作負載超出單節點處理能力時,TileDB-Cloud 可為生產級基因組學管線提供企業級擴展能力。

注意:本節根據現有文件介紹 TileDB-Cloud 的功能。如需完整的 API 細節和當前功能,請查閱官方 TileDB-Cloud 文件和 API 參考。

設定 TileDB-Cloud

1. 建立帳號並獲取 API Token

# 在 https://cloud.tiledb.com 註冊
# 在您的帳號設定中產生 API Token

2. 安裝 TileDB-Cloud Python 用戶端

# 基本安裝
uv pip install tiledb-cloud

# 包含基因組學特定功能
uv pip install tiledb-cloud[life-sciences]

3. 配置身分驗證

# 使用您的 API Token 設定環境變數
export TILEDB_REST_TOKEN="your_api_token"
import tiledb.cloud

# 透過 TILEDB_REST_TOKEN 自動進行身分驗證
# 程式碼中無需顯式登入

從開源遷移到 TileDB-Cloud

大規模攝入

# TileDB-Cloud:分散式 VCF 攝入
import tiledb.cloud.vcf

# 使用專用 VCF 攝入模組
# 注意:確切 API 需參考 TileDB-Cloud 文件
# 此處代表可用的功能結構
tiledb.cloud.vcf.ingestion.ingest_vcf_dataset(
    source="s3://my-bucket/vcf-files/",
    output="tiledb://my-namespace/large-dataset",
    namespace="my-namespace",
    acn="my-s3-credentials",
    ingest_resources={"cpu": "16", "memory": "64Gi"}
)

分散式查詢處理

# TileDB-Cloud:跨分散式儲存的 VCF 查詢
import tiledb.cloud.vcf
import tiledbvcf

# 定義資料集 URI
dataset_uri = "tiledb://TileDB-Inc/gvcf-1kg-dragen-v376"

# 從資料集取得所有樣本
ds = tiledbvcf.Dataset(dataset_uri, tiledb_config=cfg)
samples = ds.samples()

# 定義要查詢的屬性和範圍
attrs = ["sample_name", "fmt_GT", "fmt_AD", "fmt_DP"]
regions = ["chr13:32396898-32397044", "chr13:32398162-32400268"]

# 執行讀取,以分散式方式進行
df = tiledb.cloud.vcf.read(
    dataset_uri=dataset_uri,
    regions=regions,
    samples=samples,
    attrs=attrs,
    namespace="my-namespace",  # 指定扣除費用的帳號
)
df.to_pandas()

企業功能

資料分享與協作

# TileDB-Cloud 透過基於命名空間的權限和群組管理提供企業級資料分享功能

# 透過 TileDB-Cloud URI 存取共享資料集
dataset_uri = "tiledb://shared-namespace/population-study"

# 透過共享筆記本和運算資源進行協作
# (具體 API 需參考 TileDB-Cloud 文件)

成本最佳化

  • 無伺服器運算:僅需支付實際運算時間
  • 自動擴展:根據工作負載自動擴展/縮減
  • 競價執行個體:對批次作業使用成本最佳化的運算
  • 資料分層:自動管理熱/冷儲存

安全性與合規性

  • 端到端加密:傳輸中與靜止資料均加密
  • 存取控制:細粒度權限和稽核日誌
  • HIPAA/SOC2 合規:企業安全標準
  • VPC 支援:部署在私有雲端環境中

何時應遷移的檢查清單

✅ 如果您有以下情況,請遷移到 TileDB-Cloud:

  • 資料集 > 1000 個樣本
  • 需要處理 > 100GB 的 VCF 資料
  • 需要分散式運算
  • 多個團隊成員需要存取
  • 需要企業級安全性/合規性
  • 想要成本最佳化的無伺服器運算
  • 需要 24/7 生產環境正常運行時間

開始使用 TileDB-Cloud

  1. 免費開始:TileDB-Cloud 提供免費層供評估
  2. 遷移支援:TileDB 團隊提供遷移協助
  3. 教育訓練:可取得基因組學特定教學資源

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

adaptyv

How to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.

aeon

This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.

alphagenome

Look up precomputed AlphaGenome Atlas effects for any GRCh38 single-nucleotide variant (AVI score with Phred and 18 SHAP feature attributions, plus raw and quantile scores for RNA-seq, DNase, ATAC, ChIP-TF, ChIP-histone, CAGE, PRO-cap, splicing, polyadenylation and contact-map tracks), score variants or scan windows on demand with the AlphaGenome model for human and mouse (variant scoring, in silico mutagenesis, REF-versus-ALT track prediction), and build Atlas website deep links. Use when the user mentions AlphaGenome, AlphaGenome Atlas, AVI or AlphaGenome Variant Impact, DeepMind variant effect prediction, or wants to prioritise or mechanistically interpret non-coding, regulatory, splicing, enhancer, promoter, or chromatin-accessibility effects of SNVs from a VCF, credible set, or region. Research use only; not a clinical tool.

analytical-method-validation

Plan, execute, and document validation, verification, and transfer of analytical procedures under the governing framework - ICH Q2(R2) and Q14, USP <1220>/<1225>/<1226>, ICH M10 bioanalytical, CLSI EP, or ISO/IEC 17025. Use for HPLC, LC-MS/MS, GC, CE, ICP-MS, dissolution, qNMR, qPCR, NIR, and ligand binding or cell-based assays whenever the question is whether a procedure is fit for its intended purpose. Triggers include

anndata

Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.

arbor

Autonomously improve a real artifact (code, training recipe, agent harness, data pipeline, prompt) against an objective and an evaluator, using Hypothesis Tree Refinement (HTR) from the Arbor paper. Use this whenever someone wants to iteratively optimize something over many experiments without overfitting — e.g.

arboreto

Infer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.

astropy

Core Python library for astronomy and astrophysics workflows that need Astropy APIs, including units/quantities, coordinates, FITS I/O, tables, time systems, WCS, and cosmology. Use when implementing or debugging astronomical data analysis code with Astropy.

autoskill

Observe the user

benchling-integration

Benchling Python SDK and REST API integration for registry entities, inventory, ELN entries, workflows, Benchling Apps, and Data Warehouse queries. Use when automating lab data with benchling-sdk or the v2 API.

bgpt-paper-search

Search scientific papers and retrieve structured experimental data extracted from full-text studies via the BGPT MCP server. Returns 25+ fields per paper including methods, results, sample sizes, quality scores, and conclusions. Use for literature reviews, evidence synthesis, and finding experimental details not available in abstracts alone.

bids

>

biopython

Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use bioservices.

bioservices

Unified Python interface to 40+ bioinformatics services. Use when querying multiple databases (UniProt, KEGG, ChEMBL, Reactome) in a single workflow with consistent API. Best for cross-database analysis, ID mapping across services. For quick single-database lookups use gget; for sequence/file manipulation use biopython.

bulk-rnaseq

End-to-end bulk RNA-seq orchestrator — takes raw FASTQ reads through QC and trimming (FastQC, fastp/Trim Galore), alignment and quantification (STAR, Salmon, featureCounts), assembles a gene-level counts matrix, then hands off to differential expression (pydeseq2), pathway/GSEA enrichment (pathway-enrichment), and publication figures (scientific-visualization). Use whenever the user has bulk RNA-seq reads or quant output and wants a complete, reproducible differential-expression workflow — e.g.

cellxgene-census

Query the CZ CELLxGENE Census programmatically for versioned public single-cell and spatial transcriptomics data. Use when you need population-scale cell metadata, gene expression slices, Census summary counts, source H5AD URIs/downloads, embeddings, spatial Census data, or reference atlas comparisons across organisms, tissues, diseases, assays, and cell types. For analyzing your own local single-cell data use scanpy, anndata, or scvi-tools.

cirq

Google quantum computing framework. Use when targeting Google Quantum AI hardware, designing noise-aware circuits, or running quantum characterization experiments. Best for Google hardware, noise modeling, and low-level circuit design. For IBM hardware use qiskit; for quantum ML with autodiff use pennylane; for physics simulations use qutip.

citation-management

Comprehensive citation management for academic research. Search OpenAlex, PubMed, and Google Scholar for papers, extract accurate metadata, validate citations, and generate properly formatted BibTeX entries. This skill should be used when you need to find papers, verify citation information, convert DOIs to BibTeX, or ensure reference accuracy in scientific writing.

clinical-decision-support

Prepare and validate research-only clinical decision-support evaluation, evidence-profile, cohort, survival, biomarker/model, privacy, and governance artifacts. Use for aggregate or synthetic research documentation and traceability—not patient care or live clinical operation.

clinical-reports

Create safety-bounded draft structures and run local deterministic checks for clinical case, diagnostic, trial, safety, and aggregate research reports. Use only with synthetic, de-identified, or aggregate inputs and verified source-fact manifests; every output requires qualified review.

相關技能