标签:saveas head 知识 bedtool pybedtools len filter 琐碎
一个坑:pybedtools 使用和不用saveas 会导致结果不同,有时saveas 或 count 就会清空数据。
It looks like filter function doesn't return a BedTool object ready to use.
a = pybedtools.example_bedtool('a.bed')
b = a.filter(lambda x: len(x) > 100)
b.head()
NotImplementedError Traceback (most recent call last)
<ipython-input-66-154f9c28629d> in <module>()
1 a = pybedtools.example_bedtool('a.bed')
2 b = a.filter(lambda x: len(x) > 100)
----> 3 b.head()
NotImplementedError: head() not supported for non file-based BedTools
|
You need to save the generator-based b first:
a = pybedtools.example_bedtool('a.bed')
b = a.filter(lambda x: len(x) > 100)
b = b.saveas()
b.head()
Otherwise head() would consume the first 10 lines; I'm choosing to prevent this by raising the NotImplementedError. |
标签:saveas,
head,
知识,
bedtool,
pybedtools,
len,
filter,
琐碎
From: https://blog.51cto.com/emanlee/7750863