简体   繁体   English

使用 pyranges 库,如何检查染色体 position 是否包含在任何区间中?

[英]Using pyranges library, How to check if a chromosome position is contained in any interval?

I have a.vcf file containing variants information and a.bed file containing region studied information.我有一个包含变体信息的.vcf 文件和一个包含区域研究信息的.bed 文件。 I am using pyranges library to read the.bed file.我正在使用pyranges库来读取 .bed 文件。 I want to filter out all the variants in.vcf file that lies in the region studied intervals specified in.bed file.我想过滤掉位于.bed 文件中指定的研究区间区域内的所有变体 in.vcf 文件。 Since, pyranges provides a pandas dataframe, i could iterate over each row and check for containment of my variant position;由于 pyranges 提供了 pandas dataframe,我可以遍历每一行并检查我的变体 position 的包含情况; But, I am looking for an API that helps me achieve this.但是,我正在寻找可以帮助我实现这一目标的 API。

Example:例子:

>> df = pd.DataFrame({"Chromosome": ["chr1", "chr2"], "Start": [100, 200],
...                    "End": [150, 201]})
>> pr.PyRanges(df)

+--------------+-----------+-----------+
| Chromosome   |     Start |       End |
| (category)   |   (int32) |   (int32) |
|--------------+-----------+-----------|
| chr1         |       100 |       150 |
| chr2         |       200 |       201 |
+--------------+-----------+-----------+

Is there an API to find if a chromosome position 125 for chromosome "chr1" lies in any of the interval.是否有 API 来查找染色体“chr1”的染色体 position 125 是否位于任何区间内。 In above case it will be True because 125 lies in interval 100 - 150.在上述情况下,它将为 True,因为 125 位于区间 100 - 150 中。

gr = pr.PyRanges(df)
gr['chr1', 125:126]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在执行连接之前将染色体名称转换为 pyranges 中的相同格式 - How to convert chromosome name to same format in pyranges before performing a join 如何检查圆形是否包含在任何矩形中? (在 pygame 中) - How check if a circle is contained by any rectangle? (in pygame) Python:如何使用`numpy.all`和`numpy.any`检查数组是否包含在另一个数组中? - Python: How to check if an array is contained in another array using `numpy.all`and `numpy.any`? 如何检查英语单词中是否包含字符串? - How to check to see if a string is contained in any english word? 如何检查列表python中是否包含任何列表元素 - How to check if any of a list elements is contained in a list python 如何检查列表是否包含在 python 中字典的任何键中? - How to check if a list is contained within any of the keys of a dictionary in python? 检查给定的键是否包含在多个字典中的任何一个中 - Check if a given key is contained in any of multiple dictionaries 检查字符串中的字符是否包含在列表的任何单词中 - Check if the characters in a string are contained in any of the word of a list 如何检查某个数字是否在某个区间内 - How to check if a number is in a interval 如何检查XML中是否包含属性? - How to check if an Attribute is contained in XML?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM