Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

bio-population-genetics-scikit-allel-analysis

БесплатноЗапускает вложенные скриптыНе проверен

In-memory Python population genetics with scikit-allel - GenotypeArray/HaplotypeArray/AlleleCountsArray, diversity (pi, theta, Tajima's D), SFS, FST…

lilinjiот lilinji★ 18 звёзд на GitHub

Об этом скилле

Version Compatibility

Reference examples tested with: scikit-allel 1.3.13+, numpy 1.26+, zarr 2.18+.

Before using code patterns, verify installed versions match. If versions differ:

  • Python: pip show <package> then help(module.function) to check signatures

If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.

Version traps that change results, not just syntax: scikit-allel is in MAINTENANCE mode (latest line v1.3.x, e.g. v1.3.13 Sep 2024); the README names sgkit (xarray+dask) as the successor but states it is "not yet at feature parity", so scikit-allel remains the pragmatic choice for established stat workflows. average_patterson_f3/average_patterson_d are the current names; pre-2020 code used blockwise_patterson_* (gone). to_n_alt() default is fill=0, not fill=-1. read_vcf is eager and loads the whole file into RAM. The single source of truth for versions is this block, not headings.

scikit-allel Analysis

"Analyze population genetics in Python" -> Read a VCF into array structures, then compute frequency-, diversity-, differentiation-, and haplotype-based statistics with correct denominators.

  • Python: allel.GenotypeArray, allel.AlleleCountsArray, allel.windowed_diversity(..., is_accessible=), allel.average_hudson_fst, allel.pca

Scope: in-memory and dask/zarr scikit-allel analysis - the array-API mechanics of the data model, diversity/SFS, FST and f/D admixture statistics, LD pruning, PCA, and selection-scan computation. PLINK-format QC routes to plink-basics; PCA/ADMIXTURE via CLI tools to population-structure; selection-scan DESIGN (standardization, outlier calling, demographic confounding) to selection-statistics; phased input to phasing-imputation/haplotype-phasing; VCF generation to variant-calling/vcf-basics.

The Single Most Important Insight -- one denominator bug, two faces

  1. Almost every statistic scikit-allel computes is a RATIO or a DENSITY, and the two ways the denominator is silently wrong both return a finite, plausible, unflagged number.
  2. Face (a) - the per-base denominator: pi, Watterson's theta, and Dxy divide a segregating-site sum by the number of bases; omit is_accessible= and they divide by total span (stop-start+1) instead of callable bp, deflating values 2-5x AND distorting the genome-wide landscape because callability varies per window.
  3. Face (b) - FST is a ratio of variance components: the correct multi-locus estimate is sum(a)/(sum(a)+sum(b)+sum(c)), NOT mean(per_snp_fst) (which is rare-variant-dominated and biased, Bhatia 2013); scikit-allel returns the (a,b,c) components from weir_cockerham_fst and (num,den) from hudson_fst/patterson_fst precisely to force ratio-of-sums.
  4. Both bugs run silently with no exception or warning, so correctness is a design decision the analyst makes, not something the library enforces.

Tool Taxonomy -- the data model and the scaling path

Object / path Shape / form Role When
GenotypeArray (n_variants, n_samples, ploidy) int8, -1 = missing the fundamental call array diploid genotypes from calldata/GT
HaplotypeArray (n_variants, n_haplotypes) phased chromosomes iHS/XP-EHH/nSL/Garud H (REQUIRE phasing)
AlleleCountsArray (n_variants, n_alleles) int32 currency of all frequency stats gt.count_alleles(); ignores -1
to_n_alt 012 matrix (n_variants, n_samples) input to PCA/LD gt.to_n_alt(fill=...) (default fill=0 imputes to ref)
in-memory numpy dense, all in RAM fast, simple fits-in-memory regions/chromosomes
GenotypeDaskArray + zarr chunked, on-disk, lazy out-of-core / parallel biobank-scale; vcf_to_zarr once then dask
scikit-allel maintenance mode, v1.3.x established stat workflows the pragmatic default today
sgkit xarray+dask, active successor, NOT yet feature-parity greenfield biobank-scale infrastructure

Decision Tree by Scenario

Scenario Use Why
Per-base pi/theta/Dxy windowed_diversity(..., is_accessible=mask) without the mask the per-base denominator is total span, not callable bp
Genome-wide FST point estimate + SE average_hudson_fst(ac1, ac2, blen) ratio-of-sums + block-jackknife done correctly; Hudson is robust to unequal n (Bhatia 2013)
FST landscape across the genome moving_hudson_fst / windowed_weir_cockerham_fst per-window ratio aggregation, not mean(per_snp_fst)
SFS without a confident ancestral allele sfs_folded(ac) folds on minor-allele count; sfs() is unfolded and treats ALT as derived
Test if pop C is admixed average_patterson_f3(acc, aca, acb, blen) significantly negative f3 (z < ~-3) is the formal admixture test; C goes FIRST
LD-prune before PCA locate_unlinked(gn) iterated ~3 rounds one pass leaves
Полный SKILL.md на GitHub

Установить bio-population-genetics-scikit-allel-analysis в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

examples/basic_analysis.pyusage-guide.md

FAQ

Что делает скилл bio-population-genetics-scikit-allel-analysis?

In-memory Python population genetics with scikit-allel - GenotypeArray/HaplotypeArray/AlleleCountsArray, diversity (pi, theta, Tajima's D), SFS, FST (Weir-Cockerham, Hudson, Patterson), f3/D admixture stats, LD pruning, PCA, and selection scans (iHS, XP-EHH, nSL, Garud H). Nearly every statistic is a ratio or density with one silent denominator bug in two faces: omit is_accessible= and per-base pi/theta divide by total span not accessible bp (deflated 2-5x); average per-SNP FST instead of sum(a)/(sum(a)+sum(b)+sum(c)) and the estimate is rare-variant-biased - scikit-allel returns the (a,b,c) and (num,den) components on purpose to force ratio-of-sums. to_n_alt default fill=0 imputes missing to reference; sfs() is unfolded and wants derived not alt counts; iHS/XP-EHH need phased data and standardization. Use when computing population-genetics statistics in Python, scanning for selection, or building array pipelines. For PLINK QC see plink-basics; for VCF input see variant-calling/vcf-basics.

Как установить скилл bio-population-genetics-scikit-allel-analysis?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл bio-population-genetics-scikit-allel-analysis запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить bio-population-genetics-scikit-allel-analysis с