bvilhjal / ldpred

MIT License
95 stars 58 forks source link

svd did not converge in linear least square #78

Closed yingji15 closed 4 years ago

yingji15 commented 5 years ago

Hi Bjarni, Thanks for your efforts in updating LDpred. So I have the following error running a Gibbs step. The command I use is

python LDpred.py gibbs --cf=fe_summ --ldr=1000 --out=femeta01 --ldf=femeta --f=0.1 --N=267423

I got this output errors

Applying LDpred with LD radius: 1000 1037636 SNP effects were found Heritability used for inference: 0.1585 Calculating LDpred-inf weights Calculating SNP weights for Chromosome 1 Calculating SNP weights for Chromosome 2 Calculating SNP weights for Chromosome 3 Calculating SNP weights for Chromosome 4 Calculating SNP weights for Chromosome 5 Calculating SNP weights for Chromosome 6 Calculating SNP weights for Chromosome 7 Calculating SNP weights for Chromosome 8 Calculating SNP weights for Chromosome 9 Calculating SNP weights for Chromosome 10 Calculating SNP weights for Chromosome 11 Calculating SNP weights for Chromosome 12 Calculating SNP weights for Chromosome 13 Calculating SNP weights for Chromosome 14 Calculating SNP weights for Chromosome 15 Calculating SNP weights for Chromosome 16 Traceback (most recent call last): File "LDpred.py", line 300, in main() File "LDpred.py", line 287, in main LDpred_gibbs.main(p_dict) File "LDpred_gibbs.py", line 366, in main h2=p_dict['h2'], verbose=p_dict['debug'], summary_dict=summary_dict) File "LDpred_gibbs.py", line 203, in ldpred_genomewide h2=h2_chrom, n=n, ld_window_size=2 * ld_radius, verbose=False) File "LDpred_inf.py", line 43, in ldpred_inf A_inv = linalg.pinv(A) File "python3.6/site-packages/scipy/linalg/basic.py", line 1320, in pinv x, resids, rank, s = lstsq(a, b, cond=cond, check_finite=False) File "python3.6/site-packages/scipy/linalg/basic.py", line 1241, in lstsq raise LinAlgError("SVD did not converge in Linear Least Squares") numpy.linalg.LinAlgError: SVD did not converge in Linear Least Squares

I thought maybe there is something wrong with my summary stats file, but I did run it with inf (p=1) and p=0.3 model and it worked, now with p=0.1 it didn't work. Any ideas why it is and how to fix this?

bvilhjal commented 5 years ago

Thanks for your comment, and I apologize for the slow reply (I was on holidays in April).

My best guess is that you were unlucky, in the sense that some LD matrix was not invertible using a generalized inverse. I suggest try a different LD radius. Perhaps you can also use fewer SNPs, e.g. using the --only-hm3 flag in the coordination step.

Best, Bjarni