Singularity error comonfactorGWAS

102 views
Skip to first unread message

Dúalta McGrath

unread,
Mar 21, 2025, 3:54:12 PMMar 21
to Genomic SEM Users
Hi, Im running commonfactorgwas for chronic pain and atherosclerosis but I keep getting a matrix singularity error

Error in { : 

  task 1 failed - "system is computationally singular: reciprocal condition number = 2.94596e-10"

Calls: commonfactorGWAS -> %dopar% -> <Anonymous>

Execution halted


I've tried fixing the issue with LDSC matrix adjustments before running the model, and changing the toler parameters but I cant seem to fix the problem.


library(devtools)

library(GenomicSEM)

library(parallel)


# Load LDSC structure

load("LDSC_INT.RData")

LDSC_INT$V <- LDSC_INT$V + diag(1e-6, nrow(LDSC_INT$V))


# Load chromosome-specific summary statistics

sumstats_file <- paste0("CWP_ATHEROSCLEROSIS_sumstats_chr22.RData")


load(sumstats_file)  # Load the per-chromosome sumstats


# Specify the model

model <- "F1 =~ CWP + Atherosclerosis

F1 ~ SNP"


# Run Common Factor GWAS for this chromosome

CWP_Atherosclerosis_factor <- commonfactorGWAS(

  covstruc = LDSC_INT,

  SNPs = chr_data,

  cores = 120,

  smooth_check = TRUE,

  parallel = TRUE,

  toler = 1e-6

 )


# Save results per chromosome

save_file <- paste0("CWP_Atherosclerosis_factor_chr22.RData")

save(CWP_Atherosclerosis_factor, file = save_file)


# Save summary to text file

sink(paste0("CWP_Atherosclerosis_factor_chr22_summary.txt"))

summary(CWP_Atherosclerosis_factor)

sink()


My LDSC matrix output looks like this


> print(LDSC_INT)

$V

              [,1]          [,2]         [,3]

[1,]  8.073432e-04 -3.825977e-05 8.615926e-07

[2,] -3.825977e-05  1.287388e-04 9.360435e-06

[3,]  8.615926e-07  9.360435e-06 2.603861e-04


$S

             CWP Atherosclerosis

[1,]  0.33262723     -0.08408001

[2,] -0.08408001      0.17893645


$I

            [,1]        [,2]

[1,]  1.00136917 -0.02388809

[2,] -0.02388809  1.01218723


$N

       [,1]     [,2]   [,3]

[1,] 249843 300402.7 361194


$m

[1] 1173569


At the moment, im trying to run the script again but with parallel = FALSE to see if the issue is stemming from that, but if theres something obvious that im missing that you can help me with id really appreciate it!


Best, wishes and thanks in advance,

Dúalta

Elliot Tucker-Drob

unread,
Mar 21, 2025, 4:20:30 PMMar 21
to Dúalta McGrath, Genomic SEM Users
it seems that you are trying to fit a factor model with only two indicators. such a model is not identified without adding further constraints. you should be able to find more on this by searching through the google group archive, as this comes up often. number of indicators and model identifiability is also covered in standard texts on structural equation modelling. Rex Kline's is one that is particularly accessible.

--
You received this message because you are subscribed to the Google Groups "Genomic SEM Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to genomic-sem-us...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/genomic-sem-users/fb2be117-bb60-4b66-b7f0-d9a78f621c4cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages