7 Piping PyRanges
The PyRanges API supports chaining operations out of the box.
To set a new column in a PyRanges you would use the assign
method and for subsetting you would use the subset
method.
import pyranges as pr
import pandas as pd
= pr.data.exons()
exons = pr.data.cpg()
cpg lambda df: df.CpG > 25)[["CpG"]].assign("CpGDecile", lambda df: df.CpG % 10)["chrX"].slack(500) cpg.join(exons.unstrand()).subset(