1. Structure
  2. Life Sciences
  3. Population Genomics
  4. Tutorials
  5. Advanced
  6. Split VCF
  • Home
  • What is TileDB?
  • Get Started
  • Explore Content
  • Accounts
    • Individual Accounts
      • Apply for the Free Tier
      • Profile
        • Overview
        • Cloud Credentials
        • Storage Paths
        • REST API Tokens
        • Credits
    • Organization Admins
      • Create an Organization
      • Profile
        • Overview
        • Members
        • Cloud Credentials
        • Storage Paths
        • Billing
      • API Tokens
    • Organization Members
      • Organization Invitations
      • Profile
        • Overview
        • Members
        • Cloud Credentials
        • Storage Paths
        • Billing
      • API Tokens
  • Catalog
    • Introduction
    • Data
      • Arrays
      • Tables
      • Single-Cell (SOMA)
      • Genomics (VCF)
      • Biomedical Imaging
      • Vector Search
      • Files
    • Code
      • Notebooks
      • Dashboards
      • User-Defined Functions
      • Task Graphs
      • ML Models
    • Groups
    • Marketplace
    • Search
  • Collaborate
    • Introduction
    • Organizations
    • Access Control
      • Introduction
      • Share Assets
      • Asset Permissions
      • Public Assets
    • Logging
    • Marketplace
  • Analyze
    • Introduction
    • Slice Data
    • Multi-Region Redirection
    • Notebooks
      • Launch a Notebook
      • Usage
      • Widgets
      • Notebook Image Dependencies
    • Dashboards
      • Dashboards
      • Streamlit
    • Preview
    • User-Defined Functions
    • Task Graphs
    • Serverless SQL
    • Monitor
      • Task Log
      • Task Graph Log
  • Scale
    • Introduction
    • Task Graphs
    • API Usage
  • Structure
    • Why Structure Is Important
    • Arrays
      • Introduction
      • Quickstart
      • Foundation
        • Array Data Model
        • Key Concepts
          • Storage
            • Arrays
            • Dimensions
            • Attributes
            • Cells
            • Domain
            • Tiles
            • Data Layout
            • Compression
            • Encryption
            • Tile Filters
            • Array Schema
            • Schema Evolution
            • Fragments
            • Fragment Metadata
            • Commits
            • Indexing
            • Array Metadata
            • Datetimes
            • Groups
            • Object Stores
          • Compute
            • Writes
            • Deletions
            • Consolidation
            • Vacuuming
            • Time Traveling
            • Reads
            • Query Conditions
            • Aggregates
            • User-Defined Functions
            • Distributed Compute
            • Concurrency
            • Parallelism
        • Storage Format Spec
      • Tutorials
        • Basics
          • Basic Dense Array
          • Basic Sparse Array
          • Array Metadata
          • Compression
          • Encryption
          • Data Layout
          • Tile Filters
          • Datetimes
          • Multiple Attributes
          • Variable-Length Attributes
          • String Dimensions
          • Nullable Attributes
          • Multi-Range Reads
          • Query Conditions
          • Aggregates
          • Deletions
          • Catching Errors
          • Configuration
          • Basic S3 Example
          • Basic TileDB Cloud
          • fromDataFrame
          • Palmer Penguins
        • Advanced
          • Schema Evolution
          • Advanced Writes
            • Write at a Timestamp
            • Get Fragment Info
            • Consolidation
              • Fragments
              • Fragment List
              • Consolidation Plan
              • Commits
              • Fragment Metadata
              • Array Metadata
            • Vacuuming
              • Fragments
              • Commits
              • Fragment Metadata
              • Array Metadata
          • Advanced Reads
            • Get Fragment Info
            • Time Traveling
              • Introduction
              • Fragments
              • Array Metadata
              • Schema Evolution
          • Array Upgrade
          • Backends
            • Amazon S3
            • Azure Blob Storage
            • Google Cloud Storage
            • MinIO
            • Lustre
          • Virtual Filesystem
          • User-Defined Functions
          • Distributed Compute
          • Result Estimation
          • Incomplete Queries
        • Management
          • Array Schema
          • Groups
          • Object Management
        • Performance
          • Summary of Factors
          • Dense vs. Sparse
          • Dimensions vs. Attributes
          • Compression
          • Tiling and Data Layout
          • Tuning Writes
          • Tuning Reads
      • API Reference
    • Tables
      • Introduction
      • Quickstart
      • Foundation
        • Data Model
        • Key Concepts
          • Indexes
          • Columnar Storage
          • Compression
          • Data Manipulation
          • Optimize Tables
          • ACID
          • Serverless SQL
          • SQL Connectors
          • Dataframes
          • CSV Ingestion
      • Tutorials
        • Basics
          • Ingestion with SQL
          • CSV Ingestion
          • Basic S3 Example
          • Running Locally
        • Advanced
          • Scalable Ingestion
          • Scalable Queries
      • API Reference
    • AI & ML
      • Vector Search
        • Introduction
        • Quickstart
        • Foundation
          • Data Model
          • Key Concepts
            • Vector Search
            • Vector Databases
            • Algorithms
            • Distance Metrics
            • Updates
            • Deployment Methods
            • Architecture
            • Distributed Compute
          • Storage Format Spec
        • Tutorials
          • Basics
            • Ingestion & Querying
            • Updates
            • Deletions
            • Basic S3 Example
            • Running Locally
          • Advanced
            • Versioning
            • Time Traveling
            • Consolidation
            • Distributed Compute
            • RAG LLM
            • LLM Memory
            • File Search
            • Image Search
            • Protein Search
          • Performance
        • API Reference
      • ML Models
        • Introduction
        • Quickstart
        • Foundation
          • Basics
          • Storage
          • Cloud Execution
          • Why TileDB for Machine Learning
        • Tutorials
          • Ingestion
            • Data Ingestion
              • Dense Datasets
              • Sparse Datasets
            • ML Model Ingestion
          • Management
            • Array Schema
            • Machine Learning: Groups
            • Time Traveling
    • Life Sciences
      • Single-cell
        • Introduction
        • Quickstart
        • Foundation
          • Data Model
          • Key Concepts
            • Data Structures
            • Use of Apache Arrow
            • Join IDs
            • State Management
            • TileDB Cloud URIs
          • SOMA API Specification
        • Tutorials
          • Data Ingestion
          • Bulk Ingestion Tutorial
          • Data Access
          • Distributed Compute
          • Basic S3 Example
          • Multi-Experiment Queries
          • Appending Data to a SOMA Experiment
          • Add New Measurements
          • SQL Queries
          • Running Locally
          • Shapes in TileDB-SOMA
          • Drug Discovery App
        • Spatial
          • Introduction
          • Foundation
            • Spatial Data Model
            • Data Structures
          • Tutorials
            • Spatial Data Ingestion
            • Access Spatial Data
            • Manage Coordinate Spaces
        • API Reference
      • Population Genomics
        • Introduction
        • Quickstart
        • Foundation
          • Data Model
          • Key Concepts
            • The N+1 Problem
            • Architecture
            • Arrays
            • Ingestion
            • Reads
            • Variant Statistics
            • Annotations
            • User-Defined Functions
            • Tables and SQL
            • Distributed Compute
          • Storage Format Spec
        • Tutorials
          • Basics
            • Basic Ingestion
            • Basic Queries
            • Export to VCF
            • Add New Samples
            • Deleting Samples
            • Basic S3 Example
            • Basic TileDB Cloud
          • Advanced
            • Scalable Ingestion
            • Scalable Queries
            • Query Transforms
            • Handling Large Queries
            • Annotations
              • Finding Annotations
              • Embedded Annotations
              • External Annotations
              • Annotation VCFs
              • Ingesting Annotations
            • Variant Statistics
            • Tables and SQL
            • User-Defined Functions
            • Sample Metadata
            • Split VCF
          • Performance
        • API Reference
          • Command Line Interface
          • Python API
          • Cloud API
      • Biomedical Imaging
        • Introduction
        • Foundation
          • Data Model
          • Key Concepts
            • Arrays
            • Ingestion
            • Reads
            • User Defined Functions
          • Storage Format Spec
        • Quickstart
        • Tutorials
          • Basics
            • Ingestion
            • Read
              • OpenSlide
              • TileDB-Py
          • Advanced
            • Batched Ingestion
            • Chunked Ingestion
            • Machine Learning
              • PyTorch
            • Napari
    • Files
  • API Reference
  • Self-Hosting
    • Installation
    • Upgrades
    • Administrative Tasks
    • Image Customization
      • Customize User-Defined Function Images
      • AWS ECR Container Registry
      • Customize Jupyter Notebook Images
    • Single Sign-On
      • Configure Single Sign-On
      • OpenID Connect
      • Okta SCIM
      • Microsoft Entra
  • Glossary

