xmotifs.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:biclustlib 作者: padilha 项目源码 文件源码
def _find_motif(self, data, row_indices):
        """Finds the largest xMOTIF (this is the direct implementation of the
        pseucode of the FindMotif() procedure described in the original paper).
        """
        num_rows, num_cols = data.shape
        best_motif = Bicluster([], [])
        seeds = np.random.choice(num_cols, self.num_seeds, replace=False)

        for s in seeds:
            seed_col = data[row_indices, s][:, np.newaxis]

            for i in range(self.num_sets):
                cols_set = np.random.choice(num_cols, self.set_size, replace=False)

                rows_comp_data = seed_col == data[np.ix_(row_indices, cols_set)]
                selected_rows = np.array([y for x, y in enumerate(row_indices) if np.all(rows_comp_data[x])], np.int)

                seed_values = data[selected_rows, s][:, np.newaxis]
                cols_comp_data = seed_values == data[selected_rows]
                selected_cols = np.array([k for k in range(num_cols) if np.all(cols_comp_data[:, k])])

                if len(selected_cols) >= self.alpha * num_cols and len(selected_rows) > len(best_motif.rows):
                    best_motif = Bicluster(selected_rows, selected_cols)

        return best_motif
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号