TOP 統計学 獣医学 IT 生命工学 バイオインフォマティクス ケモインフォマティクス 機械学習 数学(統計以外) 趣味 ブログについて

元論文

作成日:2024年4月9日

CellOracleについて

マルコフ連鎖の実装

            
            def prepare_markov_simulation(self, verbose=False):
                """
                Pick up cells for Markov simulation.
            
                    Args:
                        verbose (bool): If True, it plots selected cells.
            
                """
                # Sample uniformly the points to avoid density driven effects - Should reimplement as a method
                steps = 100, 100
                g rs = []
                for dim_i in range(self.embedding.shape[1]):
                    m, M = np.min(self.embedding[:, dim_i]), np.max(self.embedding[:, dim_i])
                    m = m - 0.025 * np.abs(M - m)
                    M = M + 0.025 * np.abs(M - m)
                    gr = np.linspace(m, M, steps[dim_i])
                    grs.append(gr)
            
                    meshes_tuple = np.meshgrid(*grs)
                    gridpoints_coordinates = np.vstack([i.flat for i in meshes_tuple]).T
            
                    nn = NearestNeighbors()
                    nn.fit(self.embedding)
                    dist, ixs = nn.kneighbors(gridpoints_coordinates, 1)
            
                    diag_step_dist = np.sqrt((meshes_tuple[0][0,0] - meshes_tuple[0][0,1])**2 + (meshes_tuple[1][0,0] - meshes_tuple[1][1,0])**2)
                    min_dist = diag_step_dist / 2
                    ixs = ixs[dist < min_dist]
                    gridpoints_coordinates = gridpoints_coordinates[dist.flat[:]