neighbors module¶
- velotest.neighbors.cos_directionality(expression, velocity_position, expressions_neighbours)¶
Calculates the cosine similarity between the velocity of a cell and multiple cells in the neighborhood of the cell. Currently used for 2D velocity vectors.
- Parameters:
expression – position of the cell
velocity_position – position (x+v) of the tip of the velocity vector
expressions_neighbours – expressions of the neighbors
- Returns:
- velotest.neighbors.cos_directionality_batched(expression, velocity_position, expressions_neighbours)¶
Calculates the cosine similarity between the velocity of a cell and multiple cells in the neighborhood of the cell. Currently used for 2D velocity vectors.
- Parameters:
expression – position of the cell
velocity_position – position (x+v) of the tip of the velocity vector
expressions_neighbours – expressions of the neighbors
- Returns:
- velotest.neighbors.find_neighbors(x, k_neighbors=5, metric='euclidean')¶
Finds the k nearest neighbors of each cell in the expression matrix.
- Parameters:
x – expression matrix
k_neighbors – number of neighbors
metric – metric to use to calculate distances
- Returns:
an array of indices of the k nearest neighbors for each cell (#cells, k_neighbors)
- velotest.neighbors.find_neighbors_in_direction_of_velocity(Z_expr, Z_velo_position, nn_indices, threshold_degree=22.5) list¶
Finds the neighbors of each cell in 2D that are in a 2*threshold_degree cone around the velocity vector.
- Parameters:
Z_expr – 2D embedding of positions
Z_velo_position – 2D embedding of tip of velocity vectors
nn_indices – indices of the k nearest neighbors for each cell
threshold_degree – angle in degrees to define the cone around the velocity vector, e.g. specify 22.5° for a cone of 45°
- Returns:
return list of neighbours in direction of velocity for each cell
- velotest.neighbors.find_neighbors_in_direction_of_velocity_multiple(Z_expr, Z_velo_position, nn_indices, threshold_degree=22.5) list¶
- velotest.neighbors.select_neighbors_based_on_cos(Z_expr, Z_velo_position, nn_indices, threshold_degree)¶
- velotest.neighbors.select_neighbors_based_on_cos_batched(Z_expr, Z_velo_position, nn_indices, threshold_degree)¶