【发布时间】:2023-04-02 19:40:01
【问题描述】:
头部(覆盖)
chr Pos Val
X 129271111 10
X 129271112 10
X 129271113 10
X 129271114 10
X 129271115 10
X 129271116 11
X 129271117 11
X 129271118 11
X 129271119 11
X 129271120 11
X 129271121 11
X 129271122 11
X 129271123 11
X 129271124 11
X 129271125 11
X 129271126 11
X 129271127 11
X 129271128 11
X 129271129 11
X 129271130 11
X 129271131 11
X 129271132 11
X 129271133 11
头部(注解)
chr Region start end Gene status
X Exon 129271053 129271110 AIFM1 NO
X Exon 129270618 129270706 AIFM1 NO
X Exon 129270020 129270160 AIFM1 NO
X Exon 129267288 129267430 AIFM1 NO
X Exon 129265650 129265774 AIFM1 NO
X Exon 129263945 129264141 AIFM1 NO
X Exon 129263532 129263603 AIFM1 NO
3 Exon 15643358 15643401 BTD NO
3 Exon 15676931 15677195 BTD NO
3 Exon 15683415 15683564 BTD NO
尝试使用第一个文件中的基因名称创建一个新列,用于第二个位置的开始和结束之间的位置以及相应的基因名称。
covreage$Gene <- ifelse(covreage$chr == annotation$chr & covreage$pos >= annotation$start & covreage$pos <= annotation$end,annotation$Gene,"NA")
问题是第二个文件的 file1 pos 的值在 range 和 chr 和 position 应该在两个文件中匹配。 chr 可以有 23 个不同的值,Pos 在所有不同的 chr 值中都有相似的值。 chr 和 position 一起成为唯一元素
上面的代码给出了这个错误
Warning messages:
1: In is.na(e1) | is.na(e2) :
longer object length is not a multiple of shorter object length
2: In `==.default`(covreage$chr, annotation$chr) :
longer object length is not a multiple of shorter object length
3: In covreage$pos >= annotation$start :
longer object length is not a multiple of shorter object length
4: In covreage$pos <= annotation$end :
longer object length is not a multiple of shorter object length
【问题讨论】:
-
你的数据框中的
annotation$Chromosome在哪里? -
如果您想在
r中找到解决方案,为什么要用awk标记它? -
由于您使用 data.table 进行了标记,也许您需要查看它的非 equi 和更新连接,这可能能够干净利落地解决这个问题,例如
DT1[, gene := DT2[.SD, on=.(chr, start >= Pos, end <= Pos), x.Gene]]
标签: r data.table