umxGSEM_GWAS: Multivariate genomic SEM GWAS (SNP on a factor or user model)

View source: R/umxGSEM.R

umxGSEM_GWASR Documentation

Multivariate genomic SEM GWAS (SNP on a factor or user model)

Description

Expands the LDSC genetic covariance structure with each SNP (using prepared betas from umxGSEM_sumstats()), fits DWLS/WLS, and returns SNP-level results. For a default common-factor model, estimates F1 ~ SNP.

Usage

umxGSEM_GWAS(
  covstruc,
  SNPs,
  model = NULL,
  estimation = c("DWLS", "WLS", "ULS"),
  traits = NULL,
  GC = c("standard", "conserv", "none"),
  uncertainty = c("MLR", "SE"),
  SnpSamplingError = 5e-04,
  maxSNPs = NULL,
  snpEffect = "SNP_to_F1",
  quiet = TRUE,
  fix_measurement = TRUE,
  force_fallback = FALSE
)

Arguments

covstruc

LDSC list with S (genetic covariance), V (sampling covariance of vech(S)), and preferably I (LDSC intercept matrix, for GC-corrected SEs). See e.g. Psych_LDSC (I = intercepts / sample-overlap; also N, m).

SNPs

Data frame from umxGSEM_sumstats() (columns ⁠beta.*⁠, ⁠se.*⁠, MAF, SNP, ...).

model

Optional lavaan/umx string or mxModel. If NULL, builds A RAM model with one latent (F1) loading on all the traits, and "SNP" loading on F1

estimation

"DWLS" (default), "WLS", or "ULS".

traits

Trait names. Default: colnames of covstruc$S.

GC

Genomic control for SNP sampling variances: "standard", "conserv", or "none".

uncertainty

Whether to compute the robust sandwich SE ("MLR", default) or naive SE ("SE").

SnpSamplingError

SE used for SNP variance (treated as nearly fixed; default 5e-4).

maxSNPs

Optional limit for smoke tests.

snpEffect

Character; path label to extract from the model (default "SNP_to_F1").

quiet

Suppress per-SNP messages.

fix_measurement

Logical; if TRUE (default), fixes the non-SNP measurement model parameters to their base optimized values when evaluating each SNP (only applies if analytic engine is bypassed).

force_fallback

Logical; internal use for testing to force the non-vectorized analytic path (default FALSE).

Details

The LDSC object is the usual GenomicSEM-style list (S, V, preferably I); see e.g. Psych_LDSC for a packaged example and field definitions.

Value

A data.frame of SNP results (SNP, CHR, BP, MAF, est, se, Z, P, status, ...).

See Also

umxGSEM_sumstats(), umxGSEM(), Psych_LDSC

Other GSEM: Anthro_LDSC, Psych_LDSC, plot.umx_GWAS(), umxGSEM(), umxGSEM_dl_tutorial_files(), umxGSEM_label_ldsc(), umxGSEM_ldsc(), umxGSEM_munge(), umxGSEM_std(), umxGSEM_sumstats(), umxSummary.MxDataStatic(), umxSummary.list()

Examples

## Not run: 
1. load data
data(Psych_LDSC)
# Have a quick look if you like
# Psych_LDSC fields: S, V, I, N, m (see ?Psych_LDSC). V pairs are named var_SCZ, poly_BIP_SCZ, ...
umxSummary(Psych_LDSC)

#' # 2. build the snp data structure from your SNP data txt files, e.g.
dir = "~/bin/umx/inst/developer/GenomicSEM"
snps = umxGSEM_sumstats(
  files = file.path(dir, c("SCZ_subset.txt", "BIP_subset.txt", "MDD_subset.txt")),
  ref = file.path(dir, "reference.1000G.subset.txt"),
  trait.names = c("SCZ", "BIP", "MDD"), se.logit = TRUE
)

# 3. Run the GWAS on your trait measurement model adding SNP effects into the latent structure
GWAS = umxGSEM_GWAS(covstruc = Psych_LDSC, SNPs = snps,
  traits = c("SCZ", "BIP", "MDD"), maxSNPs = 20)

# 4. Examine results and make a new drug or something useful!
head(GWAS)
# Manhattan Plot (default)
plot(gwas_res)
plot(example_gwas, chromosomes= 1, label_top_n= 4, title="IQ GWAS") + theme_plos()
volcano_plot(example_gwas, size_by = "AF", label_top_n = 3)

# Q-Q Plot
plot(gwas_res, type = "qq")

# ================
# = Another demo =
# ================
# 1. Load the reference LDSC covariance structure
data(Psych_LDSC, package = "umx")

# 2. Generate a million simulated SNPs
traits = c("SCZ", "BIP", "MDD")
t0 = Sys.time()
snps = umxGSEM_sim_snps(n = 1e6, traits = traits)
print(Sys.time() - t0)

# 3. Run the GWAS and time it
t0 = Sys.time()
gwas_res = umxGSEM_GWAS(covstruc = Psych_LDSC, SNPs = snps, traits = traits)
print(Sys.time() - t0)

# 4. View the results
head(gwas_res)
# Manhattan Plot (default)
plot(gwas_res)
plot(example_gwas, chromosomes= 1, label_top_n= 4, title="IQ GWAS") + theme_plos()
volcano_plot(example_gwas, size_by = "AF", label_top_n = 3)

# Q-Q Plot
plot(gwas_res, type = "qq")


## End(Not run)

umx documentation built on Oct. 11, 2026, 5:07 p.m.