Exemplo n.º 1
0
    def test_copy_palantir_kernel(self, adata: AnnData):
        pk1 = PalantirKernel(adata).compute_transition_matrix()
        pk2 = pk1.copy()

        np.testing.assert_array_equal(pk1.transition_matrix.A,
                                      pk2.transition_matrix.A)
        assert pk1.params == pk2.params
        assert pk1.backward == pk2.backward
Exemplo n.º 2
0
    def test_not_none_transition_matrix_accessor(self, adata: AnnData):
        vk = VelocityKernel(adata)
        ck = ConnectivityKernel(adata)
        pk = PalantirKernel(adata, time_key="latent_time")

        assert vk.transition_matrix is not None
        assert ck.transition_matrix is not None
        assert pk.transition_matrix is not None
Exemplo n.º 3
0
    def test_palantir_inverse(self, adata: AnnData):
        pk = PalantirKernel(adata, time_key="latent_time")
        pt = pk.pseudotime.copy()

        pk_inv = ~pk

        assert pk_inv is pk
        assert pk_inv.backward
        np.testing.assert_allclose(pt, 1 - pk_inv.pseudotime)
Exemplo n.º 4
0
    def test_not_none_transition_matrix_compute(self, adata: AnnData):
        vk = VelocityKernel(adata).compute_transition_matrix(softmax_scale=4)
        ck = ConnectivityKernel(adata).compute_transition_matrix()
        pk = PalantirKernel(
            adata, time_key="latent_time").compute_transition_matrix()

        assert vk.transition_matrix is not None
        assert ck.transition_matrix is not None
        assert pk.transition_matrix is not None
Exemplo n.º 5
0
    def test_palantir(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 = _normalize(conn_biased)

        pk = PalantirKernel(adata,
                            time_key="latent_time").compute_transition_matrix(
                                density_normalize=False)
        T_2 = pk.transition_matrix

        np.testing.assert_allclose(T_1.A, T_2.A, rtol=_rtol)