fboehm / qtl2pleio

Testing pleiotropy vs. separate QTL in multiparental populations
Other
5 stars 1 forks source link

How to extract from addcovar input a matrix with linearly independent columns? #10

Closed fboehm closed 6 years ago

fboehm commented 6 years ago

I need to look to see how others have addressed this... maybe even an R package has a function to handle this already.

The problem is that we need to think about whether, after subsetting to common subjects and removing subjects with missing phenotypes or covariates, the resulting covariates matrix's columns are linearly independent. If they have "full rank", then we're ok... but, if rank is less than the number of columns in the covariates matrix, how to proceed? For example, we can't merely drop an arbitrary column, since a column could have, for example, all zeros. But, if we rule out this case, that a matrix column is all zeros, then maybe we can just drop one column if the rank is only one less than the number of columns. I need to review my matrix algebra - if 4 vectors form a matrix that has rank 3, is it true that any 3 of them (again, assuming none is the zero vector) together have rank 3? No! We also need to consider the possibility that two columns are "parallel". In a more general setting, we need to check the rank of the subsets of columns. Since, for example, a three vectors could all be coplanar, while no two would be parallel. I am sure that others have written code to solve this. Can I find their code?

fboehm commented 6 years ago

See discussion on stack overflow, with R code, here: https://stackoverflow.com/questions/14943422/r-independent-columns-in-matrix

fboehm commented 6 years ago

We copied functions (and tests) from rqtl/qtl2 R package