bio-phasing-imputation-imputation-qc
Quality control of phasing and imputation results. Filter by INFO scores, assess accuracy, and prepare imputed data for downstream analysis. Use when…
от BioTender-max★ 235 звёзд на GitHub
Установить bio-phasing-imputation-imputation-qc в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Version Compatibility
Reference examples tested with: bcftools 1.19+, matplotlib 3.8+, numpy 1.26+, pandas 2.2+
Before using code patterns, verify installed versions match. If versions differ:
- Python:
pip show <package>thenhelp(module.function)to check signatures - CLI:
<tool> --versionthen<tool> --helpto confirm flags
If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
Imputation QC
"Filter my imputed genotypes by quality" → Assess imputation accuracy using INFO/R2 scores, filter low-quality imputed variants, and validate against known genotypes before downstream GWAS.
- CLI:
bcftools query -f '%CHROM %POS %INFO/R2\n'to extract quality scores - Python:
pandasfor R2 distribution analysis and threshold selection
Extract INFO Scores
# Beagle DR2 (dosage R-squared)
bcftools query -f '%CHROM\t%POS\t%ID\t%REF\t%ALT\t%INFO/DR2\t%INFO/AF\n' \
imputed.vcf.gz > info_scores.txt
# Minimac R2
bcftools query -f '%CHROM\t%POS\t%ID\t%REF\t%ALT\t%INFO/R2\t%INFO/MAF\n' \
imputed.vcf.gz > info_scores.txt
# IMPUTE info
bcftools query -f '%CHROM\t%POS\t%ID\t%INFO\n' imputed.vcf.gz > info_scores.txt
Filter by INFO Score
# Standard threshold for GWAS
bcftools view -i 'INFO/DR2 > 0.3' imputed.vcf.gz -Oz -o imputed_r2_03.vcf.gz
# Strict threshold for fine-mapping
bcftools view -i 'INFO/DR2 > 0.8' imputed.vcf.gz -Oz -o imputed_r2_08.vcf.gz
# Combined filtering
bcftools view -i 'INFO/DR2 > 0.3 && INFO/AF > 0.01 && INFO/AF < 0.99' \
imputed.vcf.gz -Oz -o imputed_filtered.vcf.gz
INFO Score Distribution
import pandas as pd
import matplotlib.pyplot as plt
# Load INFO scores
info = pd.read_csv('info_scores.txt', sep='\t',
names=['CHR', 'POS', 'ID', 'REF', 'ALT', 'R2', 'AF'])
# Distribution plot
fig, axes = plt.subplots(1, 3, figsize=(15, 4))
# Overall distribution
axes[0].hist(info['R2'], bins=50, edgecolor='black')
axes[0].axvline(0.3, color='red', linestyle='--', label='Threshold 0.3')
axes[0].set_xlabel('INFO Score (R2)')
axes[0].set_ylabel('Count')
axes[0].set_title('INFO Score Distribution')
axes[0].legend()
# R2 by MAF
info['MAF'] = info['AF'].apply(lambda x: min(x, 1-x))
info['MAF_bin'] = pd.cut(info['MAF'], bins=[0, 0.01, 0.05, 0.1, 0.5])
info.boxplot(column='R2', by='MAF_bin', ax=axes[1])
axes[1].set_xlabel('MAF Bin')
axes[1].set_ylabel('INFO Score')
axes[1].set_title('INFO by MAF')
# Scatter
axes[2].scatter(info['MAF'], info['R2'], alpha=0.1, s=1)
axes[2].set_xlabel('Minor Allele Frequency')
axes[2].set_ylabel('INFO Score')
axes[2].set_title('INFO vs MAF')
plt.tight_layout()
plt.savefig('imputation_qc.png', dpi=150)
Summarize Imputation Quality
# Count variants by quality
bcftools query -f '%INFO/DR2\n' imputed.vcf.gz | \
awk '{
if ($1 >= 0.8) high++;
else if ($1 >= 0.3) med++;
else low++
} END {
print "High quality (R2>=0.8):", high
print "Medium quality (0.3<=R2<0.8):", med
print "Low quality (R2<0.3):", low
}'
# Variants passing filter
echo "Total variants: $(bcftools view -H imputed.vcf.gz | wc -l)"
echo "Passing R2>0.3: $(bcftools view -i 'INFO/DR2>0.3' imputed.vcf.gz -H | wc -l)"
Check Concordance with Typed Variants
# Extract typed variants from imputed file
bcftools view -i 'INFO/TYPED=1' imputed.vcf.gz -Oz -o typed.vcf.gz
# Compare imputed vs original genotypes
bcftools gtcheck -g original.vcf.gz typed.vcf.gz > concordance.txt
# Parse concordance
grep "^CN" concordance.txt
Python: Comprehensive QC Report
Goal: Generate a comprehensive imputation quality summary with overall statistics, MAF-stratified accuracy, and per-chromosome breakdowns.
Approach: Load INFO scores into a dataframe, compute aggregate R2 statistics, bin variants by minor allele frequency for quality stratification, and produce per-chromosome summaries.
import pandas as pd
import numpy as np
def imputation_qc_report(info_file, output_prefix):
'''Generate comprehensive imputation QC report.'''
info = pd.read_csv(info_file, sep='\t',
names=['CHR', 'POS', 'ID', 'REF', 'ALT', 'R2', 'AF'])
# Calculate MAF
info['MAF'] = info['AF'].apply(lambda x: min(x, 1-x))
# Basic statistics
stats = {
'total_variants': len(info),
'mean_r2': info['R2'].mean(),
'median_r2': info['R2'].median(),
'variants_r2_03': (info['R2'] >= 0.3).sum(),
'variants_r2_08': (info['R2'] >= 0.8).sum(),
'pct_r2_03': 100 * (info['R2'] >= 0.3).mean(),
'pct_r2_08': 100 * (info['R2'] >= 0.8).mean(),
}
# By MAF bin
maf_bins = [(0, 0.001), (0.001, 0.01), (0.01, 0.05), (0.05, 0.5)]
for low, high in maf_bins:
mask = (info['MAF'] >= low) & (info['MAF'] < high)
stats[f'mean_r2_maf_{low}_{high}'] = info.loc[mask, 'R2'].mean()
stats[f'n_va
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- examples/imputation_qc.py
- usage-guide.md
FAQ
Что делает скилл bio-phasing-imputation-imputation-qc?
Quality control of phasing and imputation results. Filter by INFO scores, assess accuracy, and prepare imputed data for downstream analysis. Use when filtering low-quality imputed variants or validating imputation accuracy before GWAS.
Как установить скилл bio-phasing-imputation-imputation-qc?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл bio-phasing-imputation-imputation-qc запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…