# reinstall to ensure that we are running the latest GSEM
devtools::install_github("GenomicSEM/GenomicSEM", force=TRUE)
library(GenomicSEM)
LDSC_PATH <- "bugtest/LDSC.RDS"
SUMSTAT_PATH <- "bugtest/bugtest.Sumstats.RDS"
# set input variables
ldsc_res <- readRDS(LDSC_PATH)
aligned_sumstats <- readRDS(SUMSTAT_PATH)
# 1. test with all in initial order
test_defaultorder <- commonfactorGWAS(
covstruc = ldsc_res,
SNPs = aligned_sumstats[1:2,],
cores=1
)
# this causes error calling combine function
# 2. flip the sumstat order
row1 <- aligned_sumstats[1,]
row2 <- aligned_sumstats[2,]
aligned_sumstats_flipped <- rbind(row2, row1)
test_flipped <- commonfactorGWAS(
covstruc = ldsc_res,
SNPs = aligned_sumstats_flipped,
cores=1
)
# this runs successfully (0.927 seconds) with legible results
# 3. just SNP1
test_snp1 <- commonfactorGWAS(
covstruc = ldsc_res,
SNPs = row1,
cores=1
)
# runs with significantly higher runtime (12 seconds) and produces lavaan error
# 4. just SNP2
test_snp2 <- commonfactorGWAS(
covstruc = ldsc_res,
SNPs = row2,
cores=1
)
# runs successfully (0.589 seconds) with legible results that is identical to flipped test above