navinlabcode / copykat

Other
203 stars 54 forks source link

"step 4: measuring baselines ...": Error in mixtools::normalmixEM(data.c, lambda = rep(1, 3)/3, mu = c(-0.2, : NA/NaN/Inf in foreign function call (arg 4) #91

Open confiya opened 1 year ago

confiya commented 1 year ago

Dear authors Thank you for developing such an excellent package! When I use it,I met some questions. Because all the cells were filtered out when I first run the original code, three places in the original code were commented:

1—— `# genes.raw <- apply(rawmat, 2, function(x) (sum(x > 0)))

if (sum(genes.raw > 200) == 0)

stop("none cells have more than 200 genes")

if (sum(genes.raw < 100) > 1) {

rawmat <- rawmat[, -which(genes.raw < 200)]

print(paste("filtered out ", sum(genes.raw <= 200),

" cells with less than 200 genes; remaining ", ncol(rawmat),

" cells", sep = ""))

}

2——

if (length(toRev) > 0) {

anno.mat <- anno.mat[-toRev, ]

}

ToRemov2 <- NULL

for (i in 8:ncol(anno.mat)) {

cell <- cbind(anno.mat$chromosome_name, anno.mat[, i])

cell <- cell[cell[, 2] != 0, ]

if (length(as.numeric(cell)) < 5) {

rm <- colnames(anno.mat)[i]

ToRemov2 <- c(ToRemov2, rm)

}

else if (length(rle(cell[, 1])$length) < 23 | min(rle(cell[,

1])$length) < ngene.chr) {

rm <- colnames(anno.mat)[i]

ToRemov2 <- c(ToRemov2, rm)

}

i <- i + 1

}

if (length(ToRemov2) == (ncol(anno.mat) - 7))

stop("all cells are filtered")

if (length(ToRemov2) > 0) {

anno.mat <- anno.mat[, -which(colnames(anno.mat) %in%

ToRemov2)]

}

3——

ToRemov3 <- NULL

for (i in 8:ncol(anno.mat2)) {

cell <- cbind(anno.mat2$chromosome_name, anno.mat2[,

i])

cell <- cell[cell[, 2] != 0, ]

if (length(as.numeric(cell)) < 5) {

rm <- colnames(anno.mat2)[i]

ToRemov3 <- c(ToRemov3, rm)

}

else if (length(rle(cell[, 1])$length) < 23 | min(rle(cell[,

1])$length) < ngene.chr) {

rm <- colnames(anno.mat2)[i]

ToRemov3 <- c(ToRemov3, rm)

}

i <- i + 1

}

if (length(ToRemov3) == ncol(norm.mat.relat))

stop("all cells are filtered")

if (length(ToRemov3) > 0) {

norm.mat.relat <- norm.mat.relat[, -which(colnames(norm.mat.relat) %in%

ToRemov3)]

}`

Then I am encountering errors on "step 4: measuring baselines ...": Error in mixtools::normalmixEM(data.c, lambda = rep(1, 3)/3, mu = c(-0.2, : NA/NaN/Inf in foreign function call (arg 4) but I have checked that there is no NA value in my counts. Is it generated in the process of calculation? I can't solve this problem .Could you please help me? I would appreciate it if you could reply to me. Thank you very much!