hypothesis_testing module¶
- velotest.hypothesis_testing.correct_for_multiple_testing(pvals, correction)¶
- velotest.hypothesis_testing.p_values(test_statistics_velocity, test_statistics_random)¶
Compute p-values using the test statistics from the permutations.
- Parameters:
test_statistics_velocity – (#cells)
test_statistics_random – (#cells, #neighborhoods)
- Returns:
- velotest.hypothesis_testing.p_values_list(test_statistics_velocity, test_statistics_random)¶
- velotest.hypothesis_testing.run_hypothesis_test(X_expr, X_velo_vector, Z_expr, Z_velo_position, number_neighborhoods=500, number_neighbors_to_sample_from=300, threshold_degree=22.5, exclusion_degree: float | None = 10, null_distribution='velocities-explicit', correction='bonferroni', alpha=0.05, cosine_empty_neighborhood=None, seed=0, parallelization=True)¶
Samples random neighborhoods for every cell and uses the high-dimensional cosine similarity between the velocity of each cell and the cells in the direction of the velocity (in 2D) as test statistic.
- Parameters:
X_expr – high-dimensional expressions
X_velo_vector – high-dimensional velocity vector, not position (x+v)
Z_expr – embedding for expressions
Z_velo_position – embedding for velocity position (x+v)
number_neighborhoods – number of neighborhoods used to define null distribution
number_neighbors_to_sample_from – number of neighbors to sample neighborhoods from and to look for neighbors in direction of velocity
threshold_degree – angle in degrees to define the cone around the velocity vector (angle of cone is 2*threshold_degree),
exclusion_degree – angle in degrees to exclude random velocities which are too similar to the visualized velocity. ‘None’ uses all random velocities.
null_distribution – ‘neighbors’ or ‘velocities’. If ‘neighbors’, the neighborhoods are uniformly sampled from the neighbors. If ‘velocities’, random velocities are sampled and then the neighborhoods are defined by the neighbors in this direction.
correction – correction method for multiple testing. ‘benjamini–hochberg’, ‘bonferroni’ or None
alpha – significance level used for Benjamini-Hochberg or Bonferroni correction.
cosine_empty_neighborhood – See mean_cos_directionality_varying_neighbors.
seed – Random seed for reproducibility.
parallelization – If True, use multiple cores for parallelization.
- Returns:
p_values_(p-values from test (not corrected), cells where test couldn’t be run are assigned a value of 2),h0_rejected(boolean array indicating whether null hypothesis was rejected after correction),debug_dict(dictionary containing additional information and byproducts of the test)
- velotest.hypothesis_testing.run_hypothesis_test_on(adata, ekey='Ms', vkey='velocity', basis='umap', restrict_to_velocity_genes=True, **kwargs)¶
Runs the hypothesis test using high dimensional expressions, high dimensional velocity, and the embeddings from an adata object. For details, see run_hypothesis_test.
- Parameters:
adata – Anndata object containing high dimensional data and embeddings.
ekey – Name of layer in adata object containing high dimensional expression data.
vkey – Name of layer in adata object containing high dimensional velocity data.
basis – Name of embedding.
restrict_to_velocity_genes – Only use velocity genes determined by the velocity estimation method for any high-dimensional computations, specifically cosine similarity.
kwargs – Additional arguments for run_hypothesis_test.
- Returns:
See run_hypothesis_test.