.hic API

class hictkpy.hic.FileWriter(*args, **kwargs)

Class representing a file handle to create .hic files.

__init__(
self,
path: str | PathLike,
chromosomes: dict[str, int],
resolution: int,
assembly: str = 'unknown',
n_threads: int = 1,
chunk_size: int = 10000000,
tmpdir: str | PathLike = PosixPath('/tmp'),
compression_lvl: int = 10,
skip_all_vs_all_matrix: bool = False,
) None
__init__(
self,
path: str | PathLike,
chromosomes: dict[str, int],
resolutions: Sequence[int],
assembly: str = 'unknown',
n_threads: int = 1,
chunk_size: int = 10000000,
tmpdir: str | PathLike = PosixPath('/tmp'),
compression_lvl: int = 10,
skip_all_vs_all_matrix: bool = False,
) None
__init__(
self,
path: str | PathLike,
bins: BinTable,
assembly: str = 'unknown',
n_threads: int = 1,
chunk_size: int = 10000000,
tmpdir: str | PathLike = PosixPath('/tmp'),
compression_lvl: int = 10,
skip_all_vs_all_matrix: bool = False,
) None

Overloaded function.

  1. __init__(self, path: str | os.PathLike, chromosomes: dict[str, int], resolution: int, assembly: str = 'unknown', n_threads: int = 1, chunk_size: int = 10000000, tmpdir: str | os.PathLike = PosixPath('/tmp'), compression_lvl: int = 10, skip_all_vs_all_matrix: bool = False) -> None

Open a .hic file for writing given a list of chromosomes with their sizes and one resolution.

  1. __init__(self, path: str | os.PathLike, chromosomes: dict[str, int], resolutions: collections.abc.Sequence[int], assembly: str = 'unknown', n_threads: int = 1, chunk_size: int = 10000000, tmpdir: str | os.PathLike = PosixPath('/tmp'), compression_lvl: int = 10, skip_all_vs_all_matrix: bool = False) -> None

Open a .hic file for writing given a list of chromosomes with their sizes and one or more resolutions.

  1. __init__(self, path: str | os.PathLike, bins: hictkpy._hictkpy.BinTable, assembly: str = 'unknown', n_threads: int = 1, chunk_size: int = 10000000, tmpdir: str | os.PathLike = PosixPath('/tmp'), compression_lvl: int = 10, skip_all_vs_all_matrix: bool = False) -> None

Open a .hic file for writing given a BinTable. Only BinTable with a fixed bin size are supported.

__enter__(self) FileWriter
__exit__(
self,
exc_type: object | None = None,
exc_value: object | None = None,
traceback: object | None = None,
) None
add_pixels(
self,
pixels: DataFrame | Table,
validate: bool = True,
) 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 .hic file.

add_pixels_from_dict(
self,
columns: Dict[str, Iterable[str | int | float]],
validate: bool = True,
) 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.

bins(self, resolution: int) BinTable

Get table of bins for the given resolution.

chromosomes(self, include_ALL: bool = False) dict[str, int]

Get the chromosome sizes as a dictionary mapping names to sizes.

finalize(self, log_lvl: str | None = None) File

Write interactions to file.

path(self) Path

Get the file path.

resolutions(self) numpy.ndarray[dtype=int64, shape=(*), order='C']

Get the list of resolutions in bp.