test_statistic module¶
- velotest.test_statistic.cos_directionality_one_cell_batch_same_neighbors(expression: Tensor, velocity_vector: Tensor, expressions_neighbours: Tensor)¶
Calculates the cosine similarity between the velocity of a cell and multiple sets of other cells (e.g., in the neighborhood of the cell). Every set is assumed to have same number of neighbors.
- Parameters:
expression – vector of gene expressions of the cell
velocity_vector – velocity vector of the cell, not the position (x+v) of the velocity
expressions_neighbours – (#neighborhoods, #neighbors, #genes)
- Returns:
- velotest.test_statistic.cos_directionality_one_cell_one_neighborhood(expression: Tensor, velocity_vector: Tensor, expressions_neighbours: Tensor)¶
Calculates the cosine similarity between the velocity of a cell and one set of other cells (e.g., in the neighborhood of the cell).
- Parameters:
expression – vector of gene expressions of the cell
velocity_vector – velocity vector of the cell, not the position (x+v) of the velocity
expressions_neighbours – (#neighbors, #genes)
- Returns:
- velotest.test_statistic.mean_cos_directionality_varying_neighborhoods_same_neighbors(expression: Tensor, velocity_vector: Tensor, neighborhoods: list, original_indices_cells)¶
Mean cos directionality for a varying number of neighbors in a neighborhood across cells but with same number of neighbors per cell: Calculates the mean cosine similarity between the velocity of a cell and multiple sets of other cells (e.g., in the neighborhood of the cell). Every set is assumed to have same number of neighbors.
- Parameters:
expression – expression of all cells
velocity_vector – velocity vectors of all cells, not position (x+v) of the velocity
neighborhoods – Neighborhoods of selected cells. list of length #cells with (#neighborhoods, #neighbors).
original_indices_cells – indices of the selected cells in the original expression matrix
- Returns:
- velotest.test_statistic.mean_cos_directionality_varying_neighbors(expression: Tensor, velocity_vector: Tensor, neighborhoods: list, original_indices_cells, cosine_empty_neighborhood: float | None = 2)¶
Mean cos directionality for a varying number of neighbors in the neighborhoods across cells: Calculates the cosine similarity between the velocity of a cell and multiple sets of other cells (e.g., in the neighborhood of the cell). Every set can have a different number of cells.
- Parameters:
expression – expression of all cells
velocity_vector – velocity vectors of all cells, not position (x+v) of the velocity
neighborhoods – Neighborhoods of selected cells. list of length #cells with lists of varying #neighbors.
original_indices_cells – indices of the selected cells in the original expression matrix
cosine_empty_neighborhood – if the neighborhood is empty, assign this value to the mean cosine similarity. Standard is 2 which is higher then the max of the cosine similarity and will therefore lead to more cells where we cannot reject the null hypothesis (Type II error). -2 would lead to Type I errors. “None” will ignore empty neighborhoods and then return a variable number of mean cosine similarities per cell.
- Returns:
- velotest.test_statistic.mean_cos_directionality_varying_neighbors_parallel(expression: Tensor, velocity_vector: Tensor, neighborhoods: List[List[Tensor]], original_indices_cells: ndarray, n_workers: int = None) Tuple[List[Tensor], Tensor]¶
- Returns:
mean_cos_neighborhoods: List[Tensor] per cell, only for non‑empty neighbors
used_mask: (n_cells, n_neigh) bool Tensor marking non‑empty slots
- velotest.test_statistic.mean_cos_directionality_varying_neighbors_torch(expression: Tensor, velocity_vector: Tensor, neighborhoods: List[List[List[int]]], original_indices_cells: List[int], chunk_size: int = 100000) Tuple[List[Tensor], BoolTensor]¶