🔧
tool
相关软件(R代码)
```r # 泊松回归示例:某基因在不同处理组中的表达计数 # 模拟数据 count_data <- data.frame( count = c(rpois(10, 5), rpois(10, 10), rpois(10, 15)), treatment = factor(rep(c("Control", "Low", "High"), each = 10)), size_factor...
📖 定义
# 泊松回归示例:某基因在不同处理组中的表达计数
# 模拟数据
count_data <- data.frame(
count = c(rpois(10, 5), rpois(10, 10), rpois(10, 15)),
treatment = factor(rep(c("Control", "Low", "High"), each = 10)),
size_factor = rep(c(1.0, 1.1, 0.9), each = 10) # 测序深度
)
# 泊松回归(带偏移量)
model_pois <- glm(count ~ treatment + offset(log(size_factor)),
data = count_data, family = poisson)
summary(model_pois)
# 检验过度离散
dispersion <- sum(residuals(model_pois, type = "pearson")^2) / df.residual(model_pois)
cat("离散参数:", dispersion, "\n")
# 如果过度离散,使用负二项回归
# install.packages("MASS")
library(MASS)
model_nb <- glm.nb(count ~ treatment + offset(log(size_factor)), data = count_data)
summary(model_nb)