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:
commonfactorGWAS) with the Q_SNP heterogeneity testThe 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.
GenomicSEM (GitHub GenomicSEM/GenomicSEM), lavaan, Matrix, gdataGenomicSEM::munge() or LDSC's munge_sumstats.pyeur_w_ld_chr/ from alkesgroup)JonJala/mtag). Prefer abdenlab/ldsc-python3 (v2.0.0) over belowlab/ldsc v3.0.1 (whose CLI is broken per the README; Docker jtb114/ldsc:latest is the belowlab fallback).baselineLD_v2.2 annotations + per-ancestry frequency filesTell an AI agent what to 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."
"Run a common-factor GWAS across MDD, BIP, and SCZ using
commonfactorGWASwithDWLSestimation. 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."
"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
usermodelwith DWLS estimation. Report fit indices and factor correlation."
"Run MTAG via CLI on the same three lipid GWAS, then compare per-trait top hits with GenomicSEM common-factor SNPs. Check that MTAG
maxFDRis < 5% for each trait. Where they disagree, classify the SNP as factor-mediated vs trait-specific."
"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."
"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."
"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."
munge() if not already munged.ldsc() to produce the genetic covariance matrix S and sampling covariance V across all input traits; verify mean chi-square per trait > 1.02.commonfactor() for single-factor CFAusermodel() with lavaan syntax for arbitrary structurecommonfactorGWAS() for SNP-level multivariate GWAS with Q_SNPmtag.py, verify MaxFDR < 5%, and compare top hits with GenomicSEM factor hits.s_ldsc() with baseline-LD and target annotations, then enrich() for factor enrichment per category.ldsc() output -- both S and V -- is the input GenomicSEM expects.estimation = 'DWLS' unless the V matrix is essentially diagonal. ML is faster but produces wrong SE when sample overlap exists (i.e., almost always in practice).commonfactorGWAS (excluding Q_SNP-significant SNPs) is a valid MR exposure for testing the causal effect of the latent factor on a separate outcome. See causal-genomics/mendelian-randomization.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