You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I ran a single cell project practice here, More specifically, the **find_de_MAST_RE**function in Chapter16.5.1. It is to use MAST package to fit model. However, once the code is coming to summaryCond <- summary(zlmCond, doLRT='groupstim.CD14_Monocytes')(within the find_de_MAST_RE function), my jupyterlab will report kernel died immediately, without any traceback information. The code will work well if I run renv::deactivate command, may you know why could this happen? Is there any method to make jupyterlab and renv work well with each other?
the find_de_MAST_RE function is like below:
%%R
find_de_MAST_RE <- function(adata_){
# create a MAST object
sca <- SceToSingleCellAssay(adata_, class = "SingleCellAssay")
print("Dimensions before subsetting:")
print(dim(sca))
print("")
# keep genes that are expressed in more than 10% of all cells
sca <- sca[freq(sca)>0.1,]
print("Dimensions after subsetting:")
print(dim(sca))
print("")
# add a column to the data which contains scaled number of genes that are expressed in each cell
cdr2 <- colSums(assay(sca)>0)
colData(sca)$ngeneson <- scale(cdr2)
# store the columns that we are interested in as factors
label <- factor(colData(sca)$label)
# set the reference level
label <- relevel(label,"ctrl")
colData(sca)$label <- label
celltype <- factor(colData(sca)$cell_type)
colData(sca)$celltype <- celltype
# same for donors (which we need to model random effects)
replicate <- factor(colData(sca)$replicate)
colData(sca)$replicate <- replicate
# create a group per condition-celltype combination
colData(sca)$group <- paste0(colData(adata_)$label, ".", colData(adata_)$cell_type)
colData(sca)$group <- factor(colData(sca)$group)
# define and fit the model
zlmCond <- zlm(formula = ~ngeneson + group + (1 | replicate),
sca=sca,
method='glmer',
ebayes=F,
strictConvergence=F,
fitArgsD=list(nAGQ = 0)) # to speed up calculations
# perform likelihood-ratio test for the condition that we are interested in
summaryCond <- summary(zlmCond, doLRT='groupstim.CD14_Monocytes')
# get the table with log-fold changes and p-values
summaryDt <- summaryCond$datatable
result <- merge(summaryDt[contrast=='groupstim.CD14_Monocytes' & component=='H',.(primerid, `Pr(>Chisq)`)], # p-values
summaryDt[contrast=='groupstim.CD14_Monocytes' & component=='logFC', .(primerid, coef)],
by='primerid') # logFC coefficients
# MAST uses natural logarithm so we convert the coefficients to log2 base to be comparable to edgeR
result[,coef:=result[,coef]/log(2)]
# do multiple testing correction
result[,FDR:=p.adjust(`Pr(>Chisq)`, 'fdr')]
result = result[result$FDR<0.01,, drop=F]
result <- stats::na.omit(as.data.frame(result))
return(result)
}
The text was updated successfully, but these errors were encountered:
Hello, thanks for developing this useful tool.
I got some problem when I use renv in jupyterlab:
When I ran a single cell project practice here, More specifically, the **find_de_MAST_RE**function in Chapter16.5.1. It is to use MAST package to fit model. However, once the code is coming to summaryCond <- summary(zlmCond, doLRT='groupstim.CD14_Monocytes')(within the find_de_MAST_RE function), my jupyterlab will report kernel died immediately, without any traceback information. The code will work well if I run renv::deactivate command, may you know why could this happen? Is there any method to make jupyterlab and renv work well with each other?
the find_de_MAST_RE function is like below:
The text was updated successfully, but these errors were encountered: