R中的匹配范围合并 [英] Matched Range Merge in R
问题描述
我想合并/合并两个文件,这样如果我的第一个文件的 B 列中的条目落入我的第二个文件的 B 列和 C 列的范围内,输出将包含两个文件中包含的所有信息文件.
I would like to merge/combine two files, so that if an entry in column B of my first file falls into the range of columns B and C in my second file, the output will contain all of the information contained in both files.
像这样:
文件 1
A B
rs10 23353
rs100 10000
rs234 54440
文件 2
A B C
E235 20000 30000
E255 50000 60000
其中,因为 23353 介于 20000 和 30000 之间,而 54440 介于 50000 和 60000 之间,所以输出文件如下所示:
where, because 23353 falls between 20000 and 30000, and 54440 falls between 50000 and 60000 the output file would look like this:
rs 23353 E235 20000 30000
rs234 54440 E255 50000 60000
并且 rs100 将被删除(从输出文件中),因为它不在文件 2 中任何行的范围内.
and rs100 would be removed (from the output file) because it does not fall within a range of any row in file 2.
有什么建议吗?
谢谢!
推荐答案
更新:这个问题比这里指出的要复杂.可以在此处找到解决方案:R 中按范围合并 - 应用循环,并使用 Bioconductor 中的 GenomicRanges
包交付.非常有用的包!
UPDATE: This question was more complicated than indicated here. The solution can be found here: Merge by Range in R - Applying Loops, and is delivered by using the GenomicRanges
package in Bioconductor. Very useful package!
这篇关于R中的匹配范围合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!