Example #1
0
    def gene_specificity(self, gene, log=True):
        gene_i = self.name_or_index(gene)

        if gene_i == None:
            spec = 0
        else:
            gexpr = self.expr[gene_i,:]
            if log:
                gexpr = [math.log(e+1) for e in gexpr]

            if sum(gexpr) == 0:
                spec = 0
            else:
                gexpr = stats.normalize(gexpr)

                min_jsd = 1.0
                for j in range(len(self.experiments)):
                    q_j = [0]*len(self.experiments)
                    q_j[j] = 1.0

                    min_jsd = min(min_jsd, math.sqrt(stats.jsd(gexpr, q_j)))

                spec = 1.0 - min_jsd

        return spec
Example #2
0
    def gene_specificity(self, gene, log=True):
        gene_i = self.name_or_index(gene)

        if gene_i == None:
            spec = 0
        else:
            gexpr = self.expr[gene_i, :]
            if log:
                gexpr = [math.log(e + 1) for e in gexpr]

            if sum(gexpr) == 0:
                spec = 0
            else:
                gexpr = stats.normalize(gexpr)

                min_jsd = 1.0
                for j in range(len(self.experiments)):
                    q_j = [0] * len(self.experiments)
                    q_j[j] = 1.0

                    min_jsd = min(min_jsd, math.sqrt(stats.jsd(gexpr, q_j)))

                spec = 1.0 - min_jsd

        return spec
Example #3
0
    def genes_jsd(self, gene1, gene2, log=True):
        gene1_i = self.name_or_index(gene1)
        gene2_i = self.name_or_index(gene2)

        gexpr1 = self.expr[gene1_i,:]
        if log:
            gexpr1 = [math.log(e+1) for e in gexpr1]
        gexpr1 = stats.normalize(gexpr1)

        gexpr2 = self.expr[gene2_i,:]
        if log:
            gexpr2 = [math.log(e+1) for e in gexpr2]
        gexpr2 = stats.normalize(gexpr2)

        return stats.jsd(gexpr1, gexpr2)
Example #4
0
    def genes_jsd(self, gene1, gene2, log=True):
        gene1_i = self.name_or_index(gene1)
        gene2_i = self.name_or_index(gene2)

        gexpr1 = self.expr[gene1_i, :]
        if log:
            gexpr1 = [math.log(e + 1) for e in gexpr1]
        gexpr1 = stats.normalize(gexpr1)

        gexpr2 = self.expr[gene2_i, :]
        if log:
            gexpr2 = [math.log(e + 1) for e in gexpr2]
        gexpr2 = stats.normalize(gexpr2)

        return stats.jsd(gexpr1, gexpr2)