RGLab / MAST

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

Got error when using summary(zlmCond.glmer) #186

Closed fnhe closed 7 months ago

fnhe commented 7 months ago

Hi MAST developers,

I can successfully get the summary table when using the default method;

library(MAST)
library(zellkonverter)

sce1=readH5AD("./test.h5ad", verbose = TRUE)
sca <- SceToSingleCellAssay(sce1, class = "SingleCellAssay", check_sanity = FALSE)
sca <- sca[freq(sca)>0.1,]
cdr2 <- colSums(assay(sca)>0)
colData(sca)$ngeneson <- scale(cdr2)
label <- factor(colData(sca)$label)
colData(sca)$label <- label
sample<- factor(colData(sca)$Time)
colData(sca)$sample<- sample
zlmCond <- zlm(formula = ~ label + ngeneson + sample, sca=sca)
summaryCond <- summary(zlmCond, doLRT = "label4n")
Combining coefficients and standard errors
Calculating log-fold changes
Calculating likelihood ratio tests
Refitting on reduced model...

Done!

However, if I change to glmer when doing zlm:

zlmCond <- zlm(formula = ~ label + ngeneson + (1 | sample), sca=sca, 
                   method = "glmer", ebayes=FALSE, parallel=FALSE,
                   fitArgsD=list(nAGQ = 0)) # to speed up calculations
summaryCond <- summary(zlmCond.glmer, doLRT = "label4n")
Combining coefficients and standard errors

 *** caught segfault ***

 *** caught segfault ***

 *** caught segfault ***

 *** caught segfault ***
address 0x55f51f97416c, cause 'memory not mapped'

 *** caught segfault ***
address 0x55f51f833ee0, cause 'memory not mapped'

 *** caught segfault ***
address 0x55f51f8b4118, cause 'memory not mapped'

 *** caught segfault ***
address 0x55f51fab3eb8, cause 'memory not mapped'

 *** caught segfault ***
address 0x55f51fcb4378, cause 'memory not mapped'

 *** caught segfault ***
address 0x55f51f873e7c, cause 'memory not mapped'

 *** caught segfault ***
address 0x55f51fbb43e8, cause 'memory not mapped'

Traceback:
 1: forderv(dat, by = varnames, retGrp = TRUE)
 2: dcast.data.table(data.table((TRUE())(coefAndCI, as.is = TRUE)),     primerid + component + contrast ~ metric)

 *** caught segfault ***
address 0x55f51fbf4324, cause 'memory not mapped'

 *** caught segfault ***
address 0x55f51fa741bc, cause 'memory not mapped'
address 0x55f51fb34210, cause 'memory not mapped'

Traceback:
 1: forderv(dat, by = varnames, retGrp = TRUE)
 2: dcast.data.table(data.table(reshape2::melt(coefAndCI, as.is = TRUE)),     summary(zlmCond.glmer, doLRT = "label4n")(primerid + component,         contrast) ~ metric)
 3: .local(object, ...)
 *** caught segfault ***
address 0x55f51f8f3e74, cause 'memory not mapped'

 *** caught segfault ***
address 0x55f51fa34100, cause 'memory not mapped'

 *** caught segfault ***
address 0x55f51fcf3e34, cause 'memory not mapped'
address 0x55f51fb73f0c, cause 'memory not mapped'
 3: .local(object, ..., data.table(reshape2::TRUE(coefAndCI, as.is = TRUE)),
Traceback:
 1: forderv(dat, by = varnames, retGrp = TRUE)
 2: dcast.data.table(data.table(reshape2::melt(coefAndCI, as.is = TRUE)),     primerid + component + contrast ~ metric)
 3: .local(object, ...)
Traceback:
 1: forderv(dat, by = varnames, retGrp = TRUE)
 2: dcast.data.table(data.table(reshape2::melt(coefAndCI, as.is = TRUE)),     primerid + component + contrast ~ metric)
 3: .local(object, ...)
 4: Error in forderv(dat, by = varnames, retGrp = TRUE) : bad value

Traceback:
 1: forderv(dat, by = varnames, retGrp = TRUE)
 2:
 *** caught segfault ***
address 0x309, cause 'memory not mapped'
>
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
    NULL)

 *** caught segfault ***

 *** caught segfault ***
Selection: address 0x55f51f9b43a8, cause 'memory not mapped'

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

Traceback:
 1: forderv(dat, by = varnames, retGrp = TRUE)
 2: dcast.data.table(data.table(reshape2::melt(coefAndCI, as.is = TRUE)),     primerid + component + contrast ~ metric)
 3: .local(object, ...)
 4: Selection:
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

 *** caught segfault ***
address 0x55f51f934230, cause 'memory not mapped'

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:  4: reshape2::TRUE
 5: summary(zlmCond.glmer, doLRT = "label4n")Selection:
Error in forderv(dat, by = varnames, retGrp = TRUE) : bad value

Traceback:
 1: >
 4: summary(zlmCond.glmer, doLRT = "label4n")
 5: summary(zlmCond.glmer, doLRT = "label4n")

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

Traceback:
 1: Selection: forderv(dat, by = varnames, retGrp = TRUE)
 2: dcast.data.table(data.table(reshape2::melt(coefAndCI, as.is = TRUE)),     primerid + component + contrast ~ metric)
 3: .local(object, ...)
 4: summary(zlmCond.glmer, doLRT = "label4n")
 5: summary(zlmCond.glmer, doLRT = "label4n")

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:
Traceback:
 1: forderv(dat, by = varnames, retGrp = TRUE)
 *** caught segfault ***
address 0x55f51fc73f5c, cause 'memory not mapped'
dcast.data.table(data.table(reshape2::melt(coefAndCI, as.is = TRUE)),     primerid + component + contrast ~ metric)summary(zlmCond.glmer, doLRT = "label4n")
Traceback:
 1: forderv(dat, by = varnames, retGrp = TRUE)
 2:
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Segmentation fault (core dumped)
summaryCond <- summary(zlmCond, parallel=FALSE, doLRT = 'label4n')
Combining coefficients and standard errors
Calculating log-fold changes
Calculating likelihood ratio tests
Refitting on reduced model...

Done!
double free or corruption (!prev)
Aborted (core dumped)

Any ideas how this happened? Thanks

amcdavid commented 7 months ago

MAST doesn't have any compiled code in it, and as you noted, the error is coming from calls to lme4. It's possible that it relates to https://r-forge.r-project.org/tracker/?func=detail&atid=294&aid=6835&group_id=61, but it's hard to tell from your report, which doesn't give a way for someone else attempt to reproduce it. I suspect if you recompiled lme4 and Matrix from source the error probably goes away, since there are unit tests in the package that use lme4 that are being run automatically on bioconductor's servers.