Cooler API¶
- class hictkpy.cooler.SingleCellFile(*args, **kwargs)¶
Class representing a file handle to a .scool file.
- __getitem__(self, cell_id: str) File¶
Open the Cooler file corresponding to the cell ID given as input.
- __enter__(self) SingleCellFile¶
- __exit__(
- self,
- exc_type: object | None = None,
- exc_value: object | None = None,
- traceback: object | None = None,
- class hictkpy.cooler.FileWriter(*args, **kwargs)¶
Class representing a file handle to create .cool files.
- __init__(
- self,
- path: str | PathLike,
- chromosomes: dict[str, int],
- resolution: int,
- assembly: str = 'unknown',
- tmpdir: str | PathLike = PosixPath('/tmp'),
- compression_lvl: int = 6,
- __init__(
- self,
- path: str | PathLike,
- bins: BinTable,
- assembly: str = 'unknown',
- tmpdir: str | PathLike = PosixPath('/tmp'),
- compression_lvl: int = 6,
Overloaded function.
__init__(self, path: str | os.PathLike, chromosomes: dict[str, int], resolution: int, assembly: str = 'unknown', tmpdir: str | os.PathLike = PosixPath('/tmp'), compression_lvl: int = 6) -> None
Open a .cool file for writing given a list of chromosomes with their sizes and a resolution.
__init__(self, path: str | os.PathLike, bins: hictkpy._hictkpy.BinTable, assembly: str = 'unknown', tmpdir: str | os.PathLike = PosixPath('/tmp'), compression_lvl: int = 6) -> None
Open a .cool file for writing given a table of bins.
- __enter__(self) FileWriter¶
- __exit__(
- self,
- exc_type: object | None = None,
- exc_value: object | None = None,
- traceback: object | None = None,
- add_pixels( ) None¶
Add pixels from a pandas.DataFrame or pyarrow.Table containing pixels in COO or BG2 format (i.e. either with columns=[bin1_id, bin2_id, count] or with columns=[chrom1, start1, end1, chrom2, start2, end2, count]). When sorted is True, pixels are assumed to be sorted by their genomic coordinates in ascending order. When validate is True, hictkpy will perform some basic sanity checks on the given pixels before adding them to the Cooler file.
- add_pixels_from_dict( ) None¶
Add pixels from a dictionary containing containing columns corresponding to pixels in COO or BG2 format (i.e. either with keys=[bin1_id, bin2_id, count] or with keys=[chrom1, start1, end1, chrom2, start2, end2, count]). When sorted is True, pixels are assumed to be sorted by their genomic coordinates in ascending order. When validate is True, hictkpy will perform some basic sanity checks on the given pixels before adding them to the Cooler file.
- chromosomes(self, include_ALL: bool = False) dict[str, int]¶
Get the chromosome sizes as a dictionary mapping names to sizes.