SparseAPCluster.py 文件源码

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

项目:pysapc 作者: bioinfocao 项目源码 文件源码
def denseToSparseAbvCutoff(self, denseMatrix, cutoff):
        """
        Remove datas in denseMatrix that is below cutoff, Convert the remaining datas into sparse matrix.
        Parameters:
        ----------------------
        denseMatrix: dense numpy matrix

        cutoff: int or float

        Returns
        ----------------------
        Scipy csr_matrix

        """
        maskArray=denseMatrix>=cutoff
        sparseMatrix=csr_matrix( (np.asarray(denseMatrix[maskArray]).reshape(-1),np.nonzero(maskArray)),\
                    shape=denseMatrix.shape)
        return sparseMatrix
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号