Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fitnullmodel error for matrix with negatives #74

Closed
Reavyr opened this issue Aug 18, 2021 · 3 comments
Closed

fitnullmodel error for matrix with negatives #74

Reavyr opened this issue Aug 18, 2021 · 3 comments

Comments

@Reavyr
Copy link

Reavyr commented Aug 18, 2021

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?

@mconomos
Copy link
Contributor

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.

@Reavyr
Copy link
Author

Reavyr commented Aug 19, 2021

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?

@mconomos
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants