Пример #1
0
    def coexpression(self,gene_a,gene_b):
        ''' 
            Returns a coexpression z-score between two genes. This
            is the pearson correlation coefficient of the two genes'
            expression profiles across the accessions (experiments).
            This value is pulled from the 

            Parameters
            ----------
            gene_a : camoco.Locus
                The first gene
            gene_b : camoco.Locus
                The second gene
        
            Returns
            -------
            Coexpression Z-Score 

        '''
        # Grab the indices in the original expression matrix
        ids = np.array([self._expr_index[gene_a.id],self._expr_index[gene_b.id]])
        # We need the number of genes
        num_genes = self.num_genes()
        index = PCCUP.coex_index(ids,num_genes)[0]
        return self.coex.iloc[index]
Пример #2
0
 def subnetwork(self,gene_list=None,sig_only=True,min_distance=100000,
     filter_missing_gene_ids=True):
     '''
         Input: a gene list (passing None gives you all genes)
         Output: a dataframe containing all edges EXCLUSIVELY between genes
             within list
     '''
     if gene_list is None:
         df = self.coex
     else:
         ids = np.array([self._expr_index[x.id] for x in gene_list])
         if filter_missing_gene_ids:
             # filter out the Nones 
             ids = np.array(list(filter(None,ids)))
         num_genes = self.num_genes()
         # Grab the coexpression indices for the genes
         indices = PCCUP.coex_index(ids,num_genes)
         df = self.coex.iloc[indices]
     if min_distance:
         df = df.loc[df.distance >= min_distance,:]
     if sig_only:
         df = df.loc[df.significant == 1,:]
     return df.copy()