Closed MengQiuchen closed 5 years ago
There's a lot of gaps in your bug report:
MnnSim2D
?NA
s in the input?Do read this. Otherwise I can only guess as to the causes.
Sorry, I didn't make it clear.
I followed the code in [https://github.com/MarioniLab/MNN2017/tree/master/Simulations] to simulate figure2 in MNN paper. It worked well.
But when I changed ngenes
in simulateBatches.R
from 100 to more than 400. Others are the same. I got this error.
I also checked two batches matrix, there's no Na
in the input.
The following works for me.
source("simulateBatches.R") # modified with ngenes=400
load("Sim.RData")
hard <- mnnCorrect(B1, B2i, k=20, sigma=1, cos.norm.in=FALSE, cos.norm.out=FALSE, var.adj=TRUE)
easy <- mnnCorrect(B1, B2ii, k=20, sigma=1, cos.norm.in=FALSE, cos.norm.out=FALSE, var.adj=TRUE)
Note that mnnCorrect
will move from scran to batchelor, hence the deprecation warnings.
I checked Session Information and rewrote the code entirely the same. Problem solved.
But the corrected space has many Na
. For example, sum(is.na(easy$corrected[[2]]))
equals to 3600
when ngenes=400
.
I find that if we don't add random noise to Batch 2, or add noise with small sd, the numbers of Na
will decrease to 0.
This is caused by a double-precision underflow when performing the Gaussian smoothing. It has now been fixed in the batchelor package (version 1.1.5, BioC-devel - not Bioc-release!). You can also get it from https://github.com/LTLA/batchelor. Keep in mind the output type of batchelor::mnnCorrect
is different from scran::mnnCorrect
, so you will have to update your scripts for that.
The cost of the fix is that the smoothing is much slower. But better slow than broken, and besides, people should be using fastMNN()
rather than mnnCorrect()
.
I'm going to assume that the latest version fixed this problem, unless told otherwise.
when gene dimension is more than 400, mnnCorrect function report error:
Thank you very much.