Skip to content
bio-long-read-sequencing-clair3-variants logo

Clair3 Variant Calling

bio-long-read-sequencing-clair3-variants

Deep learning-based variant calling from long reads using Clair3 for SNPs and small indels. Use when calling germline variants from ONT or PacBio alignments, particularly when high accuracy is needed for clinical or research applications.

SKILL.md

Full skill instructions

Clair3 Variant Calling

Basic Usage

# ONT variant calling
run_clair3.sh \
    --bam_fn=sample.bam \
    --ref_fn=reference.fasta \
    --threads=32 \
    --platform=ont \
    --model_path=${CONDA_PREFIX}/​bin/​models/​ont \
    --output=clair3_output

# PacBio HiFi variant calling
run_clair3.sh \
    --bam_fn=sample.bam \
    --ref_fn=reference.fasta \
    --threads=32 \
    --platform=hifi \
    --model_path=${CONDA_PREFIX}/​bin/​models/​hifi \
    --output=clair3_output

# Output: clair3_output/​merge_output.vcf.gz

Platform-Specific Models

PlatformModelRecommended Coverage
ONT R10r1041_e82_400bps_sup_v43030-60x
ONT R9r941_prom_sup_g501430-60x
PacBio HiFihifi20-40x
PacBio CLR-Use PEPPER-Margin-DeepVariant
# List available models
ls ${CONDA_PREFIX}/​bin/​models/

# Specify exact model
run_clair3.sh \
    --bam_fn=sample.bam \
    --ref_fn=reference.fasta \
    --model_path=${CONDA_PREFIX}/​bin/​models/​r1041_e82_400bps_sup_v430 \
    --output=clair3_out \
    --threads=32

Key Parameters

ParameterDescription
--platformont, hifi, or ilmn
--model_pathPath to trained model
--bed_fnRestrict calling to regions
--include_all_ctgsCall on all contigs (not just chr1-22,X,Y)
--no_phasing_for_faDisable phasing
--gvcfOutput gVCF format
--qualMinimum variant quality (default: 2)

Region-Specific Calling

# Call variants in specific regions
run_clair3.sh \
    --bam_fn=sample.bam \
    --ref_fn=reference.fasta \
    --bed_fn=target_regions.bed \
    --threads=32 \
    --platform=ont \
    --model_path=${CONDA_PREFIX}/​bin/​models/​ont \
    --output=clair3_targeted

# Call on non-human genomes (all contigs)
run_clair3.sh \
    --bam_fn=sample.bam \
    --ref_fn=reference.fasta \
    --include_all_ctgs \
    --threads=32 \
    --platform=hifi \
    --model_path=${CONDA_PREFIX}/​bin/​models/​hifi \
    --output=clair3_all_contigs

gVCF Output

# Generate gVCF for joint calling
run_clair3.sh \
    --bam_fn=sample.bam \
    --ref_fn=reference.fasta \
    --gvcf \
    --threads=32 \
    --platform=ont \
    --model_path=${CONDA_PREFIX}/​bin/​models/​ont \
    --output=clair3_gvcf

# Joint genotyping multiple samples
bcftools merge sample1.g.vcf.gz sample2.g.vcf.gz -o cohort.vcf.gz

Phased Variant Calling

# With phasing information (requires haplotagged BAM)
run_clair3.sh \
    --bam_fn=haplotagged.bam \
    --ref_fn=reference.fasta \
    --enable_phasing \
    --longphase_for_phasing \
    --threads=32 \
    --platform=ont \
    --model_path=${CONDA_PREFIX}/​bin/​models/​ont \
    --output=clair3_phased

Quality Filtering

# Filter by quality score
bcftools view -i 'QUAL>20' clair3_output/​merge_output.vcf.gz -Oz -o filtered.vcf.gz

# Filter by genotype quality
bcftools view -i 'GQ>30' clair3_output/​merge_output.vcf.gz -Oz -o high_gq.vcf.gz

# SNPs only
bcftools view -v snps clair3_output/​merge_output.vcf.gz -Oz -o snps.vcf.gz

# Indels only
bcftools view -v indels clair3_output/​merge_output.vcf.gz -Oz -o indels.vcf.gz

Python Wrapper

import subprocess
from pathlib import Path

