我有两个数据集:尺寸为 53*17237 的“datExprSTLMS”和尺寸为 99*22144 的“datExprSTF”。在两个数据集中,一些列(gene_names)是通用的。基于在两个数据集的 colnames 之间使用 match(),我建立了 15711(TRUE) gene_name 作为它们之间的交叉基因。现在,我想提供“datExprSTLMS”的子集,以便“datExprSTLMS”的维度为 53*15711。为此,我编写了以下代码:
dim(datExprSTF)
#[1] 99 22144
dim(datExprSTLMS)
#[1] 53 17237
TCGA2STF <- match(colnames(datExprSTLMS), colnames(datExprSTF))
table(is.finite(TCGA2STF))
#FALSE TRUE
#1526 15711
#delete NA(mismatch gene_names which in my case are 1526)
TCGA2STF_final <- Filter(function(x)!all(is.na(x)), TCGA2STF)
datExprSTLMS_final <- as.data.frame(datExprSTLMS[,TCGA2STF_final])
但在运行我的代码的最后一行后,我得到以下错误:
Error in datExprSTLMS[, TCGA2STF_final] : subscript out of bounds
我用 R 语言编写代码。我需要指导
我们可以使用intersect
找到两个数据集之间的公共列,然后使用它们进行子集datExprSTLMS
datExprSTLMS[, intersect(colnames(datExprSTLMS), colnames(datExprSTF))]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句