def test_backward_manual_dense_norm(self, adata): backward = True vk = VelocityKernel(adata, backward=backward).compute_transition_matrix( density_normalize=False) ck = ConnectivityKernel(adata, backward=backward).compute_transition_matrix( density_normalize=False) # combine the kernels comb = 0.8 * vk + 0.2 * ck T_1 = comb.transition_matrix conn = _get_neighs(adata, "connectivities") T_1 = density_normalization(T_1, conn) T_1 = _normalize(T_1) transition_matrix( adata, diff_kernel="sum", weight_diffusion=0.2, density_normalize=True, backward=backward, ) T_2 = adata.uns[_transition(Direction.BACKWARD)]["T"] np.testing.assert_allclose(T_1.A, T_2.A, rtol=_rtol)
def test_palantir_differ_dense_norm(self, adata: AnnData): conn = _get_neighs(adata, "connectivities") n_neighbors = _get_neighs_params(adata)["n_neighbors"] pseudotime = adata.obs["latent_time"] conn_biased = bias_knn(conn, pseudotime, n_neighbors) T_1 = density_normalization(conn_biased, conn) T_1 = _normalize(T_1) pk = PalantirKernel(adata, time_key="latent_time").compute_transition_matrix( density_normalize=False) T_2 = pk.transition_matrix assert not np.allclose(T_1.A, T_2.A, rtol=_rtol)