| name | bio-ecological-genomics-conservation-genetics |
| description | Assesses genetic health of populations for conservation using effective population size estimation (GONE2 for recent Ne trajectory, NeEstimator for contemporary Ne, Stairway Plot 2 and PSMC for historical Ne), F-statistics (hierfstat), runs of homozygosity (detectRUNS), and genetic diversity metrics. Use when estimating effective population size, detecting inbreeding or bottlenecks, or assessing genetic diversity in threatened species from microsatellite or SNP data. |
| tool_type | mixed |
| primary_tool | hierfstat |
Conservation Genetics
Assesses genetic health of populations through diversity metrics, effective population size estimation, inbreeding detection, and demographic history reconstruction.
Genetic Diversity with hierfstat
Basic population genetics statistics using Weir & Cockerham estimators:
library(hierfstat)
library(adegenet)
data_genind <- read.genepop('populations.gen')
data_hf <- genind2hierfstat(data_genind)
bstats <- basic.stats(data_hf)
cat('Overall Fis:', bstats$overall['Fis'], '\n')
cat('Overall Fst:', bstats$overall['Fst'], '\n')
pop_stats <- data.frame(
Ho = colMeans(bstats$Ho, na.rm = TRUE),
He = colMeans(bstats$Hs, na.rm = TRUE),
Fis = colMeans(bstats$Fis, na.rm = TRUE)
)
pop_stats
Pairwise Fst
pw_fst <- pairwise.WCfst(data_hf)
pw_fst
boot_fst <- boot.ppfst(data_hf, nboot = 1000)
boot_fst$ll
boot_fst$ul
Allelic Richness
Rarefied allelic richness corrects for unequal sample sizes:
ar <- allelic.richness(data_hf)
cat('Rarefied allelic richness per population:\n')
colMeans(ar$Ar, na.rm = TRUE)
Private Alleles
library(poppr)
pa <- private_alleles(data_genind, count.alleles = TRUE)
private_counts <- rowSums(pa > 0)
cat('Private alleles per population:\n')
print(private_counts)
Runs of Homozygosity (ROH)
Detects autozygous segments indicating recent inbreeding:
library(detectRUNS)
runs <- consecutiveRUNS.run(
genotypeFile = 'genotypes.ped',
mapFile = 'genotypes.map',
minSNP = 20,
minLengthBps = 1e6,
maxGap = 1e6,
maxOppRun = 1,
maxMissRun = 2
)
summary_runs <- summaryRuns(runs, genotypeFile = 'genotypes.ped',
mapFile = 'genotypes.map')
froh Froh_inbreedingruns mapFile genome_wide
cat
printfroh
ROH Length Classes
| ROH Length | Approximate Ancestor | Interpretation |
|---|
| > 16 Mb | Parents or grandparents | Very recent inbreeding |
| 4-16 Mb | ~5 generations back | Recent inbreeding |
| 1-4 Mb | ~10-20 generations back | Historical inbreeding/bottleneck |
| < 1 Mb | Deep background | Ancient homozygosity |
plot_DistributionRuns(runs)
Effective Population Size (Ne)
GONE2: Recent Ne Trajectory (Linkage Disequilibrium)
Estimates Ne changes over the last ~200 generations from LD patterns:
./gone2 -t 4 -u 0.05 genotypes.vcf
gone_out <- read.table('OUTPUT_GONE2', header = TRUE, sep = '\t')
pdf('gone2_ne_trajectory.pdf', width = 8, height = 5)
plot(gone_out$generation, gone_out$Ne,
type = 'l', lwd = 2, col = 'blue',
xlab = 'Generations ago', ylab = 'Effective population size (Ne)',
main = 'Recent Ne Trajectory (GONE2)', log = 'y')
dev.off()
cat('Current Ne estimate:', gone_out$Ne[1]
NeEstimator: Contemporary Ne (LD Method)
# NeEstimator v2 uses an option file (.ne2), not command-line flags
# Create option file specifying input, method, and parameters:
# Input: genepop or FSTAT format genotype file
# Method: LD (linkage disequilibrium, single time point)
# Pcrit: 0.02 (exclude alleles with frequency < 2%)
# 0.02 balances bias (lower pcrit) vs precision (higher pcrit)
# Output: tab-separated with Ne point estimate and 95% CI (jackknife + parametric)
# Run: java -jar NeEstimator.jar option_file.ne2
# Build from GitHub: bunop/NeEstimator2.X (requires JDK 1.8+ and Apache Ant)
Stairway Plot 2: Demographic History from SFS
Reconstructs Ne over thousands of generations using the site frequency spectrum:
java -cp stairway_plot_v2.jar Stairbuilder blueprint.txt
bash blueprint.sh
PSMC: Whole-Genome Pairwise Coalescent
For a single diploid genome (whole-genome sequencing):
bcftools mpileup -C50 -Q 30 -q 30 -f reference.fa sample.bam | \
bcftools call -c | vcfutils.pl vcf2fq -d 10 -D 100 > consensus.fq
fq2psmcfa -q20 consensus.fq > consensus.psmcfa
psmc -N25 -t15 -r5 -p '4+25*2+4+6' -o sample.psmc consensus.psmcfa
seq 100 | xargs -P 4 -I {} \
psmc -N25 -t15 -r5 -p '4+25*2+4+6' -b \
-o sample_bootstrap_{}.psmc consensus.psmcfa
psmc_plot.pl -u 1.4e-8 -g 5 -p sample_psmc_plot sample.psmc
Ne Interpretation Thresholds
| Ne Value | Conservation Status | Rationale |
|---|
| Ne < 50 | Critical | Inbreeding depression risk (50/500 rule, Franklin 1980) |
| Ne = 50-500 | Vulnerable | Sufficient to avoid inbreeding but limited adaptive potential |
| Ne > 500 | Viable | Adequate for long-term adaptive evolution |
| Ne/N ratio | ~0.1-0.3 typical | Ne is usually 10-30% of census size |
Bottleneck Detection
library(hierfstat)
bstats <- basic.stats(data_hf)
he_obs <- bstats$perloc$Hs
k_alleles <- sapply(data_hf[, -1], function(x) length(unique(na.omit(x))))
n_samples <- nrow(data_hf)
heq_iam <- 1 - 1 k_alleles
wilcox.testhe_obs heq_iam paired alternative
Related Skills
- landscape-genomics - Adaptive variation and genotype-environment associations
- species-delimitation - Taxonomic unit definition for conservation
- population-genetics/population-structure - Population stratification
- population-genetics/selection-statistics - Selection signatures
- variant-calling/vcf-basics - VCF input from RADseq/WGS