[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ECZ1WT4HMH7SY04EJJ9QEM":3,"skill-same:01M7ECZ1WT4HMH7SY04EJJ9QEM":66},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":14,"repositoryHtmlUrl":33,"repositoryHomepageUrl":33,"ownerHtmlUrl":34,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":35,"install":36,"resources":49},"01M7ECZ1WT4HMH7SY04EJJ9QEM","bio-ecological-genomics-landscape-genomics",null,"Tests genotype-environment associations and identifies adaptive loci while correcting for the four-confound landscape (structure, demography, background selection, sampling design) using LFMM2 with mandatory K via sNMF cross-entropy elbow (LEA 3), BayPass Core\u002FAUX\u002FC2\u002FIS with Omega covariance matrix, RDA \u002F pRDA for polygenic adaptation (Forester 2018; requires imputed genotypes), OutFLANK with trimmed FST null, pcadapt, gradient forests (Ellis-Smith-Pitcher 2012, NOT mis-cited Ellis-Manel), Capblancq & Forester 2021 RDA Swiss-army-knife, genomic-offset prediction with Lind & Lotterhos 2025 three-regime caveat, Lotterhos-Whitlock sampling optima, Wang & Bradburd 2014 IBD vs IBE, and Circuitscape + ResistanceGA. Use when identifying adaptive loci across gradients, choosing K for LFMM2, deciding among GEA methods, predicting maladaptation with the novel-environment caveat, distinguishing IBD vs IBE, or optimizing sampling design.","Mr-Nobody-Anonymous\u002FAll-skills","Mr-Nobody-Anonymous","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184253119?v=4","01M7AEXFJHKTYQW5R0ZCQQTWFV","anonymous","01M7C00M3GQR4QKP9GZA42GFAK",0,"MIT","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-ecological-genomics-landscape-genomics\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: bio-ecological-genomics-landscape-genomics\ndescription: Tests genotype-environment associations and identifies adaptive loci while correcting for the four-confound landscape (structure, demography, background selection, sampling design) using LFMM2 with mandatory K via sNMF cross-entropy elbow (LEA 3), BayPass Core\u002FAUX\u002FC2\u002FIS with Omega covariance matrix, RDA \u002F pRDA for polygenic adaptation (Forester 2018; requires imputed genotypes), OutFLANK with trimmed FST null, pcadapt, gradient forests (Ellis-Smith-Pitcher 2012, NOT mis-cited Ellis-Manel), Capblancq & Forester 2021 RDA Swiss-army-knife, genomic-offset prediction with Lind & Lotterhos 2025 three-regime caveat, Lotterhos-Whitlock sampling optima, Wang & Bradburd 2014 IBD vs IBE, and Circuitscape + ResistanceGA. Use when identifying adaptive loci across gradients, choosing K for LFMM2, deciding among GEA methods, predicting maladaptation with the novel-environment caveat, distinguishing IBD vs IBE, or optimizing sampling design.\ntool_type: r\nprimary_tool: LEA\nsource: \"https:\u002F\u002Fgithub.com\u002FGPTomics\u002FbioSkills\"\nsource_repository: \"GPTomics\u002FbioSkills\"\nsource_path: \"ecological-genomics\u002Flandscape-genomics\u002FSKILL.md\"\nlicense: \"MIT\"\nimported_at: \"2026-09-20\"\n---\n\n## Version Compatibility\n\nReference examples tested with: LEA 3.14+ (lfmm2 via LEA 3), pcadapt 4.3+, OutFLANK 0.2+, vegan 2.6+, gradientForest 0.1-32+, terra 1.7+, qvalue 2.34+, BayPass 2.3+\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- R: `packageVersion('\u003Cpkg>')` then `?function_name` to verify parameters\n- CLI: `\u003Ctool> --version` then `\u003Ctool> --help` to confirm flags\n\nIf code throws ImportError, AttributeError, or TypeError, introspect the installed\npackage and adapt the example to match the actual API rather than retrying.\n\n# Landscape Genomics\n\n**\"Find loci associated with environmental adaptation in my populations\"** -> Genotype-environment association with K-selected latent-factor correction, multivariate RDA for polygenic signal, paired with demography-calibrated FST outliers; genomic-offset prediction with explicit prediction-novelty regime characterization.\n- R: `LEA::lfmm2()` (modern; via LEA 3) for univariate GEA with cross-entropy-elbow K choice\n- R: `vegan::rda()` with `Condition()` for partial-RDA polygenic GEA\n- R: `OutFLANK::OutFLANK()` for demography-calibrated FST outliers\n- R: `pcadapt::pcadapt()` for PC-based scans without environmental data\n- CLI: `g_baypass` for BayPass Bayesian Core\u002FAUX\u002FC2\u002FIS analyses\n\n## The Single Most Important Modern Insight -- GEA is a Four-Confound Problem, Not a Signal-Plus-Noise Problem\n\nThe number-one failure mode in landscape genomics is treating \"is locus X associated with environment Y\" as a simple signal-extraction problem (the NimBios working group consolidated this view in Hoban 2016 *Am Nat* 188:379-397). **GEA has FOUR concurrent confounds**:\n1. **Population structure** — IBD-driven allele-frequency gradients track distance, which correlates with most environmental variables\n2. **Demographic history** — range expansion creates allele-frequency clines along the expansion axis that mimic selection (Lotterhos & Whitlock 2014 *Mol Ecol* 23:2178-2192)\n3. **Background and linked selection** — reduces diversity in low-recombination regions, inflating apparent local-FST signals\n4. **Sampling design** — non-random spatial sampling creates spurious GEA signals (Lotterhos & Whitlock 2015 *Mol Ecol* 24:1031-1046; **paired contrasts > random > transects** when demography is concerning)\n\nA second cornerstone: **Forester et al. 2018 established RDA as the best polygenic-adaptation detector** but with a caveat — RDA performance requires imputed genotypes (no missing data) and is best for linear-gradient environments. For monogenic strong-selection loci, OutFLANK and BayPass-C2 remain competitive.\n\nA third: **Genomic offset has three regimes** (Lind & Lotterhos 2025 *Mol Ecol Resour* 25:e14008): works well for interpolation (similar-to-training environments), degrades gracefully for modest extrapolation, FAILS for highly novel future environments. Reporting a single offset map without characterizing prediction-novelty is methodologically incomplete. For the broader eco-evolutionary integration framework, see Aguirre-Liguori 2021 *Nat Ecol Evol* 5:1350-1360.\n\n## Algorithmic Taxonomy\n\n| Method | Type | Strength | Fails when |\n|--------|------|----------|------------|\n| FST outliers (naive) | Univariate per-locus | Simple; widely understood | Inflated FDR under demography (Lotterhos & Whitlock 2014) |\n| OutFLANK (Whitlock & Lotterhos 2015) | Univariate FST with trimmed null | Robust to demography via trimmed-tail null | Conservative; misses weak-effect polygenic |\n| pcadapt (Luu 2017) | PC-based Mahalanobis | Handles continuous structure; no need to define populations | Detects axes-of-divergence loci; not environment-specific |\n| LFMM (Frichot 2013) | MCMC mixed model with latent factors | Original framework | Slow; superseded by LFMM2 |\n| LFMM2 (Caye 2019) | LSE-based mixed model with K latent factors | Fast; orders of magnitude faster than LFMM; modern default | K choice is critical; wrong K silently invalidates results |\n| BayPass Core (Gautier 2015) | Bayesian FST with covariance matrix Omega | Explicit shared-history correction via Omega | Computationally heavy; convergence needs care |\n| BayPass AUX | Bayesian env association with binary auxiliary variable | Posterior gives Bayes Factor per locus | Same as Core |\n| BayPass C2 | Bayesian contrast between two pre-defined groups | Like Bayesian Fisher exact | Requires pre-defined groups, not continuous env |\n| BayPass IS | Importance-sampling joint Bayesian | Multiple covariates simultaneously | Most computationally expensive |\n| RDA (Forester 2018) | Multivariate constrained ordination | HIGH power and LOW FDR for polygenic adaptation | Requires imputed genotypes; less power for monogenic |\n| pRDA (partial RDA) | RDA conditioning out population structure | Controls for structure explicitly | Conservative; depends on which axes are conditioned out |\n| Gradient forests (Ellis 2012; Ellis-Smith-Pitcher) | Random-forest non-linear GEA | Detects non-linear gene-environment | Less interpretable; no formal p-values |\n| RDA offset (Capblancq 2021) | Linear genomic-offset prediction | Linear gradient assumption | Fails under highly novel future climate (Lind 2025) |\n| Gradient-forest offset | Non-linear genomic-offset prediction | Captures non-linearity | Same three-regime caveat |\n| RONA | Locus-by-locus offset | Simple, transparent | Locus-specific; ignores multilocus structure |\n| Circuitscape (McRae 2008) | Circuit-theory landscape resistance | Integrates ALL paths; not single-best | Symmetric only; asymmetric landscapes need directional methods |\n| ResistanceGA (Peterman 2018) | Genetic-algorithm optimization of resistance | Optimizes cost surface itself | MLPE parameterization needed (specific lmer form) |\n\n## Decision Tree by Scenario\n\n| Scenario | Recommended approach | Why |\n|----------|---------------------|-----|\n| Monogenic local adaptation | OutFLANK or BayPass Core; cross-check with simulations | Demography-calibrated null |\n| Polygenic local adaptation | RDA with environmental matrix; pRDA conditioning on structure | Forester 2018 superior power + lower FDR |\n| Environmental association with structure correction | LFMM2 (K from sNMF cross-entropy elbow) | Modern default; orders of magnitude faster than LFMM |\n| Binary group contrast | BayPass C2 | Like Bayesian Fisher exact |\n| Joint multi-covariate Bayesian inference | BayPass IS | Multiple env simultaneously |\n| Quantifying maladaptation under climate change | RDA offset OR gradientForest offset | Report Lind 2025 caveat: works for interpolation, fails for novel |\n| Multi-method consensus | Run OutFLANK + LFMM2 + BayPass; overlap is high-confidence | Method differences = methodological coverage |\n| Mapping landscape resistance | Circuitscape + ResistanceGA optimization | Circuitscape integrates all paths; ResistanceGA optimizes the surface |\n| Distinguishing IBD vs IBE | dbRDA variance partitioning (geographic + env) | Mantel-based methods have known autocorrelation issues |\n| Sampling design optimization | Paired contrasts at environmental endpoints; cite Lotterhos & Whitlock 2015 | Most powerful under demographic concern |\n| Polyploid species | polyRAD \u002F fitPoly \u002F updog FIRST; then standard GEA | Diploid-assuming tools give biased FST estimates |\n\n## LFMM2 with Mandatory K Selection\n\n**Goal:** Identify loci significantly associated with environmental variables while controlling for unobserved demographic structure via K latent factors.\n\n**Approach:** Run sNMF on the genotype matrix across K = 1...10 (or higher), compute cross-entropy at each K, pick K at the elbow (where cross-entropy first plateaus), then pass that K to `LEA::lfmm2()`. Wrong K silently invalidates results — too few K means residual structure confounds environment; too many K absorbs the environmental signal.\n\n```r\nlibrary(LEA)\nlibrary(qvalue)\n\n# Convert VCF -> LFMM\u002FGENO format\nvcf2lfmm('variants.vcf', 'genotypes.lfmm')\nvcf2geno('variants.vcf', 'genotypes.geno')\n\n# MANDATORY K selection via sNMF cross-entropy elbow\n# Run multiple repetitions per K (5 minimum) for stability\nsnmf_result \u003C- snmf('genotypes.geno', K = 1:10, repetitions = 5,\n                     entropy = TRUE, project = 'new')\nce_values \u003C- sapply(1:10, function(k) min(cross.entropy(snmf_result, K = k)))\nplot(1:10, ce_values, xlab = 'K', ylab = 'Cross-entropy',\n     pch = 19, col = 'blue', type = 'b')\n\n# Pick K at elbow (first plateau); report sensitivity across K\nbest_K \u003C- which.min(ce_values)\n\n# Run LFMM2 with selected K\ngenotypes \u003C- read.lfmm('genotypes.lfmm')\nenv_vars \u003C- read.env('environment.env')\nlfmm_result \u003C- lfmm2(input = genotypes, env = env_vars, K = best_K)\n\n# Test associations with genomic-control calibration\npvalues \u003C- lfmm2.test(lfmm_result, input = genotypes, env = env_vars,\n                       full = TRUE, genomic.control = TRUE)\n\n# Check genomic inflation factor (GIF \u002F lambda)\n# Target ~1.0; > 1.5 means insufficient structure correction (try larger K)\n# \u003C 0.5 means over-correction (try smaller K)\ngif \u003C- median(qchisq(1 - pvalues$pvalues[, 1], df = 1)) \u002F qchisq(0.5, df = 1)\ncat('Genomic inflation factor (lambda):', round(gif, 3), '\\n')\n\n# Storey FDR control\nqvals \u003C- qvalue(pvalues$pvalues[, 1])$qvalues\ncandidates \u003C- which(qvals \u003C 0.05)\ncat('Candidate adaptive loci (q \u003C 0.05):', length(candidates), '\\n')\n\n# Sensitivity check: re-run with K +\u002F- 1 and report overlap of candidates\n# Loci detected only at one K are sensitive to latent-factor choice; flag as lower-confidence\n```\n\n## RDA — Capblancq & Forester 2021 Swiss-Army-Knife Workflow\n\n**Goal:** Detect polygenic local adaptation via multivariate constrained ordination, with optional climate-offset prediction.\n\n**Approach:** Apply the Capblancq & Forester 2021 RDA workflow: (1) variable selection via forward selection with adjusted R^2; (2) variance partitioning into pure-environment \u002F pure-spatial \u002F shared; (3) GEA outlier identification at SD > 3 on RDA axes 1-3; (4) adaptive-index computation; (5) genomic-offset prediction with the Lind 2025 three-regime caveat. **CRITICAL: genotypes must be imputed before RDA** (no missing data); cite Forester 2018 for the polygenic-power result.\n\n```r\nlibrary(vegan)\n\n# CRITICAL: impute missing genotypes BEFORE RDA (Forester 2018 benchmark requirement)\n# Column-mean imputation per locus is the simplest valid choice;\n# population-stratified mean imputation is preferred when populations are known.\n# For LEA-generated data, LEA::impute() is the canonical option.\nfor (j in seq_len(ncol(allele_freq))) {\n    col_mean \u003C- mean(allele_freq[, j], na.rm = TRUE)\n    allele_freq[is.na(allele_freq[, j]), j] \u003C- col_mean\n}\n\n# Partial RDA conditioning on population structure (e.g., Q-matrix from sNMF)\n# This is pRDA per Capblancq 2021\nrda_result \u003C- rda(allele_freq ~ temperature + precipitation + altitude +\n                  Condition(as.matrix(q_matrix)), data = env_data)\n\n# Permutation test\nanova(rda_result, permutations = 999)\n\n# Variance partitioning (Capblancq workflow step 2)\nvp \u003C- varpart(allele_freq, env_data, q_matrix)\nvp$part$fract  # pure env \u002F shared \u002F pure structure \u002F residual\n\n# GEA outliers (z-score > 3 on RDA axes 1-3)\n# Threshold of 3 SD is conservative; for polygenic adaptation, may use 2.5 SD\nloadings \u003C- scores(rda_result, choices = 1:3, display = 'species')\nzscores \u003C- apply(loadings, 2, function(x) (x - mean(x)) \u002F sd(x))\nrda_candidates \u003C- which(apply(abs(zscores), 1, max) > 3)\ncat('RDA candidate loci (|z| > 3):', length(rda_candidates), '\\n')\n```\n\n## BayPass — Core, AUX, C2, IS Models\n\n**Goal:** Bayesian Genotype-Environment Association with explicit population-history correction via covariance matrix Omega.\n\n**Approach:** Convert VCF to BayPass's space-separated allele-count format. Run Core (estimates Omega; like Bayesian FST); use AUX for binary env-association testing; C2 for two-group contrast; IS for joint multi-covariate.\n\n```bash\n# BayPass input: space-separated allele counts, NOT VCF\n# Use vcf2baypass.pl OR bcftools query to convert\n\n# Core model: estimate Omega (population covariance from genome-wide SNPs)\ng_baypass -gfile geno_BayPass.txt -outprefix core_run -nthreads 4\n\n# AUX (binary auxiliary variable): test environmental association\n# omegafile from Core run; covariates is samples x env file\ng_baypass -gfile geno_BayPass.txt -efile env_BayPass.txt \\\n          -omegafile core_run_mat_omega.out \\\n          -outprefix aux_run -auxmodel -nthreads 4\n\n# C2 (contrast between two pre-defined groups)\n# contrasts.txt: 1 = group 1, -1 = group 2, 0 = excluded\ng_baypass -gfile geno_BayPass.txt -contrastfile contrasts.txt \\\n          -omegafile core_run_mat_omega.out \\\n          -outprefix c2_run -nthreads 4\n\n# Bayes Factor > 20 dB: strong evidence\n# Bayes Factor > 30 dB: decisive evidence\n# Convert: BFis (decibel scale) = 10 * log10(BF)\n```\n\n## Genomic Offset — Lind & Lotterhos 2025 Three-Regime Framework\n\n**Goal:** Predict maladaptation under future climate using genomic-offset methods (gradientForest, RDA-offset, LFMM2offset, RONA) while characterizing prediction-novelty. For the broader genomic-prediction review (foundation of the offset literature), see Capblancq et al. 2020 *Annu Rev Ecol Evol Syst* 51:245-269.\n\n**Approach:** Compute offset per location as the distance in transformed genomic-environmental space between current and future predicted climate. CRITICAL: characterize whether each prediction falls into regime 1 (interpolation), regime 2 (modest extrapolation), or regime 3 (highly novel, where offset is uninformative or misleading). Report offset alongside prediction-novelty mapping.\n\n```r\nlibrary(gradientForest)\nlibrary(terra)\n\n# Fit gradient forests on candidate loci x environment\ngf \u003C- gradientForest(cbind(env_predictors, allele_data),\n                     predictor.vars = colnames(env_predictors),\n                     response.vars = colnames(allele_data),\n                     ntree = 500, trace = FALSE)\n\n# Variable importance (which env drives most allele turnover)\nplot(gf, plot.type = 'Overall.Importance')\n\n# Predict genetic offset under current vs future\ncurrent \u003C- rast('bioclim_current.tif')\nfuture \u003C- rast('bioclim_2070_ssp585.tif')\ncurrent_vals \u003C- extract(current, sampling_coords)\nfuture_vals \u003C- extract(future, sampling_coords)\n\n# Genomic offset = Euclidean distance in transformed space\ncurrent_transformed \u003C- predict(gf, current_vals)\nfuture_transformed \u003C- predict(gf, future_vals)\ngenetic_offset \u003C- sqrt(rowSums((current_transformed - future_transformed)^2))\n\n# CRITICAL: characterize prediction-novelty regime per location\n# For each future location, compute distance to nearest training-data envelope\n# locations in regime 3 (high novelty) should have offset values down-weighted\n# in interpretation per Lind & Lotterhos 2025\n\n# Cross-validation with multiple offset methods (gradientForest + RDA + LFMM2offset)\n# Robust signals appear in ALL methods; method-specific offset is suspect\n```\n\n## Per-Method Failure Modes\n\n### LFMM2 with wrong K silently invalidates results\n\n**Trigger:** Running LFMM2 with K too small (residual structure confounds environment) or K too large (latent factors absorb the environmental signal).\n\n**Mechanism:** LFMM2 uses K latent factors to capture unobserved population structure. Wrong K means structure is either undercorrected (false positives) or overcorrected (false negatives), with no error message.\n\n**Symptom:** Thousands of significant SNPs (too small K) OR almost none (too large K); genomic inflation factor lambda far from 1.0.\n\n**Fix:** Use sNMF cross-entropy elbow as the primary K choice; run LFMM2 at K-1, K, K+1 and report sensitivity; flag loci detected at only one K as lower-confidence.\n\n### RDA on un-imputed genotypes silently degrades\n\n**Trigger:** Running RDA on an allele-frequency matrix with NA values without imputation.\n\n**Mechanism:** RDA cannot handle missing data internally; default behavior is to use `na.omit` which drops loci AND samples. Forester 2018's RDA-dominance benchmark assumed imputed genotypes.\n\n**Symptom:** Effective sample size much smaller than expected; results sensitive to which loci have missing data.\n\n**Fix:** Impute missing genotypes (mean within population, kNN, or `snmf::impute()`) BEFORE running RDA.\n\n### Genomic offset reported without prediction-novelty characterization\n\n**Trigger:** Producing a country-wide genomic-offset map without indicating which areas are inside vs outside the training-data envelope.\n\n**Mechanism:** Per Lind & Lotterhos 2025, genomic-offset accuracy declines with novelty of the predicted environment. Highly novel future climates fall in \"regime 3\" where offset is uninformative.\n\n**Symptom:** Map shows highest predicted maladaptation in geographically extreme areas; cross-validation with multiple methods shows divergent predictions.\n\n**Fix:** Compute prediction novelty per location (e.g., Mahalanobis distance to training envelope); annotate offset values with their regime; report cross-method consensus rather than single-method offset.\n\n### OutFLANK applied to continuous sampling design\n\n**Trigger:** Running OutFLANK on continuous-gradient samples treated as a single \"population\".\n\n**Mechanism:** OutFLANK assumes distinct, well-defined populations for FST calculation. Continuous sampling does not have natural population delimitation; the FST distribution depends arbitrarily on how samples are binned.\n\n**Symptom:** OutFLANK results unstable to alternative population definitions; very few or impossibly many outliers.\n\n**Fix:** Use LFMM2 or RDA for continuous gradient data; OutFLANK is appropriate when distinct populations are defined a priori.\n\n### LDNe physical-linkage trap on RAD-seq SNPs\n\n**Trigger:** Running LFMM2 \u002F RDA \u002F OutFLANK on RAD-seq SNPs without LD pruning.\n\n**Mechanism:** Physical linkage among RAD-seq SNPs creates correlated test statistics; outlier counts are inflated by chromosomal clustering rather than independent adaptation signal.\n\n**Symptom:** Outliers cluster in large blocks along the genome; individual-locus inference is dominated by linkage.\n\n**Fix:** LD-prune SNPs (PLINK `--indep-pairwise 50 5 0.2`) before GEA; OR thin to >= 1 cM apart with a genetic map.\n\n## Quantitative Thresholds\n\n| Threshold | Value | Source \u002F rationale |\n|-----------|-------|-------------------|\n| LFMM2 K selection | Cross-entropy elbow from sNMF (`LEA`) | Caye 2019; sensitivity check at K-1, K+1 |\n| Genomic inflation factor target | Lambda ~ 1.0 | > 1.5 = under-correction; \u003C 0.5 = over-correction |\n| FDR threshold | q \u003C 0.05 (Storey) | qvalue package; more powerful than BH for genomic data |\n| RDA outlier threshold | abs(z) > 3 on RDA axes 1-3 | Capblancq & Forester 2021 conservative; 2.5 for polygenic |\n| BayPass Bayes Factor | BF > 20 dB strong; > 30 dB decisive | Gautier 2015 convention |\n| OutFLANK trim fractions | LeftTrim = RightTrim = 0.05 | Whitlock & Lotterhos 2015 default |\n| OutFLANK Hmin | 0.1 | Exclude low-heterozygosity unreliable FST |\n| Forester 2018 RDA imputation | Required (no missing data) | RDA performance benchmark assumed imputed genotypes |\n| Lind & Lotterhos 2025 offset regimes | Regime 1 (interpolation) \u002F 2 (modest extrapolation) \u002F 3 (highly novel) | Characterize per location |\n| Lotterhos & Whitlock 2015 sampling design | Paired contrasts > random > transects under demographic concern | Genome-scan power |\n\n## Common errors\n\n| Error | Cause | Solution |\n|-------|-------|----------|\n| LFMM2 returns thousands of significant SNPs | K too small | Increase K via sNMF cross-entropy elbow |\n| LFMM2 returns no significant SNPs | K too large; signal absorbed | Decrease K |\n| Lambda (GIF) >> 1.5 | Insufficient structure correction | Increase K or add structure covariate |\n| RDA effective N much smaller than total | NA values in allele matrix | Impute before RDA |\n| pcadapt screeplot shows no elbow | Continuous population structure or single-cline data | Switch to LFMM2 or RDA |\n| OutFLANK error about populations | Continuous sampling, no defined populations | Use LFMM2 \u002F RDA instead |\n| BayPass \"format error\" | Passing VCF directly | Convert to space-separated allele counts via vcf2baypass.pl |\n| Gradient-forest plot blank | Insufficient SNPs in candidate set | Increase candidate-locus pool |\n| Genomic offset highest in intermediate climate | PC axes capture environment; structure absorbing signal | pRDA conditioning on geographic distance |\n\n## References\n\n- Frichot E, Schoville SD, Bouchard G, François O (2013) LFMM. *Mol Biol Evol* 30(7):1687-1699. doi:10.1093\u002Fmolbev\u002Fmst063\n- Caye K, Jumentier B, Lepeule J, François O (2019) LFMM 2: fast LSE estimator. *Mol Biol Evol* 36(4):852-860. doi:10.1093\u002Fmolbev\u002Fmsz008\n- Gain C, François O (2021) LEA 3 package. *Mol Ecol Resour* 21(8):2738-2748. doi:10.1111\u002F1755-0998.13366\n- Gautier M (2015) BayPass. *Genetics* 201(4):1555-1579. doi:10.1534\u002Fgenetics.115.181453\n- Forester BR, Lasky JR, Wagner HH, Urban DL (2018) Multilocus adaptation methods: RDA superior. *Mol Ecol* 27(9):2215-2233. doi:10.1111\u002Fmec.14584\n- Capblancq T, Forester BR (2021) RDA Swiss-army-knife for landscape genomics. *Methods Ecol Evol* 12(12):2298-2309. doi:10.1111\u002F2041-210X.13722\n- Capblancq T, Fitzpatrick MC, Bay RA, Exposito-Alonso M, Keller SR (2020) Genomic prediction of (mal)adaptation. *Annu Rev Ecol Evol Syst* 51:245-269. doi:10.1146\u002Fannurev-ecolsys-020720-042553\n- Whitlock MC, Lotterhos KE (2015) OutFLANK. *Am Nat* 186(S1):S24-S36. doi:10.1086\u002F682949\n- Lotterhos KE, Whitlock MC (2014) Demographic confounders of FST outlier tests. *Mol Ecol* 23(9):2178-2192. doi:10.1111\u002Fmec.12725\n- Lotterhos KE, Whitlock MC (2015) Sampling-design optimization for genome scans. *Mol Ecol* 24(5):1031-1046. doi:10.1111\u002Fmec.13100\n- Lind BM, Lotterhos KE (2025) Accuracy of predicting maladaptation. *Mol Ecol Resour* 25:e14008. doi:10.1111\u002F1755-0998.14008\n- Wang IJ, Bradburd GS (2014) Isolation by environment (IBD vs IBE). *Mol Ecol* 23(23):5649-5662. doi:10.1111\u002Fmec.12938\n- McRae BH, Dickson BG, Keitt TH, Shah VB (2008) Circuitscape circuit-theory. *Ecology* 89(10):2712-2724. doi:10.1890\u002F07-1861.1\n- Peterman WE (2018) ResistanceGA. *Methods Ecol Evol* 9(6):1638-1647. doi:10.1111\u002F2041-210X.12984\n- Ellis N, Smith SJ, Pitcher CR (2012) Gradient forests. *Ecology* 93(1):156-168. doi:10.1890\u002F11-0252.1\n- Aguirre-Liguori JA, Ramírez-Barahona S, Gaut BS (2021) Evolutionary genomics of climate response. *Nat Ecol Evol* 5(10):1350-1360. doi:10.1038\u002Fs41559-021-01526-9\n- Hoban S, Kelley JL, Lotterhos KE et al. (2016) Finding the genomic basis of local adaptation. *Am Nat* 188(4):379-397. doi:10.1086\u002F688018\n- Luu K, Bazin E, Blum MGB (2017) pcadapt: an R package to perform genome scans for selection based on principal component analysis. *Mol Ecol Resour* 17(1):67-77. doi:10.1111\u002F1755-0998.12592\n- Legendre P, Fortin M-J (2010) Comparison of the Mantel test and alternative approaches for detecting complex multivariate relationships. *Mol Ecol Resour* 10(5):831-844. doi:10.1111\u002Fj.1755-0998.2010.02866.x\n\n## Related Skills\n\n- ecological-genomics\u002Fconservation-genetics - Population genetic health (Ne, F_ROH); use ESU\u002FMU framework not species delimitation for management units\n- ecological-genomics\u002Fcommunity-ecology - Environmental gradient analysis for species composition (analog of GEA for community data)\n- population-genetics\u002Fselection-statistics - Selection scans in human population genetics\n- population-genetics\u002Fpopulation-structure - STRUCTURE \u002F ADMIXTURE for substructure inference\n- variant-calling\u002Fvcf-basics - VCF preparation from RAD-seq or WGS\n","## Version Compatibility\n\nReference examples tested with: LEA 3.14+ (lfmm2 via LEA 3), pcadapt 4.3+, OutFLANK 0.2+, vegan 2.6+, gradientForest 0.1-32+, terra 1.7+, qvalue 2.34+, BayPass 2.3+\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- R: `packageVersion('\u003Cpkg>')` then `?function_name` to verify parameters\n- CLI: `\u003Ctool> --version` then `\u003Ctool> --help` to confirm flags\n\nIf code throws ImportError, AttributeError, or TypeError, introspect the installed\npackage and adapt the example to match the actual API rather than retrying.\n\n# Landscape Genomics\n\n**\"Find loci associated with environmental adaptation in my populations\"** -> Genotype-environment association with K-selected latent-factor correction, multivariate RDA for polygenic signal, paired with demography-calibrated FST outliers; genomic-offset prediction with explicit prediction-novelty regime characterization.\n- R: `LEA::lfmm2()` (modern; via LEA 3) for univariate GEA with cross-entropy-elbow K choice\n- R: `vegan::rda()` with `Condition()` for partial-RDA polygenic GEA\n- R: `OutFLANK::OutFLANK()` for demography-calibrated FST outliers\n- R: `pcadapt::pcadapt()` for PC-based scans without environmental data\n- CLI: `g_baypass` for BayPass Bayesian Core\u002FAUX\u002FC2\u002FIS analyses\n\n## The Single Most Important Modern Insight -- GEA is a Four-Confound Problem, Not a Signal-Plus-Noise Problem\n\nThe number-one failure mode in landscape genomics is treating \"is locus X associated with environment Y\" as a simple signal-extraction problem (the NimBios working group consolidated this view in Hoban 2016 *Am Nat* 188:379-397). **GEA has FOUR concurrent confounds**:\n1. **Population structure** — IBD-driven allele-frequency gradients track distance, which correlates with most environmental variables\n2. **Demographic history** — range expansion creates allele-frequency clines along the expansion axis that mimic selection (Lotterhos & Whitlock 2014 *Mol Ecol* 23:2178-2192)\n3. **Background and linked selection** — reduces diversity in low-recombination regions, inflating apparent local-FST signals\n4. **Sampling design** — non-random spatial sampling creates spurious GEA signals (Lotterhos & Whitlock 2015 *Mol Ecol* 24:1031-1046; **paired contrasts > random > transects** when demography is concerning)\n\nA second cornerstone: **Forester et al. 2018 established RDA as the best polygenic-adaptation detector** but with a caveat — RDA performance requires imputed genotypes (no missing data) and is best for linear-gradient environments. For monogenic strong-selection loci, OutFLANK and BayPass-C2 remain competitive.\n\nA third: **Genomic offset has three regimes** (Lind & Lotterhos 2025 *Mol Ecol Resour* 25:e14008): works well for interpolation (similar-to-training environments), degrades gracefully for modest extrapolation, FAILS for highly novel future environments. Reporting a single offset map without characterizing prediction-novelty is methodologically incomplete. For the broader eco-evolutionary integration framework, see Aguirre-Liguori 2021 *Nat Ecol Evol* 5:1350-1360.\n\n## Algorithmic Taxonomy\n\n| Method | Type | Strength | Fails when |\n|--------|------|----------|------------|\n| FST outliers (naive) | Univariate per-locus | Simple; widely understood | Inflated FDR under demography (Lotterhos & Whitlock 2014) |\n| OutFLANK (Whitlock & Lotterhos 2015) | Univariate FST with trimmed null | Robust to demography via trimmed-tail null | Conservative; misses weak-effect polygenic |\n| pcadapt (Luu 2017) | PC-based Mahalanobis | Handles continuous structure; no need to define populations | Detects axes-of-divergence loci; not environment-specific |\n| LFMM (Frichot 2013) | MCMC mixed model with latent factors | Original framework | Slow; superseded by LFMM2 |\n| LFMM2 (Caye 2019) | LSE-based mixed model with K latent factors | Fast; orders of magnitude faster than LFMM; modern default | K choice is critical; wrong K silently invalidates results |\n| BayPass Core (Gautier 2015) | Bayesian FST with covariance matrix Omega | Explicit shared-history correction via Omega | Computationally heavy; convergence needs care |\n| BayPass AUX | Bayesian env association with binary auxiliary variable | Posterior gives Bayes Factor per locus | Same as Core |\n| BayPass C2 | Bayesian contrast between two pre-defined groups | Like Bayesian Fisher exact | Requires pre-defined groups, not continuous env |\n| BayPass IS | Importance-sampling joint Bayesian | Multiple covariates simultaneously | Most computationally expensive |\n| RDA (Forester 2018) | Multivariate constrained ordination | HIGH power and LOW FDR for polygenic adaptation | Requires imputed genotypes; less power for monogenic |\n| pRDA (partial RDA) | RDA conditioning out population structure | Controls for structure explicitly | Conservative; depends on which axes are conditioned out |\n| Gradient forests (Ellis 2012; Ellis-Smith-Pitcher) | Random-forest non-linear GEA | Detects non-linear gene-environment | Less interpretable; no formal p-values |\n| RDA offset (Capblancq 2021) | Linear genomic-offset prediction | Linear gradient assumption | Fails under highly novel future climate (Lind 2025) |\n| Gradient-forest offset | Non-linear genomic-offset prediction | Captures non-linearity | Same three-regime caveat |\n| RONA | Locus-by-locus offset | Simple, transparent | Locus-specific; ignores multilocus structure |\n| Circuitscape (McRae 2008) | Circuit-theory landscape resistance | Integrates ALL paths; not single-best | Symmetric only; asymmetric landscapes need directional methods |\n| ResistanceGA (Peterman 2018) | Genetic-algorithm optimization of resistance | Optimizes cost surface itself | MLPE parameterization needed (specific lmer form) |\n\n## Decision Tree by Scenario\n\n| Scenario | Recommended approach | Why |\n|----------|---------------------|-----|\n| Monogenic local adaptation | OutFLANK or BayPass Core; cross-check with simulations | Demography-calibrated null |\n| Polygenic local adaptation | RDA with environmental matrix; pRDA conditioning on structure | Forester 2018 superior power + lower FDR |\n| Environmental association with structure correction | LFMM2 (K from sNMF cross-entropy elbow) | Modern default; orders of magnitude faster than LFMM |\n| Binary group contrast | BayPass C2 | Like Bayesian Fisher exact |\n| Joint multi-covariate Bayesian inference | BayPass IS | Multiple env simultaneously |\n| Quantifying maladaptation under climate change | RDA offset OR gradientForest offset | Report Lind 2025 caveat: works for interpolation, fails for novel |\n| Multi-method consensus | Run OutFLANK + LFMM2 + BayPass; overlap is high-confidence | Method differences = methodological coverage |\n| Mapping landscape resistance | Circuitscape + ResistanceGA optimization | Circuitscape integrates all paths; ResistanceGA optimizes the surface |\n| Distinguishing IBD vs IBE | dbRDA variance partitioning (geographic + env) | Mantel-based methods have known autocorrelation issues |\n| Sampling design optimization | Paired contrasts at environmental endpoints; cite Lotterhos & Whitlock 2015 | Most powerful under demographic concern |\n| Polyploid species | polyRAD \u002F fitPoly \u002F updog FIRST; then standard GEA | Diploid-assuming tools give biased FST estimates |\n\n## LFMM2 with Mandatory K Selection\n\n**Goal:** Identify loci significantly associated with environmental variables while controlling for unobserved demographic structure via K latent factors.\n\n**Approach:** Run sNMF on the genotype matrix across K = 1...10 (or higher), compute cross-entropy at each K, pick K at the elbow (where cross-entropy first plateaus), then pass that K to `LEA::lfmm2()`. Wrong K silently invalidates results — too few K means residual structure confounds environment; too many K absorbs the environmental signal.\n\n```r\nlibrary(LEA)\nlibrary(qvalue)\n\n# Convert VCF -> LFMM\u002FGENO format\nvcf2lfmm('variants.vcf', 'genotypes.lfmm')\nvcf2geno('variants.vcf', 'genotypes.geno')\n\n# MANDATORY K selection via sNMF cross-entropy elbow\n# Run multiple repetitions per K (5 minimum) for stability\nsnmf_result \u003C- snmf('genotypes.geno', K = 1:10, repetitions = 5,\n                     entropy = TRUE, project = 'new')\nce_values \u003C- sapply(1:10, function(k) min(cross.entropy(snmf_result, K = k)))\nplot(1:10, ce_values, xlab = 'K', ylab = 'Cross-entropy',\n     pch = 19, col = 'blue', type = 'b')\n\n# Pick K at elbow (first plateau); report sensitivity across K\nbest_K \u003C- which.min(ce_values)\n\n# Run LFMM2 with selected K\ngenotypes \u003C- read.lfmm('genotypes.lfmm')\nenv_vars \u003C- read.env('environment.env')\nlfmm_result \u003C- lfmm2(input = genotypes, env = env_vars, K = best_K)\n\n# Test associations with genomic-control calibration\npvalues \u003C- lfmm2.test(lfmm_result, input = genotypes, env = env_vars,\n                       full = TRUE, genomic.control = TRUE)\n\n# Check genomic inflation factor (GIF \u002F lambda)\n# Target ~1.0; > 1.5 means insufficient structure correction (try larger K)\n# \u003C 0.5 means over-correction (try smaller K)\ngif \u003C- median(qchisq(1 - pvalues$pvalues[, 1], df = 1)) \u002F qchisq(0.5, df = 1)\ncat('Genomic inflation factor (lambda):', round(gif, 3), '\\n')\n\n# Storey FDR control\nqvals \u003C- qvalue(pvalues$pvalues[, 1])$qvalues\ncandidates \u003C- which(qvals \u003C 0.05)\ncat('Candidate adaptive loci (q \u003C 0.05):', length(candidates), '\\n')\n\n# Sensitivity check: re-run with K +\u002F- 1 and report overlap of candidates\n# Loci detected only at one K are sensitive to latent-factor choice; flag as lower-confidence\n```\n\n## RDA — Capblancq & Forester 2021 Swiss-Army-Knife Workflow\n\n**Goal:** Detect polygenic local adaptation via multivariate constrained ordination, with optional climate-offset prediction.\n\n**Approach:** Apply the Capblancq & Forester 2021 RDA workflow: (1) variable selection via forward selection with adjusted R^2; (2) variance partitioning into pure-environment \u002F pure-spatial \u002F shared; (3) GEA outlier identification at SD > 3 on RDA axes 1-3; (4) adaptive-index computation; (5) genomic-offset prediction with the Lind 2025 three-regime caveat. **CRITICAL: genotypes must be imputed before RDA** (no missing data); cite Forester 2018 for the polygenic-power result.\n\n```r\nlibrary(vegan)\n\n# CRITICAL: impute missing genotypes BEFORE RDA (Forester 2018 benchmark requirement)\n# Column-mean imputation per locus is the simplest valid choice;\n# population-stratified mean imputation is preferred when populations are known.\n# For LEA-generated data, LEA::impute() is the canonical option.\nfor (j in seq_len(ncol(allele_freq))) {\n    col_mean \u003C- mean(allele_freq[, j], na.rm = TRUE)\n    allele_freq[is.na(allele_freq[, j]), j] \u003C- col_mean\n}\n\n# Partial RDA conditioning on population structure (e.g., Q-matrix from sNMF)\n# This is pRDA per Capblancq 2021\nrda_result \u003C- rda(allele_freq ~ temperature + precipitation + altitude +\n                  Condition(as.matrix(q_matrix)), data = env_data)\n\n# Permutation test\nanova(rda_result, permutations = 999)\n\n# Variance partitioning (Capblancq workflow step 2)\nvp \u003C- varpart(allele_freq, env_data, q_matrix)\nvp$part$fract  # pure env \u002F shared \u002F pure structure \u002F residual\n\n# GEA outliers (z-score > 3 on RDA axes 1-3)\n# Threshold of 3 SD is conservative; for polygenic adaptation, may use 2.5 SD\nloadings \u003C- scores(rda_result, choices = 1:3, display = 'species')\nzscores \u003C- apply(loadings, 2, function(x) (x - mean(x)) \u002F sd(x))\nrda_candidates \u003C- which(apply(abs(zscores), 1, max) > 3)\ncat('RDA candidate loci (|z| > 3):', length(rda_candidates), '\\n')\n```\n\n## BayPass — Core, AUX, C2, IS Models\n\n**Goal:** Bayesian Genotype-Environment Association with explicit population-history correction via covariance matrix Omega.\n\n**Approach:** Convert VCF to BayPass's space-separated allele-count format. Run Core (estimates Omega; like Bayesian FST); use AUX for binary env-association testing; C2 for two-group contrast; IS for joint multi-covariate.\n\n```bash\n# BayPass input: space-separated allele counts, NOT VCF\n# Use vcf2baypass.pl OR bcftools query to convert\n\n# Core model: estimate Omega (population covariance from genome-wide SNPs)\ng_baypass -gfile geno_BayPass.txt -outprefix core_run -nthreads 4\n\n# AUX (binary auxiliary variable): test environmental association\n# omegafile from Core run; covariates is samples x env file\ng_baypass -gfile geno_BayPass.txt -efile env_BayPass.txt \\\n          -omegafile core_run_mat_omega.out \\\n          -outprefix aux_run -auxmodel -nthreads 4\n\n# C2 (contrast between two pre-defined groups)\n# contrasts.txt: 1 = group 1, -1 = group 2, 0 = excluded\ng_baypass -gfile geno_BayPass.txt -contrastfile contrasts.txt \\\n          -omegafile core_run_mat_omega.out \\\n          -outprefix c2_run -nthreads 4\n\n# Bayes Factor > 20 dB: strong evidence\n# Bayes Factor > 30 dB: decisive evidence\n# Convert: BFis (decibel scale) = 10 * log10(BF)\n```\n\n## Genomic Offset — Lind & Lotterhos 2025 Three-Regime Framework\n\n**Goal:** Predict maladaptation under future climate using genomic-offset methods (gradientForest, RDA-offset, LFMM2offset, RONA) while characterizing prediction-novelty. For the broader genomic-prediction review (foundation of the offset literature), see Capblancq et al. 2020 *Annu Rev Ecol Evol Syst* 51:245-269.\n\n**Approach:** Compute offset per location as the distance in transformed genomic-environmental space between current and future predicted climate. CRITICAL: characterize whether each prediction falls into regime 1 (interpolation), regime 2 (modest extrapolation), or regime 3 (highly novel, where offset is uninformative or misleading). Report offset alongside prediction-novelty mapping.\n\n```r\nlibrary(gradientForest)\nlibrary(terra)\n\n# Fit gradient forests on candidate loci x environment\ngf \u003C- gradientForest(cbind(env_predictors, allele_data),\n                     predictor.vars = colnames(env_predictors),\n                     response.vars = colnames(allele_data),\n                     ntree = 500, trace = FALSE)\n\n# Variable importance (which env drives most allele turnover)\nplot(gf, plot.type = 'Overall.Importance')\n\n# Predict genetic offset under current vs future\ncurrent \u003C- rast('bioclim_current.tif')\nfuture \u003C- rast('bioclim_2070_ssp585.tif')\ncurrent_vals \u003C- extract(current, sampling_coords)\nfuture_vals \u003C- extract(future, sampling_coords)\n\n# Genomic offset = Euclidean distance in transformed space\ncurrent_transformed \u003C- predict(gf, current_vals)\nfuture_transformed \u003C- predict(gf, future_vals)\ngenetic_offset \u003C- sqrt(rowSums((current_transformed - future_transformed)^2))\n\n# CRITICAL: characterize prediction-novelty regime per location\n# For each future location, compute distance to nearest training-data envelope\n# locations in regime 3 (high novelty) should have offset values down-weighted\n# in interpretation per Lind & Lotterhos 2025\n\n# Cross-validation with multiple offset methods (gradientForest + RDA + LFMM2offset)\n# Robust signals appear in ALL methods; method-specific offset is suspect\n```\n\n## Per-Method Failure Modes\n\n### LFMM2 with wrong K silently invalidates results\n\n**Trigger:** Running LFMM2 with K too small (residual structure confounds environment) or K too large (latent factors absorb the environmental signal).\n\n**Mechanism:** LFMM2 uses K latent factors to capture unobserved population structure. Wrong K means structure is either undercorrected (false positives) or overcorrected (false negatives), with no error message.\n\n**Symptom:** Thousands of significant SNPs (too small K) OR almost none (too large K); genomic inflation factor lambda far from 1.0.\n\n**Fix:** Use sNMF cross-entropy elbow as the primary K choice; run LFMM2 at K-1, K, K+1 and report sensitivity; flag loci detected at only one K as lower-confidence.\n\n### RDA on un-imputed genotypes silently degrades\n\n**Trigger:** Running RDA on an allele-frequency matrix with NA values without imputation.\n\n**Mechanism:** RDA cannot handle missing data internally; default behavior is to use `na.omit` which drops loci AND samples. Forester 2018's RDA-dominance benchmark assumed imputed genotypes.\n\n**Symptom:** Effective sample size much smaller than expected; results sensitive to which loci have missing data.\n\n**Fix:** Impute missing genotypes (mean within population, kNN, or `snmf::impute()`) BEFORE running RDA.\n\n### Genomic offset reported without prediction-novelty characterization\n\n**Trigger:** Producing a country-wide genomic-offset map without indicating which areas are inside vs outside the training-data envelope.\n\n**Mechanism:** Per Lind & Lotterhos 2025, genomic-offset accuracy declines with novelty of the predicted environment. Highly novel future climates fall in \"regime 3\" where offset is uninformative.\n\n**Symptom:** Map shows highest predicted maladaptation in geographically extreme areas; cross-validation with multiple methods shows divergent predictions.\n\n**Fix:** Compute prediction novelty per location (e.g., Mahalanobis distance to training envelope); annotate offset values with their regime; report cross-method consensus rather than single-method offset.\n\n### OutFLANK applied to continuous sampling design\n\n**Trigger:** Running OutFLANK on continuous-gradient samples treated as a single \"population\".\n\n**Mechanism:** OutFLANK assumes distinct, well-defined populations for FST calculation. Continuous sampling does not have natural population delimitation; the FST distribution depends arbitrarily on how samples are binned.\n\n**Symptom:** OutFLANK results unstable to alternative population definitions; very few or impossibly many outliers.\n\n**Fix:** Use LFMM2 or RDA for continuous gradient data; OutFLANK is appropriate when distinct populations are defined a priori.\n\n### LDNe physical-linkage trap on RAD-seq SNPs\n\n**Trigger:** Running LFMM2 \u002F RDA \u002F OutFLANK on RAD-seq SNPs without LD pruning.\n\n**Mechanism:** Physical linkage among RAD-seq SNPs creates correlated test statistics; outlier counts are inflated by chromosomal clustering rather than independent adaptation signal.\n\n**Symptom:** Outliers cluster in large blocks along the genome; individual-locus inference is dominated by linkage.\n\n**Fix:** LD-prune SNPs (PLINK `--indep-pairwise 50 5 0.2`) before GEA; OR thin to >= 1 cM apart with a genetic map.\n\n## Quantitative Thresholds\n\n| Threshold | Value | Source \u002F rationale |\n|-----------|-------|-------------------|\n| LFMM2 K selection | Cross-entropy elbow from sNMF (`LEA`) | Caye 2019; sensitivity check at K-1, K+1 |\n| Genomic inflation factor target | Lambda ~ 1.0 | > 1.5 = under-correction; \u003C 0.5 = over-correction |\n| FDR threshold | q \u003C 0.05 (Storey) | qvalue package; more powerful than BH for genomic data |\n| RDA outlier threshold | abs(z) > 3 on RDA axes 1-3 | Capblancq & Forester 2021 conservative; 2.5 for polygenic |\n| BayPass Bayes Factor | BF > 20 dB strong; > 30 dB decisive | Gautier 2015 convention |\n| OutFLANK trim fractions | LeftTrim = RightTrim = 0.05 | Whitlock & Lotterhos 2015 default |\n| OutFLANK Hmin | 0.1 | Exclude low-heterozygosity unreliable FST |\n| Forester 2018 RDA imputation | Required (no missing data) | RDA performance benchmark assumed imputed genotypes |\n| Lind & Lotterhos 2025 offset regimes | Regime 1 (interpolation) \u002F 2 (modest extrapolation) \u002F 3 (highly novel) | Characterize per location |\n| Lotterhos & Whitlock 2015 sampling design | Paired contrasts > random > transects under demographic concern | Genome-scan power |\n\n## Common errors\n\n| Error | Cause | Solution |\n|-------|-------|----------|\n| LFMM2 returns thousands of significant SNPs | K too small | Increase K via sNMF cross-entropy elbow |\n| LFMM2 returns no significant SNPs | K too large; signal absorbed | Decrease K |\n| Lambda (GIF) >> 1.5 | Insufficient structure correction | Increase K or add structure covariate |\n| RDA effective N much smaller than total | NA values in allele matrix | Impute before RDA |\n| pcadapt screeplot shows no elbow | Continuous population structure or single-cline data | Switch to LFMM2 or RDA |\n| OutFLANK error about populations | Continuous sampling, no defined populations | Use LFMM2 \u002F RDA instead |\n| BayPass \"format error\" | Passing VCF directly | Convert to space-separated allele counts via vcf2baypass.pl |\n| Gradient-forest plot blank | Insufficient SNPs in candidate set | Increase candidate-locus pool |\n| Genomic offset highest in intermediate climate | PC axes capture environment; structure absorbing signal | pRDA conditioning on geographic distance |\n\n## References\n\n- Frichot E, Schoville SD, Bouchard G, François O (2013) LFMM. *Mol Biol Evol* 30(7):1687-1699. doi:10.1093\u002Fmolbev\u002Fmst063\n- Caye K, Jumentier B, Lepeule J, François O (2019) LFMM 2: fast LSE estimator. *Mol Biol Evol* 36(4):852-860. doi:10.1093\u002Fmolbev\u002Fmsz008\n- Gain C, François O (2021) LEA 3 package. *Mol Ecol Resour* 21(8):2738-2748. doi:10.1111\u002F1755-0998.13366\n- Gautier M (2015) BayPass. *Genetics* 201(4):1555-1579. doi:10.1534\u002Fgenetics.115.181453\n- Forester BR, Lasky JR, Wagner HH, Urban DL (2018) Multilocus adaptation methods: RDA superior. *Mol Ecol* 27(9):2215-2233. doi:10.1111\u002Fmec.14584\n- Capblancq T, Forester BR (2021) RDA Swiss-army-knife for landscape genomics. *Methods Ecol Evol* 12(12):2298-2309. doi:10.1111\u002F2041-210X.13722\n- Capblancq T, Fitzpatrick MC, Bay RA, Exposito-Alonso M, Keller SR (2020) Genomic prediction of (mal)adaptation. *Annu Rev Ecol Evol Syst* 51:245-269. doi:10.1146\u002Fannurev-ecolsys-020720-042553\n- Whitlock MC, Lotterhos KE (2015) OutFLANK. *Am Nat* 186(S1):S24-S36. doi:10.1086\u002F682949\n- Lotterhos KE, Whitlock MC (2014) Demographic confounders of FST outlier tests. *Mol Ecol* 23(9):2178-2192. doi:10.1111\u002Fmec.12725\n- Lotterhos KE, Whitlock MC (2015) Sampling-design optimization for genome scans. *Mol Ecol* 24(5):1031-1046. doi:10.1111\u002Fmec.13100\n- Lind BM, Lotterhos KE (2025) Accuracy of predicting maladaptation. *Mol Ecol Resour* 25:e14008. doi:10.1111\u002F1755-0998.14008\n- Wang IJ, Bradburd GS (2014) Isolation by environment (IBD vs IBE). *Mol Ecol* 23(23):5649-5662. doi:10.1111\u002Fmec.12938\n- McRae BH, Dickson BG, Keitt TH, Shah VB (2008) Circuitscape circuit-theory. *Ecology* 89(10):2712-2724. doi:10.1890\u002F07-1861.1\n- Peterman WE (2018) ResistanceGA. *Methods Ecol Evol* 9(6):1638-1647. doi:10.1111\u002F2041-210X.12984\n- Ellis N, Smith SJ, Pitcher CR (2012) Gradient forests. *Ecology* 93(1):156-168. doi:10.1890\u002F11-0252.1\n- Aguirre-Liguori JA, Ramírez-Barahona S, Gaut BS (2021) Evolutionary genomics of climate response. *Nat Ecol Evol* 5(10):1350-1360. doi:10.1038\u002Fs41559-021-01526-9\n- Hoban S, Kelley JL, Lotterhos KE et al. (2016) Finding the genomic basis of local adaptation. *Am Nat* 188(4):379-397. doi:10.1086\u002F688018\n- Luu K, Bazin E, Blum MGB (2017) pcadapt: an R package to perform genome scans for selection based on principal component analysis. *Mol Ecol Resour* 17(1):67-77. doi:10.1111\u002F1755-0998.12592\n- Legendre P, Fortin M-J (2010) Comparison of the Mantel test and alternative approaches for detecting complex multivariate relationships. *Mol Ecol Resour* 10(5):831-844. doi:10.1111\u002Fj.1755-0998.2010.02866.x\n\n## Related Skills\n\n- ecological-genomics\u002Fconservation-genetics - Population genetic health (Ne, F_ROH); use ESU\u002FMU framework not species delimitation for management units\n- ecological-genomics\u002Fcommunity-ecology - Environmental gradient analysis for species composition (analog of GEA for community data)\n- population-genetics\u002Fselection-statistics - Selection scans in human population genetics\n- population-genetics\u002Fpopulation-structure - STRUCTURE \u002F ADMIXTURE for substructure inference\n- variant-calling\u002Fvcf-basics - VCF preparation from RAD-seq or WGS\n",{"name":5,"source":24,"license":15,"tool_type":25,"description":7,"imported_at":26,"source_path":27,"primary_tool":28,"source_repository":29},"https:\u002F\u002Fgithub.com\u002FGPTomics\u002FbioSkills","r","2026-09-20","ecological-genomics\u002Flandscape-genomics\u002FSKILL.md","LEA","GPTomics\u002FbioSkills","main","2d1750717747097b602acf30bd09a7cbd4b4c6ea","awesome_skills\u002Fbiology\u002Fbio-ecological-genomics-landscape-genomics","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous","2026-11-09 11:45:36",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-ecological-genomics-landscape-genomics",{"tool":42,"command":43},"bunx","bunx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-ecological-genomics-landscape-genomics",{"tool":45,"command":46},"pnpm","pnpm dlx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-ecological-genomics-landscape-genomics","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-ecological-genomics-landscape-genomics\u002FSKILL.md",true,[50,56,60],{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"examples\u002Flfmm_gea.R","OTHER","其他",5319,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-ecological-genomics-landscape-genomics\u002Fexamples\u002Flfmm_gea.R",{"path":57,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":58,"sourceHtmlUrl":59},"examples\u002Fpcadapt_outliers.R",4034,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-ecological-genomics-landscape-genomics\u002Fexamples\u002Fpcadapt_outliers.R",{"path":61,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":64,"sourceHtmlUrl":65},"usage-guide.md","REFERENCE","参考文档",8781,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-ecological-genomics-landscape-genomics\u002Fusage-guide.md",[67,75,82,89,96,103],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":74},"01M7FFFZPC2025JQQHPHDX154J","dei-assessment","Assess diversity, equity, and inclusion with metrics. TRIGGERS - Use when user needs help with dei-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-assessment\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":74},"01M7FFFWN8H4WA7A6Y398QKB6J","dei-action-plan","Create DEI action plans with goals and initiatives. TRIGGERS - Use when user needs help with dei-action-plan related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-action-plan\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":74},"01M7FFFSHTM0QZRVZ2NRJTJ0PY","culture-fit-assessment","Design culture add assessment processes. TRIGGERS - Use when user needs help with culture-fit-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fculture-fit-assessment\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":74},"01M7FFFMA12RKEQA38KHJSXXPS","cowork-to-code-bridge","Use an already-installed, independently verified cowork-to-code bridge to run narrowly approved actions on the user's own macOS, Linux, or WSL2 machine through a local file queue.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcowork-to-code-bridge\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":74},"01M7FFFH1F6M8YRGW5V487GH1K","counter-offer-response","Draft counter-offer responses for retention. TRIGGERS - Use when user needs help with counter-offer-response related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcounter-offer-response\u002FSKILL.md",[],[],{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":74},"01M7FFFDGEHV8Y7J9N40HZXW52","continuous-feedback-system","Design continuous feedback systems. TRIGGERS - Use when user needs help with continuous-feedback-system related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcontinuous-feedback-system\u002FSKILL.md",[],[]]