drisso / zinbwave

Clone of the Bioconductor repository for the zinbwave package, see https://bioconductor.org/packages/zinbwave
43 stars 10 forks source link

W2=0 when calculating two latent variables #59

Closed vincr04 closed 4 years ago

vincr04 commented 4 years ago

Hi, I have some 10X single-cell data and am using zinbwave to infer latent variables. I realised that when using K=2 in zinbFit, W1 values are between ~-0.2 and ~0.2, but W2 values are all 0. My code: design <- model.matrix(~se$sex1*se$stim) zinb <- zinbFit(Y=se, X=design, epsilon=1e6, K=2, verbose=T, BPPARAM=MulticoreParam(8)) se_zinb <- zinbwave(Y=se, X=design, epsilon=1e6, fitted_model=zinb, K=2, verbose=T, observationalWeights=T) head(reducedDim(se_zinb)) Screenshot 2020-07-15 at 17 46 38

You can download the data here: https://github.com/vincr04/variousdata/blob/master/se.Robj

Somehow if I choose K=3 the problem doesn't occur... zinb <- zinbFit(Y=se, X=design, epsilon=1e6, K=3, verbose=T, BPPARAM=MulticoreParam(8)) se_zinb <- zinbwave(Y=se, X=design, epsilon=1e6, fitted_model=zinb, K=3, verbose=T, observationalWeights=T) head(reducedDim(se_zinb)) Screenshot 2020-07-15 at 17 47 50

Is this a bug, or did I do something wrong?

drisso commented 4 years ago

Thanks, this definitely looks like a bug, I will have a look at the data and update you here.

drisso commented 4 years ago

I can confirm that I'm able to reproduce your example. This is quite puzzling, but I'm looking into it.

drisso commented 4 years ago

I found the bug. This was due to softImpute sometimes returning a singular value of 0. I've fixed it in version 1.11.6.