Skip to content

Utils Module

def natural_chr_sort(a, b)

def timer_func(func)

def read_chromosome_from_bw(file, chrom)

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).

def find_lca(path1: List[str], path2: List[str]) -> int

Find 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.

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).