genetics-statistics / GEMMA

Genome-wide Efficient Mixed Model Association
https://github.com/genetics-statistics/GEMMA
GNU General Public License v3.0
334 stars 126 forks source link

GSL ERROR: matrix is singular in lu.c at line 262 errno 1 #228

Closed pwang16 closed 4 years ago

pwang16 commented 4 years ago

When running: gemma -bfile 214_plink -k ../output/rel_214.cXX.txt -lmm 2 -n 13 14 15 16 17 18 19 20 21 -o trait_all_suagrs

Got error: GSL ERROR: matrix is singular in lu.c at line 262 errno 1

Could you please help me with this error?

Thanks, Peng

xiangzhou commented 4 years ago

This is usually due to insufficient sample size for analyzing a large number of phenotypes. There are approximately d^2/2 parameters in the mvLMM model when you analyze d different phenotypes. For each parameter, you will need to have at least ~100 to ensure stable estimation. So the typical sample size you want to have for analyzing d phenotypes is around 100d^2. In your case, for analyzing 9 phentoypes, you will usually want to have ~8000 individuals. A small number of phenotypes can often cause algorithm stability issues.

In addition, it is important to normalize each phenotype properly. We usually use quantile normalization (a.k.a. inverse normalization) for each pheonotype. You can use qqnorm function in R to carry out such normalization.

pwang16 commented 4 years ago

Thank you very much for your reply. It is very interesting! I have another questions:

(1) If I have 250 individuals, does that mean I only can do two or three phenotypes at most?

(2) Can I use log transformation to normalize the phenotype?

(2) For the significant SNPs detected from GWAS results of two phenotypes, does it mean the SNPs control the two phenotypes in the same time? How to understand the result?

(3) Can I add the Q matrix (K=3) from the STRUCTURE software (see as below) as the covariant during the LMM? Is the format of Q matrix right below? Or I should only use Q1 one column and the intercept?

Q1 | Q2 | Q3 1 0.014 | 0.972 | 0.014 1 0.003 | 0.993 | 0.004 1 0.071 | 0.917 | 0.012 1 0.035 | 0.854 | 0.111 1 0.013 | 0.982 | 0.005 1 0.762 | 0.017 | 0.221 1 0.035 | 0.963 | 0.002 … 

Best, Peng

xiangzhou commented 4 years ago

(1) Yes. (2) Sure, you can try. We don't have experience with log transformation. (3) It means that the SNP is associated with at least one phentoype. (4) Yes, but you will need to change the Q matrix into the correct format for GEMMA to read.