r - 如何有满秩矩阵?
问题描述
我有两组数据,第 1 批的 4 个样本,每个样本 2 个重复,另外 4 个样本,第 2 批的 2 个重复。
我想从这些样本中删除批次效应,并一起比较不同的方法。我已经完成了以下命令,但面临错误:
design
method batch
L4_rep1 L b1
L4_rep2 L b1
L6_L8_rep1 L b1
L6_L8_rep2 L b1
Q5_Q7_rep1 Q b1
Q5_Q7_rep2 Q b1
Q3_rep1 Q b1
Q3_rep2 Q b1
co_40d_A co_40d b2
co_40d_B co_40d b2
co_60d_A co_60d b2
co_60d_B co_60d b2
EB_A EB b2
EB_B EB b2
H9_A H9 b2
H9_B H9 b2
design$method <- factor(design$method, levels = c("L", "Q", "co_40d","co_60d", "EB", "H9"))
design$batch <- factor(design$batch, levels = c("b1", "b2"))
design.matrix <- model.matrix(~0+batch+method,design)
design.matrix
batchb1 batchb2 methodQ methodco_40d methodco_60d methodEB methodH9
L4_rep1 1 0 0 0 0 0 0
L4_rep2 1 0 0 0 0 0 0
L6_L8_rep1 1 0 0 0 0 0 0
L6_L8_rep2 1 0 0 0 0 0 0
Q5_Q7_rep1 1 0 1 0 0 0 0
Q5_Q7_rep2 1 0 1 0 0 0 0
Q3_rep1 1 0 1 0 0 0 0
Q3_rep2 1 0 1 0 0 0 0
co_40d_A 0 1 0 1 0 0 0
co_40d_B 0 1 0 1 0 0 0
co_60d_A 0 1 0 0 1 0 0
co_60d_B 0 1 0 0 1 0 0
EB_A 0 1 0 0 0 1 0
EB_B 0 1 0 0 0 1 0
H9_A 0 1 0 0 0 0 1
H9_B 0 1 0 0 0 0 1
library(edgeR)
data_filter<- count table
edgeR.dgelist = DGEList(data_filter)
edgeR.dgelist_normal = calcNormFactors(edgeR.dgelist)
CommonDisp <- estimateGLMCommonDisp(edgeR.dgelist_normal, design.matrix)
Error in glmFit.default(y, design = design, dispersion = dispersion, offset = offset, : Design matrix not of full rank. The following coefficients not estimable: methodH9
我想知道我的设计矩阵是否正确?另外,我喜欢将Q方法与其他方法进行比较,请您帮我做对比吗?
解决方案
无法基于此设计创建满秩矩阵。如果您有变量 batch1 和其中一个方法列的值,您可以很容易地知道其他虚拟变量的值。也无法跨批次比较方法,例如,批次 2 中没有方法“L”可与批次 1 进行比较。
推荐阅读
- python - 在库之间共享小段代码
- react-native - 反应导航设置初始路线到另一个堆栈屏幕
- azure - 现实世界的示例可能通过 Azure Devops 或 GitHub 操作将 Infra 匿名化为代码
- linux - 如何使用 bash 将具有不同版本号的多个文件从一个目录复制到另一个目录?
- android - Flutter:如何将 SVG 添加为启动画面?
- javascript - 保留字符串格式中提到的空格
- flutter - 我怎样才能拥有像这样的动画 SliverAppBar?
- python - 比较txt文件中的值
- regex - 匹配以逗号和空格分隔的两个单词的正则表达式
- sql - 获取一列的所有可能组合