scikit-allel is the in-memory Python toolkit for population genetics, built on three array types (GenotypeArray, HaplotypeArray, AlleleCountsArray), but its statistics are mostly ratios and densities with one denominator bug in two faces: per-base diversity (pi, theta, Dxy) silently divides by total span instead of accessible bases unless an is_accessible= callability mask is passed, and a genome-wide FST must be a ratio-of-sums (sum(a)/(sum(a)+sum(b)+sum(c))), not a mean of per-SNP FST - scikit-allel deliberately returns the variance components so the aggregation is done correctly. Both bugs run silently and return plausible numbers, so correctness is a choice the analyst makes.
pip install scikit-allel (plus zarr and dask[array] for out-of-core work)is_accessible=; without it the denominator is total span, not callable bp, deflating values and distorting the landscape.sum(a)/(sum(a)+sum(b)+sum(c)) (or sum(num)/sum(den)), never mean(per_snp_fst); average_hudson_fst does the aggregation plus a block-jackknife SE.to_n_alt() defaults to fill=0, which imputes every missing call as homozygous reference and biases PCA/LD toward the reference allele.sfs() is unfolded and expects DERIVED counts, not ALT counts; use sfs_folded(ac) when polarization is uncertain.read_vcf is eager and OOMs on whole genomes; convert once with vcf_to_zarr and use GenotypeDaskArray for scale.Tell your AI agent what you want to do: - "Calculate nucleotide diversity from my VCF using an accessibility mask" - "Compute genome-wide Hudson FST between two populations with a jackknife standard error" - "Run a Patterson f3 admixture test to check whether my target population is admixed" - "LD-prune my genotypes and run a Patterson-scaled PCA" - "Scan phased haplotypes for selection with iHS and standardize the scores" - "Convert my large VCF to Zarr and compute statistics out-of-core"
"Compute pi and Watterson's theta in 100kb windows using a callable-loci mask, and report the accessible base count per window."
"Build a folded site frequency spectrum because I don't trust my ancestral-allele calls."
"Estimate genome-wide FST between population A and population B with a block-jackknife standard error, using the Hudson estimator."
"Give me a per-window FST landscape across the chromosome and flag the top outlier windows."
"Run a Patterson f3 test with my target population as C to see if it is admixed between A and B."
"Compute an ABBA-BABA D-statistic with a jackknife z-score for my four populations."
"LD-prune my genotypes over three rounds and run a randomized Patterson PCA, then plot PC1 vs PC2."
"Compute iHS across phased chromosome 2 and standardize the scores binned by derived-allele frequency."
"Convert my whole-genome VCF to Zarr and count alleles out-of-core with dask."
average_hudson_fst) with a block-jackknife SE, never a mean of per-SNP FST.is_accessible=; the mask must come from coverage/mappability (a callable-loci BED), never from the VCF's variant positions.average_* FST and f-statistic functions: they do the correct ratio-of-sums and a block-jackknife SE in one call.blen) to exceed the LD decay length; too-small blocks correlate and produce anticonservative standard errors and false significance.average_patterson_f3(acc, aca, acb, blen)); a significantly negative f3 (z < ~-3) is the admixture signal.sfs_folded whenever the ancestral allele is uncertain; the plain sfs() is unfolded and silently treats ALT as derived.