UW-GAC/GENESIS

fitnullmodel error for matrix with negatives

Closed this issue · 3 comments

Trying to do run the fitnullmodel using a grm covariate matrix generated with pc-air. I get:

Error in asMethod(object) : not a positive definite matrix

This seem to stem from having negative values generated with king and pc-air in the matrix. Some issue with how cholesky decomposition is performed I guess, but why does this happen?

Could you please provide some additional detail on what you are doing? pcair generates ancestry PCs, not a GRM or kinship matrix (KM), so it's not clear to me what matrix you are using in fitNullModel.

It's possible (though uncommon) that a GRM/KM can have issues that lead to a non-positive definite matrix that needs to be inverted in the REML procedure. The presence of negative values in the GRM/KM is not necessarily problematic though -- in fact, a standard GRM will certainly have negative values.

To build the GRM I am using the results from pcrelate transformed to matrix using pcrelateToMatrix(), which I guess in part uses the PCs generated by pc-air to build. I am not sure exactly which function might be generating the negative values. So I could just invert the GRM results from pcrelateToMatrix and use that for fitNullModel?

Yes, pcrelate uses the PCs from pcair to adjust for (or "remove") the correlation due to ancestry (as captured by the PCs). Using the pcrelateToMatrix function to format the results from pcrelate as a matrix is the correct thing to do.

The fact that you have negative values in the pcrelate kinship matrix (or a GRM) is not a problem; that is perfectly fine and expected. A positive definite matrix can have negative values.

One of the more common issues I've seen that can lead to a non-positive definite matrix is when your sample set includes duplicates or MZ twins. You could check for those -- if you have any, try removing one sample from the pair and running again.