子集一个表,通过两个列在R中的查找表中的任何参考范围内
R TABLE1:实际上还有更多行
PatientID chr pos type end length
AB1 1 2431 DEL 2100 -331
AC3 1 98041 INV 99100 1059
AG6 1 8743 BND 9000 257
表2:实际上,更多的行,第2和3列是外显子所需输出的范围
Exon 2001 2500
Exon 8700 8750
:从表1中的那些行,其中变体的任何部分(来自pos-end)(来自pos-end)属于任何地方在Table2输出中的外显子的范围中
:
PatientID chr pos type end length
AB1 1 2431 DEL 2100 -331
AG6 1 8743 BND 9000 257
我尝试了一个子集:
subset(table1$pos >= table2$V2 | table1$end <= table$end)
但这并不能给我所需的输出。任何帮助都将不胜感激。
一切顺利
R Table1: In reality many more rows
PatientID chr pos type end length
AB1 1 2431 DEL 2100 -331
AC3 1 98041 INV 99100 1059
AG6 1 8743 BND 9000 257
Table 2: In reality many more rows, columns 2 and 3 are the ranges for the exon
Exon 2001 2500
Exon 8700 8750
Desired output: Those rows from table 1 where any part of the variants (from pos-end) fall within anywhere of the range of an Exon in table2
output:
PatientID chr pos type end length
AB1 1 2431 DEL 2100 -331
AG6 1 8743 BND 9000 257
I have tried a subset:
subset(table1$pos >= table2$V2 | table1$end <= table$end)
but this does not give me my desired output. Any help would be much appreciated.
All the best
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我正确理解您,您想找到的变体(对于Table2至少一个范围, r )至少满足以下条件之一:
table1 $ end end
is在 r表1 $ pos
在 rtable1 中下面的 r 的相对侧是对
所有可能性的示意图描述,这些可能性是由括号界定的 r ,以及由连字符代表的变体以及符合条件的数量。
请注意,下面的代码假定(与Table1)
Table2 [,2]
&lt; =table2 [,3]
。If I understand you correctly, you want to find variants which (for at least one range in table2, r) meet at least one of the following conditions:
table1$end
is within rtable1$pos
is within rtable1$pos
andtable2$end
are on opposite sides of rBelow are schematic depictions of all possibilities with r delimited by brackets and a variant represented by hyphens together with the numbers of conditions met.
Please note that the code below assumes that (unlike table1)
table2[, 2]
<=table2[, 3]
.