Phasage d'haplotypes avec Beagle et SHAPEIT

VérifiéPrudence

Phase des génotypes en haplotypes avec Beagle ou SHAPEIT. Détermine quels allèles sont hérités ensemble. À utiliser pour préparer des fichiers VCF pour l'imputation, le typage HLA ou les analyses de génétique des populations.

Spar Skills Guide Bot
Data & IAIntermédiaire
0030/08/2026
Claude CodeCursorWindsurfCopilotCodex
#bioinformatics#haplotype-phasing#beagle#shapeit5#genomics

Recommandé pour

Notre avis

Ce skill permet de phaser des génotypes en haplotypes à l'aide de Beagle ou SHAPEIT5, en préparant les fichiers VCF pour l'imputation, le typage HLA ou les analyses de génétique des populations.

Points forts

  • Supporte deux outils majeurs de phasage (Beagle et SHAPEIT5) avec options avancées.
  • Intègre l'utilisation de cartes génétiques et de panels de référence pour améliorer la précision.
  • Fournit des commandes pour le traitement par chromosome et la concaténation des résultats.
  • Inclut des étapes de préparation et de vérification des fichiers VCF.

Limites

  • Nécessite le téléchargement de Beagle et l'installation de SHAPEIT5 ou de Java.
  • Se concentre sur l'utilisation en ligne de commande sans expliquer les algorithmes sous-jacents.
  • Les options et formats sont spécifiques à ces outils et peuvent nécessiter une adaptation.
Quand l'utiliser

Utilisez ce skill lorsque vous disposez d'un VCF non phasé et que vous avez besoin d'haplotypes phasés pour l'imputation, le typage HLA ou des analyses de génétique des populations.

Quand l'éviter

Ne l'utilisez pas si vous n'avez besoin que d'appel de génotypes simples ou si vos données ne justifient pas un phasage complet.

Analyse de sécurité

Prudence
Score qualité88/100

The skill instructs legitimate bioinformatics phasing workflows using standard tools (Beagle, SHAPEIT5, bcftools). It does not contain destructive, exfiltration, or obfuscated actions. However, it involves downloading and running external executables and uses shell commands, so caution is warranted.

Points d'attention
  • Downloads and executes a Java jar (Beagle) from an external source without checksum verification.
  • Uses shell commands to download genetic maps and process VCF files.
  • Contains author signature and copyright notice but no explicit license for use.

Exemples

Phase with Beagle using a genetic map
Phase the genotypes in input.vcf.gz using Beagle 5.4 with the provided genetic map plink.chr22.GRCh38.map, using 8 threads, and name the output 'phased'.
Phase with SHAPEIT5 common and rare variants
Use SHAPEIT5 to phase the common variants from input.vcf.gz with genetic_map.txt, then phase rare variants using the common phased scaffold, with 8 threads.
Verify phasing results
Check whether the variants in phased.vcf.gz are phased by counting the number of genotypes containing a pipe (|) using bcftools query.
<!-- # COPYRIGHT NOTICE # This file is part of the "Universal Biomedical Skills" project. # Copyright (c) 2026 MD BABU MIA, PhD <md.babu.mia@mssm.edu> # All Rights Reserved. # # This code is proprietary and confidential. # Unauthorized copying of this file, via any medium is strictly prohibited. # # Provenance: Authenticated by MD BABU MIA -->

name: bio-phasing-imputation-haplotype-phasing description: Phase genotypes into haplotypes using Beagle or SHAPEIT. Resolves which alleles are inherited together on each chromosome. Use when preparing VCF files for imputation, HLA typing, or population genetic analyses requiring phased haplotypes. tool_type: cli primary_tool: beagle measurable_outcome: Execute skill workflow successfully with valid output within 15 minutes. allowed-tools:

  • read_file
  • run_shell_command

Haplotype Phasing

Beagle 5.4 Phasing (Recommended)

# Download Beagle 5.4
wget https://faculty.washington.edu/browning/beagle/beagle.22Jul22.46e.jar

# Basic phasing
java -jar beagle.22Jul22.46e.jar \
    gt=input.vcf.gz \
    out=phased

# Output: phased.vcf.gz (phased genotypes)

