Hello!
I'm having trouble running common factor GWAS on some neurodegenerative traits as it keeps throwing back a matrix singularity error. I've successfully replicated the
Wightman et al. 2023 publication using Alzheimer's, ALS, Lewy Body Dementia and Parkinson's, but when I try to exclude LBD or substitute it for Multiple Sclerosis instead, it fails in parts despite the model without SNP's working. Here is the error (the task number and U[,] values vary)
Error in { :
task 8 failed - "Lapack routine dgesv: system is exactly singular: U[7,7] = 0"
I've split the task into batches of 1000SNP so I know where the problems are occurring (batches 9,14,23,25,194,195,206,270,393,447,567,709,etc.) but I can't seem to find anything suspicious about these particular groups of SNP's. The rest of the batches all work fine. The original sumstats files contain rows with Betas or SE's = 0 (never both), but these are all removed by post sumstats() anyway. Here's my code:
length=nrow(RUN_7_SNPmodel)
n=length/1000 #5612.628
for(i in 1:n){
index1 = i*1000+1
index2 = i*1000+1000
print(paste0("Batch number: ",i+1, " Running"))
outputGWAS_batch2 <- commonfactorGWAS(covstruc = LDSCoutput, SNPs = RUN_7_SNPmodel[index1:index2,], estimation = "DWLS", cores = 20, toler = 1e-70, SNPSE = FALSE, parallel = TRUE,GC="standard",MPI=FALSE,smooth_check=TRUE)
saveRDS(outputGWAS_batch2,file = paste0("OutputGWAS_RUN_7_toler_batch",i+1,".RData") )
}
All included GWAS have a Heritability Z-score > 4 and the smallest has a sample size of 26,723. I think I've explored all other solutions for similar errors in this group but I may be wrong! Here's the LDSCoutput for the run with AD, ALS, MS and PD included:
$V
[,1] [,2] [,3] [,4] [,5]
[1,] 6.485030e-05 3.002846e-06 -1.666858e-06 -4.112997e-06 1.677034e-06
[2,] 3.002846e-06 3.682346e-06 7.168059e-07 1.259315e-06 7.261583e-07
[3,] -1.666858e-06 7.168059e-07 1.480481e-05 7.564524e-07 1.756760e-07
[4,] -4.112997e-06 1.259315e-06 7.564524e-07 3.018949e-05 4.376101e-07
[5,] 1.677034e-06 7.261583e-07 1.756760e-07 4.376101e-07 3.051818e-06
[6,] -1.160472e-06 4.047893e-07 1.745293e-06 -1.218710e-06 8.718427e-08
[7,] 2.633134e-06 3.430578e-07 4.999136e-07 1.455192e-06 9.321648e-07
[8,] 1.378374e-05 3.918891e-06 4.748670e-06 1.018749e-05 2.477197e-06
[9,] 2.235910e-06 8.672565e-07 1.809971e-06 6.681371e-06 4.940327e-07
[10,] 1.722475e-05 2.559956e-06 1.989956e-06 3.666518e-06 1.535065e-06
[,6] [,7] [,8] [,9] [,10]
[1,] -1.160472e-06 2.633134e-06 1.378374e-05 2.235910e-06 1.722475e-05
[2,] 4.047893e-07 3.430578e-07 3.918891e-06 8.672565e-07 2.559956e-06
[3,] 1.745293e-06 4.999136e-07 4.748670e-06 1.809971e-06 1.989956e-06
[4,] -1.218710e-06 1.455192e-06 1.018749e-05 6.681371e-06 3.666518e-06
[5,] 8.718427e-08 9.321648e-07 2.477197e-06 4.940327e-07 1.535065e-06
[6,] 6.988151e-06 -4.716473e-07 -4.667419e-06 1.684793e-06 -4.118639e-06
[7,] -4.716473e-07 1.224719e-05 6.762582e-06 2.070561e-06 5.606182e-06
[8,] -4.667419e-06 6.762582e-06 1.160256e-04 1.150625e-05 3.258666e-05
[9,] 1.684793e-06 2.070561e-06 1.150625e-05 5.127326e-05 1.887847e-05
[10,] -4.118639e-06 5.606182e-06 3.258666e-05 1.887847e-05 2.292578e-04
$S
AD_2021 ALS MS PD_noproxy
[1,] 0.039078315 0.008454464 -0.003234379 0.011873066
[2,] 0.008454464 0.015641720 0.001365194 0.007969419
[3,] -0.003234379 0.001365194 0.119938037 0.008371002
[4,] 0.011873066 0.007969419 0.008371002 0.153429643
$I
[,1] [,2] [,3] [,4]
[1,] 1.039005277 -0.001888624 0.016065851 -0.007650786
[2,] -0.001888624 1.027053159 -0.005457264 0.020401443
[3,] 0.016065851 -0.005457264 1.027321318 -0.007544079
[4,] -0.007650786 0.020401443 -0.007544079 0.973303850
$N
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] 111607.8 94357.87 57029.97 44861.54 79539.38 48158.18 37931.51 29063.96
[,9] [,10]
[1,] 22915.45 18022.58
$m
[1] 1173569
Hoping you may know what's going wrong
Thank you!
Tomas