def run_clair3(bam, reference, output_dir, platform='ont', model_path=None,
               threads=32, bed=None, gvcf=False, include_all_ctgs=False):
    if model_path is None:
        import os
        conda_prefix = os.environ.get('CONDA_PREFIX', '')
        model_path = f'{conda_prefix}/​bin/​models/​{platform}'

    cmd = [
        'run_clair3.sh',
        f'--bam_fn={bam}',
        f'--ref_fn={reference}',
        f'--threads={threads}',
        f'--platform={platform}',
        f'--model_path={model_path}',
        f'--output={output_dir}'
    ]

    if bed:
        cmd.append(f'--bed_fn={bed}')
    if gvcf:
        cmd.append('--gvcf')
    if include_all_ctgs:
        cmd.append('--include_all_ctgs')

    subprocess.run(cmd, check=True)
    return Path(output_dir) / 'merge_output.vcf.gz'

def filter_variants(vcf, output, min_qual=20, variant_type=None):
    cmd = ['bcftools', 'view', '-i', f'QUAL>{min_qual}']
    if variant_type:
        cmd.extend(['-v', variant_type])
    cmd.extend([vcf, '-Oz', '-o', output])
    subprocess.run(cmd, check=True)
    subprocess.run(['bcftools', 'index', '-t', output], check=True)
    return output

# Example
vcf = run_clair3('sample.bam', 'ref.fa', 'clair3_out', platform='hifi', threads=48)
snps = filter_variants(str(vcf), 'snps_q20.vcf.gz', min_qual=20, variant_type='snps')

Comparison with Other Callers

CallerBest ForSpeedAccuracy
Clair3ONT/​HiFi germlineFastHigh
DeepVariantHiFi, IlluminaMediumVery high
PEPPER-DVONT (integrated)SlowVery high
LongshotONT SNPsFastGood

Troubleshooting

IssueSolution
Missing modelDownload from Clair3 releases or use conda models
Low call rateCheck coverage; increase --qual threshold
Slow performanceReduce --threads or use --bed_fn for targeted calling
Wrong variants on non-humanUse --include_all_ctgs

Docker Usage

# Using Docker
docker run -v /​data:/​data \
    hkubal/​clair3:latest \
    /​opt/​bin/​run_clair3.sh \
    --bam_fn=/​data/​sample.bam \
    --ref_fn=/​data/​reference.fasta \
    --threads=32 \
    --platform=ont \
    --model_path=/​opt/​models/​ont \
    --output=/​data/​clair3_output

# Singularity
singularity exec clair3.sif run_clair3.sh \
    --bam_fn=sample.bam \
    --ref_fn=reference.fasta \
    --threads=32 \
    --platform=ont \
    --model_path=/​opt/​models/​ont \
    --output=clair3_output

Related Skills

  • variant-calling/​bcftools-basics - VCF manipulation
  • variant-calling/​filtering-best-practices - Quality filtering
  • long-read-sequencing/​long-read-qc - Input quality control
  • long-read-sequencing/​long-read-alignment - Mapping with minimap2

More Other skills

Delegate independent tasks to specialized agents working concurrently with isolated context.

295.4K 206.3K
View

Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.

179.7K 100.1K
View

Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.

179.7K 89.5K
View

A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal communications (status reports, leadership updates, 3P updates, company newsletters, FAQs, incident reports, project updates, etc.).

179.7K 76.1K
View

Fundamental design principles for writing maintainable, testable Python code.

40.2K 21.9K
View

Modern responsive layouts using container queries, fluid typography, CSS Grid, and mobile-first strategies.

40.2K 20K
View

Generate Playwright tests from scenarios using interactive browser exploration and validation.

39.7K 18.2K
View

Modern React state management with Redux Toolkit, Zustand, Jotai, and React Query for every state category.

40.2K 14.7K
View

GDPR-compliant data handling with consent management, data subject rights, and privacy controls.

40.2K 14.3K
View

Python error handling patterns including input validation, exception hierarchies, and partial failure handling. Use when implementing validation logic, designing exception strategies, handling batch processing failures, or building robust APIs.

40.2K 13.5K
View

Detailed multi-file refactor planning with safety checks and rollback guidance.

39.7K 13K
View