删除两个文件中找不到的数据-RStudio

问题描述 投票:0回答:1

我正在处理两个文件,一个是基因水平计数文件,另一个是元数据。我在下面的代码行中运行并收到错误消息。

deseqdt = DESeqDataSetFromMatrix(countData = baseinput,colData = basemeta,设计=〜race) DESeqDataSetFromMatrix(countData = baseinput,colData = basemeta,中的错误: ncol(countData)== nrow(colData)不是TRUE

我现在看到错误的原因是我的计数数据中有503列,而colData中的593列是基于我的元数据的。我试图用for循环删除它,但是没有任何运气。如何最有效地删除两个文件中都没有的项目?

r bioinformatics
1个回答
0
投票
# find columns in common
common_cols = intersect(names(baseinput), names(basemeta))
# only use the common columns
deseqdt = DESeqDataSetFromMatrix(
  countData = baseinput[common_cols],
  colData = basemeta[common_cols],
  design = ~race
)
© www.soinside.com 2019 - 2024. All rights reserved.