# With genetic map (improves accuracy)
java -jar beagle.22Jul22.46e.jar \
    gt=input.vcf.gz \
    map=plink.chr22.GRCh38.map \
    out=phased

Beagle Options

java -jar beagle.22Jul22.46e.jar \
    gt=input.vcf.gz \
    out=phased \
    map=genetic_map.txt \
    nthreads=8 \
    window=40 \
    overlap=4 \
    ne=20000 \              # Effective population size
    seed=12345              # For reproducibility

Phase Per Chromosome

# Process each chromosome separately
for chr in {1..22}; do
    java -Xmx16g -jar beagle.jar \
        gt=input.chr${chr}.vcf.gz \
        map=genetic_maps/plink.chr${chr}.GRCh38.map \
        out=phased.chr${chr} \
        nthreads=8
done

# Concatenate chromosomes
bcftools concat phased.chr*.vcf.gz -Oz -o phased.all.vcf.gz
bcftools index phased.all.vcf.gz

SHAPEIT5 Phasing (for Large Datasets)

# Phase common variants first
shapeit5_phase_common \
    --input input.vcf.gz \
    --map genetic_map.txt \
    --output phased_common.bcf \
    --thread 8 \
    --log phased.log

# Then phase rare variants
shapeit5_phase_rare \
    --input input.vcf.gz \
    --scaffold phased_common.bcf \
    --map genetic_map.txt \
    --output phased.bcf \
    --thread 8

SHAPEIT5 with Reference Panel

# Improves phasing using reference haplotypes
shapeit5_phase_common \
    --input input.vcf.gz \
    --reference reference_panel.bcf \
    --map genetic_map.txt \
    --output phased.bcf \
    --thread 8

Beagle with Reference Panel

# Use reference panel for better phasing
java -jar beagle.22Jul22.46e.jar \
    gt=input.vcf.gz \
    ref=reference.vcf.gz \
    map=genetic_map.txt \
    out=phased \
    nthreads=8

Input Preparation

# Filter variants before phasing
bcftools view -m2 -M2 -v snps input.vcf.gz -Oz -o biallelic_snps.vcf.gz

# Remove missing genotypes (optional)
bcftools view -g ^miss biallelic_snps.vcf.gz -Oz -o no_missing.vcf.gz

# Normalize (important!)
bcftools norm -f reference.fa -Oz -o normalized.vcf.gz input.vcf.gz

Check Phasing Results

# View phased genotypes (| instead of /)
bcftools query -f '%CHROM\t%POS\t[%GT\t]\n' phased.vcf.gz | head

# Unphased: 0/1
# Phased: 0|1 or 1|0

# Count phased vs unphased
bcftools query -f '[%GT\n]' phased.vcf.gz | grep -c '|'

Genetic Maps

# Download genetic maps (GRCh38)
wget https://faculty.washington.edu/browning/beagle/genetic_maps/plink.GRCh38.map.zip
unzip plink.GRCh38.map.zip

# Format: chromosome position rate(cM/Mb) genetic_position(cM)
# chr1 55550 2.981822 0.000000

Key Parameters

| Parameter | Beagle | SHAPEIT5 | Description | |-----------|--------|----------|-------------| | Threads | nthreads | --thread | CPU threads | | Window | window | --window | Analysis window size | | Eff. pop size | ne | --effective-size | For LD modeling | | Seed | seed | --seed | Random seed |

Memory Requirements

| Dataset Size | Beagle Memory | SHAPEIT5 Memory | |--------------|--------------|-----------------| | 1,000 samples | 8 GB | 4 GB | | 10,000 samples | 32 GB | 16 GB | | 100,000 samples | 64+ GB | 32 GB |

Phasing Accuracy Metrics

  • Switch error rate: Rate of phase switches vs truth
  • Mismatch error rate: Overall haplotype differences
  • Measure using trio data or known haplotypes

Related Skills

  • phasing-imputation/genotype-imputation - Impute after phasing
  • phasing-imputation/reference-panels - Get reference data
  • variant-calling/filtering-best-practices - Prepare input VCF
  • population-genetics/linkage-disequilibrium - LD analysis
<!-- AUTHOR_SIGNATURE: 9a7f3c2e-MD-BABU-MIA-2026-MSSM-SECURE -->
Skills similaires