On this page

  • Setup
  • Split by sample names
  • Split all samples
  • Next steps
  1. Structure
  2. Life Sciences
  3. Population Genomics
  4. Tutorials
  5. Advanced
  6. Split VCF

Split VCF

life sciences
genomics (vcf)
tutorials
ingestion
Split multi-level VCF files for compatibility with TileDB-VCF ingestion.
How to run this tutorial

You can run this tutorial in two ways:

  1. Locally on your machine.
  2. On TileDB Cloud.

However, since TileDB Cloud has a free tier, we strongly recommend that you sign up and run everything there, as that requires no installations or deployment.

TileDB supports the ingestion of single-sample VCF files into TileDB-VCF datasets. Multi-sample or project-level VCF files must be split as a prerequisite for ingestion into TileDB. To accommodate multi-sample VCFs, TileDB offers utilities to split them into individual, single-sample files. The most useful of these utilities is a distributed splitting function to enable simultaneous splitting of numerous samples from a single multi-sample VCF. Once single-sample VCF files are isolated, subsequently ingest them into TileDB datasets or combine the entire process into a broader task graph for standardized processing.

Follow this tutorial to learn how to split multi-sample VCF files stored in public or private S3 buckets.

Setup

First, import the necessary libraries for this tutorial.

  • Python
