RGLab / MAST

Tools and methods for analysis of single cell assay data in R
224 stars 57 forks source link

Changes to Matrix::rankMatrix break tests #149

Closed amcdavid closed 3 years ago

amcdavid commented 3 years ago

We're failing CHECK in Bioconductor Devel and Bioconductor 3.12 since around Xmas. I can reproduce the failing test on my machine.

The issue is that rank deficient design matrices are triggering an error from lme4, while previously the rank deficient columns were just pruned with a message. I believe there may be a bug upstream in Matrix::rankMatrix, in that the model matrix, after pruning seems to obviously be rank 5 (via svd(X) or rankMatrix(X, method = 'qrLINPACK')) but the default rankMatrix(X, method = 'qr.R') says rank 3. This function did undergo some changes in the most recent release of Matrix on 15-December-2020.

Until / unless this is fixed upstream we might need to handle rank deficient matrices on our end and set lmerControl(check.rankX = 'ignore').

Here's the offending design matrix: ``` X = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0), .Dim = c(55L, 5L), .Dimnames = list(c("Sub01 1 G11", "Sub01 1 G12", "Sub01 1 H01", "Sub01 1 H02", "Sub01 1 H03", "Sub01 1 H04", "Sub01 1 H06", "Sub01 1 H07", "Sub01 1 H08", "Sub01 1 H09", "Sub01 2 E01", "Sub01 2 E10", "Sub01 2 E12", "Sub01 2 G11", "Sub01 2 H03", "Sub01 2 H04", "Sub01 2 H06", "Sub01 2 H07", "Sub01 2 H08", "Sub01 2 H09", "Sub01 2 H10", "Sub02 1 D08", "Sub02 1 D09", "Sub02 1 H05", "Sub02 1 H09", "Sub02 1 H10", "Sub02 1 H11", "Sub02 2 B04", "Sub02 2 D08", "Sub02 2 D09", "Sub02 2 F02", "Sub02 2 H08", "Sub02 2 H09", "Sub02 2 H10", "Sub02 2 H11", "Sub02 3 A03", "Sub02 3 A04", "Sub02 3 A07", "Sub02 3 B01", "Sub02 3 B06", "Sub02 3 C01", "Sub02 3 D04", "Sub02 3 D08", "Sub02 3 D09", "Sub02 3 D10", "Sub02 3 D11", "Sub02 3 E01", "Sub02 3 E02", "Sub02 3 E07", "Sub02 3 G01", "Sub02 3 G08", "Sub02 3 H08", "Sub02 3 H09", "Sub02 3 H10", "Sub02 3 H11"), c("`(Intercept)`", "`PopulationCD154-VbetaUnresponsive`", "`PopulationCD154+VbetaResponsive`", "`PopulationCD154+VbetaUnresponsive`", "PopulationVbetaResponsive"))) ```
amcdavid commented 3 years ago

It seems this relates to qr.R(qr(X)) returning negative values along the diagonal, just as the warning from rankMatrix says. This looks like some issue upstream in LAPACK...

amcdavid commented 3 years ago

This seems fixed in Matrix version 1.30-2, available via install.packages("Matrix", repos = "http://R-Forge.R-project.org"). Hopefully it'll be pushed to CRAN soon.