Utils Module
natural_chr_sort
Section titled “natural_chr_sort”def natural_chr_sort(a, b)timer_func
Section titled “timer_func”def timer_func(func)read_chromosome_from_bw
Section titled “read_chromosome_from_bw”def read_chromosome_from_bw(file, chrom)find_path
Section titled “find_path”def find_path(hierarchy: Dict[str, Dict], path: List[str], cell_type: str) -> Optional[List[str]]Find the path from the root to a given cell type in a hierarchy.
Args: hierarchy: A dictionary representing the hierarchy. path: The current path. cell_type: The cell type to find.
Returns: The path from the root to the cell type (a list of strings or None).
find_lca
Section titled “find_lca”def find_lca(path1: List[str], path2: List[str]) -> intFind the lowest common ancestor (LCA) of two paths.
Args: path1: The first path. path2: The second path.
Returns: int: The index of the lowest common ancestor in the paths.
compute_cell_hierarchy_distance
Section titled “compute_cell_hierarchy_distance”def compute_cell_hierarchy_distance(hierarchy: Dict[str, Dict], cell1: str, cell2: str) -> Optional[int]Compute the distance between two cell types in a hierarchy.
The distance is the number of edges between the two cells in the hierarchy.
Args: hierarchy: A dictionary representing the hierarchy. cell1: The first cell type. cell2: The second cell type.
Returns: The distance between the two cell types (an integer or None).