from tiledb.cloud.vcf import ls_samples, split_vcf

Next, set some global variables:

  • project_vcf: S3 path of bgzipped VCF to be split. No index file is required for splitting.
  • dest: S3 directory to write single-sample VCFs.
  • namespace: Namespace in which to execute task graph in.
  • acn: TileDB access credential name to authenticate task graph to S3. Must be configured using an AWS IAM role for usability in task graphs.
  • config: Parameters for accessing S3, such as region.

More notes concerning these variables:

  • Split VCF files are named after the sample name listed in the source multi-sample VCF file. If a VCF file already exists at the S3 URI, it will be overwritten.
  • The task graph in tiledb.cloud.vcf.split.split_vcf is authenticated by the specified TileDB access credential name (acn).
  • For non-task graph access to S3, either pass credentials to config or set them as environment variables (recommended).
  • Python
# bgzipped target project VCF file
project_vcf = (
    "s3://tiledb-inc-demo-data/vcf/canine/vcf_split_demo_yorkshire_terrier.vcf.gz"
)
# s3 destination to deposit single-sample VCF files
dest = "s3://tiledb-spencer/projects/canine/split-demo/singles"
# TileDB namespace to execute task graph in
namespace = "spencerseale"
# TileDB access credential to authenticate task graph to read/write to S3
acn = "ss_tiledb_cloud"  # update with your ACN
# tiledb config settings
config = {
    "vfs.s3.region": "us-east-1",  # update to S3 region holding your data
}

Split by sample names

To identify all samples within a multi-sample VCF file for splitting, use tiledb.cloud.vcf.split.ls_samples.

  • Python
all_samples = ls_samples(vcf_uri=project_vcf, config=config)
all_samples
[2024-11-26 17:28:19,081] [split] [ls_samples] [INFO] Samples Identified:
    >>> YorkshireTerrier01
    >>> YorkshireTerrier02
[2024-11-26 17:28:19,082] [split] [ls_samples] [INFO] 
2 samples aggregated in s3://tiledb-inc-demo-data/vcf/canine/vcf_split_demo_yorkshire_terrier.vcf.gz.
['YorkshireTerrier01', 'YorkshireTerrier02']

This dataset consists of two samples. To split just one sample, use tiledb.cloud.vcf.split.split_vcf and pass its name to the samples: Sequence[str] argument.

  • Python
# indicate sample to split from VCF
graph_a = split_vcf(
    vcf_uri=project_vcf,
    output_uri=dest,
    namespace=namespace,
    acn=acn,
    config=config,
    samples=[all_samples[0]],
)
[2024-11-26 17:28:42,838] [split] [split_vcf] [INFO] Task Graph submitted - https://cloud.tiledb.com/activity/taskgraphs/spencerseale/db43aa71-fc70-48ce-a6c2-854ac4b0cdda

This launches a single-node task graph in the indicated namespace since only one sample is passed to samples. The resultant single-sample VCF for the indicated sample is saved to the location specified to split_vcf’s output_uri argument.

After the task graph completes, the URI of the isolated VCF file is returned. The file is named based on the sample name provided in tiledb.cloud.vcf.split.split_vcf.

  • Python
graph_a.end_results()
{UUID('02388050-ecdf-45bc-b238-5c115c9421be'): 's3://tiledb-spencer/projects/canine/split-demo/singles/YorkshireTerrier01.vcf.gz'}

Split all samples

Split all samples in a multi-sample VCF into single-sample VCF files by not specifying a value for samples.

  • Python
# split all samples
graph_b = split_vcf(
    vcf_uri=project_vcf,
    output_uri=dest,
    namespace=namespace,
    acn=acn,
    config=config,
)
[2024-11-25 16:23:07,242] [split] [split_vcf] [INFO] Task Graph submitted - https://cloud.tiledb.com/activity/taskgraphs/spencerseale/215c8897-ac3b-4bec-a838-31ac2cba14a1

This starts a two-stage task graph in the specified namespace. The first stage identifies all samples in the VCF. The second stage dynamically creates nodes for each sample identified in the first stage. This results in parallel isolation of each sample from the multi-sample VCF, expediting the splitting process.

Next steps

Now that the multi-sample VCF file has been isolated into single-sample VCF files, proceed with ingestion. To learn how to ingest the newly created single-sample VCF files, visit the ingestion tutorial.

Sample Metadata
Performance