[英]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.