LR
- 對(duì)于每個(gè)基因:利用邏輯回歸涣雕,使用這個(gè)基因的表達(dá)來(lái)預(yù)測(cè)分組(屬于(1) 或 不屬于(0)這個(gè)細(xì)胞類(lèi)型),如果有隱變量演顾,就也作為自變量加到回歸模型里疟赊。
- 函數(shù):Seurat:::LRDETest
function (data.use, cells.1, cells.2, latent.vars = NULL, verbose = TRUE)
{
group.info <- data.frame(row.names = c(cells.1, cells.2))
group.info[cells.1, "group"] <- "Group1"
group.info[cells.2, "group"] <- "Group2"
group.info[, "group"] <- factor(x = group.info[, "group"])
data.use <- data.use[, rownames(group.info), drop = FALSE]
latent.vars <- latent.vars[rownames(group.info), , drop = FALSE]
my.sapply <- ifelse(test = verbose && nbrOfWorkers() == 1,
yes = pbsapply, no = future_sapply)
p_val <- my.sapply(X = 1:nrow(x = data.use), FUN = function(x) {
if (is.null(x = latent.vars)) {
model.data <- cbind(GENE = data.use[x, ], group.info)
fmla <- as.formula(object = "group ~ GENE")
fmla2 <- as.formula(object = "group ~ 1")
}
else {
model.data <- cbind(GENE = data.use[x, ], group.info,
latent.vars)
fmla <- as.formula(object = paste("group ~ GENE +",
paste(colnames(x = latent.vars), collapse = "+")))
fmla2 <- as.formula(object = paste("group ~", paste(colnames(x = latent.vars),
collapse = "+")))
}
model1 <- glm(formula = fmla, data = model.data, family = "binomial")
model2 <- glm(formula = fmla2, data = model.data, family = "binomial")
lrtest <- lrtest(model1, model2)
return(lrtest$Pr[2])
})
to.return <- data.frame(p_val, row.names = rownames(data.use))
return(to.return)
}
未完待續(xù)