← Về thư mục
📄 / / profiles / r-and-d / raw_evidence / OpenAI4S / skills / bioskills / bio-causal-genomics-genomic-sem / references / usage-guide.md

Genomic SEM Usage Guide

Overview

Genomic SEM fits structural equation models to GWAS summary statistics, treating each GWAS as an indicator of one or more latent genetic factors. The framework (Grotzinger 2019 Nat Hum Behav 3:513) uses an LDSC-derived genetic covariance matrix (S) and its sampling covariance (V) as inputs to a lavaan-based SEM, supporting:

The skill emphasizes when GenomicSEM is the right multivariate framework, when MTAG is a better fit, and how to read fit indices and Q_SNP to avoid over-claiming "common-factor SNPs" that are in fact trait-specific.

Prerequisites

Quick Start

Tell an AI agent what to model:

Example Prompts

Common-Factor Model

"Take these three educational-attainment GWAS sumstats, run GenomicSEM::ldsc() against the EUR reference, fit a common-factor CFA, and report CFI, RMSEA, SRMR, and standardized loadings. Diagnose any Heywood case if present."

Common-Factor GWAS with Q_SNP

"Run a common-factor GWAS across MDD, BIP, and SCZ using commonfactorGWAS with DWLS estimation. Report SNPs with factor p < 5e-8 AND Q_SNP p > Bonferroni-corrected threshold. Exclude Q_SNP-significant SNPs from the common-factor SNP list."

Confirmatory Two-Factor Model

"Fit a two-factor user model where F1 = LDL + HDL + triglycerides and F2 = fasting glucose + HbA1c + 2hr glucose, with F1 ~~ F2 free to estimate factor correlation. Use usermodel with DWLS estimation. Report fit indices and factor correlation."

MTAG Comparison

"Run MTAG via CLI on the same three lipid GWAS, then compare per-trait top hits with GenomicSEM common-factor SNPs. Check that MTAG maxFDR is < 5% for each trait. Where they disagree, classify the SNP as factor-mediated vs trait-specific."

Stratified GenomicSEM

"Use s_ldsc() to partition the heritability of the latent externalizing factor across baseline-LD annotations + ENCODE/Roadmap cell-type marks. Report per-annotation factor enrichment and the cell type with the largest factor-tau coefficient."

Sample Overlap Diagnosis

"These four GWAS are from UK Biobank. Verify the bivariate LDSC intercepts and confirm the V matrix off-diagonals reflect overlap. Fit the common-factor model and check that SEs differ from a naive analysis that ignores V."

ESEM Exploratory

"Run an ESEM with two free factors on these 8 cognition + personality GWAS to discover whether a single g factor captures the shared variance or whether g + p_factor emerges. Report rotation: geomin oblique."

What the Agent Will Do

  1. Verify each input GWAS sumstats file is HapMap3-aligned and has columns SNP, A1, A2, BETA/OR, SE, P, N (and EAF when available); call munge() if not already munged.
  2. Run ldsc() to produce the genetic covariance matrix S and sampling covariance V across all input traits; verify mean chi-square per trait > 1.02.
  3. Inspect S for pairwise rg near +/-1 (multicollinearity warning); inspect V eigenvalues for positive-definiteness.
  4. Fit the requested model:
  5. commonfactor() for single-factor CFA
  6. usermodel() with lavaan syntax for arbitrary structure
  7. commonfactorGWAS() for SNP-level multivariate GWAS with Q_SNP
  8. Report model fit indices: CFI, TLI, RMSEA, SRMR, chi-square + df + p-value, AIC, BIC.
  9. Inspect standardized loadings; flag any Heywood cases (residual variance < 0 OR standardized loading > 1).
  10. For common-factor GWAS, parse factor effect (Est, SE, P) AND Q_SNP (chi-square, df, P) per SNP; apply Bonferroni for heterogeneity threshold.
  11. Classify discovered SNPs into "common-factor SNPs" (factor sig + Q_SNP non-sig) vs "heterogeneous SNPs" (factor sig + Q_SNP sig).
  12. When MTAG is also requested, build per-trait sumstats input, run mtag.py, verify MaxFDR < 5%, and compare top hits with GenomicSEM factor hits.
  13. For stratified analysis, run s_ldsc() with baseline-LD and target annotations, then enrich() for factor enrichment per category.
  14. Reconcile any disagreement between GenomicSEM, MTAG, and per-trait univariate GWAS using the reconciliation table in SKILL.md.
  15. Produce a manuscript-ready summary: fit indices, factor diagram, SNP table with Q_SNP, and a methodological statement covering sample overlap handling via V.

Tips

causal-genomics/mendelian-randomization - Run MR with the common-factor sumstats as exposure causal-genomics/heritability-partitioning - sLDSC foundations + LDAK comparison; required upstream for stratified GenomicSEM causal-genomics/colocalization-analysis - Resolve overlap of factor-significant SNPs with eQTL/pQTL signals causal-genomics/pleiotropy-detection - Q_SNP is the per-SNP pleiotropy diagnostic in GenomicSEM causal-genomics/fine-mapping - Construct credible sets at factor-significant loci causal-genomics/mediation-analysis - SEM mediation overlaps with usermodel indirect path coefficients causal-genomics/transcriptome-wide-association - TWAS on factor GWAS output population-genetics/association-testing - GWAS workflow upstream of GenomicSEM