I/O Module
BedSet
Section titled “BedSet”class BedSet(region_sets: Union[List[RegionSet], List[str], List[List[Region]], None] = None, file_path: str = None, identifier: str = None)BedSet object
Initialize a BedSet object.
Args: region_sets: list of BED file paths, RegionSet, or 2-dimension list of Region. Defaults to None (empty BedSet). file_path (str): path to the .txt file with identifier of all BED files in it identifier (str): the identifier of the BED set
Attributes
Section titled “Attributes”Properties
Section titled “Properties”identifier
Section titled “identifier”@propertydef identifier -> strMethods
Section titled “Methods”def add(bedfile: RegionSet) -> NoReturnAdd a BED file to the BED set.
Warning: if new bedfile will be added, bedSet identifier will be changed!
Args: bedfile (RegionSet): RegionSet instance, that should be added to the bedSet
compute_bedset_identifier
Section titled “compute_bedset_identifier”def compute_bedset_identifier() -> strReturn the identifier. If it is not set, compute one.
Returns: str: the identifier of BED set
RegionSet
Section titled “RegionSet”class RegionSet(regions: Union[str, List[Region]], backed: bool = False)Instantiate a RegionSet object. This can be backed or not backed. It represents a set of genomic regions.
If you specify backed as True, then the bed file will not be loaded into memory. This is useful for large
bed files. You can still iterate over the regions, but you cannot index into them.
Args: regions: path, or url to bed file or list of Region objects backed (bool): whether to load the bed file into memory or not. Defaults to False.
Attributes
Section titled “Attributes”backedregions(List[Region])pathis_gzippedlength
Properties
Section titled “Properties”identifier
Section titled “identifier”@propertydef identifier -> strMethods
Section titled “Methods”to_pandas
Section titled “to_pandas”def to_pandas() -> Union[pd.DataFrame, None]to_granges
Section titled “to_granges”def to_granges()Return GenomicRanges contained in this BED file.
Returns: genomicranges.GenomicRanges: GenomicRanges object
compute_bed_identifier
Section titled “compute_bed_identifier”def compute_bed_identifier() -> strReturn bed file identifier. If it is not set, compute one.
Returns: str: the identifier of BED file
Region
Section titled “Region”class Region(chr: str, start: int, stop: int)Instantiate a Region object.
Args: chr (str): chromosome start (int): start position stop (int): stop position