def corr_bin_genes(self, number_of_features=None, input_gene=None):
weights = self.adata.var['<STR_LIT>'].values<EOL>all_gene_names = np.array(list(self.adata.var_names))<EOL>D_avg = self.adata.layers['<STR_LIT>']<EOL>idx2 = np.argsort(-weights)[:weights[weights > <NUM_LIT:0>].size]<EOL>if(number_of_features is None or number_of_features > idx2.size):<EOL><INDENT>number_of_features = idx2.size<EOL><DEDENT>if number_of_features > <NUM_LIT:1000>:<EOL><INDENT>number_of_features = <NUM_LIT:1000><EOL><DEDENT>if(input_gene is not None):<EOL><INDENT>input_gene = np.where(all_gene_names == input_gene)[<NUM_LIT:0>]<EOL>if(input_gene.size == <NUM_LIT:0>):<EOL><INDENT>print(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL>return<EOL><DEDENT>seeds = [np.array([input_gene])]<EOL>pw_corr = np.corrcoef(<EOL>D_avg[:, idx2[:number_of_features]].T.toarray())<EOL>for i in range(<NUM_LIT:1>, number_of_features):<EOL><INDENT>flag = False<EOL>maxd = np.mean(pw_corr[i, :][pw_corr[i, :] > <NUM_LIT:0>])<EOL>maxi = <NUM_LIT:0><EOL>for j in range(len(seeds)):<EOL><INDENT>if(pw_corr[np.where(idx2 == seeds[j][<NUM_LIT:0>])[<NUM_LIT:0>], i]<EOL>> maxd):<EOL><INDENT>maxd = pw_corr[np.where(idx2 == seeds[j][<NUM_LIT:0>])[<NUM_LIT:0>], i]<EOL>maxi = j<EOL>flag = True<EOL><DEDENT><DEDENT>if(not flag):<EOL><INDENT>seeds.append(np.array([idx2[i]]))<EOL><DEDENT>else:<EOL><INDENT>seeds[maxi] = np.append(seeds[maxi], idx2[i])<EOL><DEDENT><DEDENT>geneID_groups = []<EOL>for i in range(len(seeds)):<EOL><INDENT>geneID_groups.append(all_gene_names[seeds[i]])<EOL><DEDENT>return geneID_groups[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>seeds = [np.array([idx2[<NUM_LIT:0>]])]<EOL>pw_corr = np.corrcoef(<EOL>D_avg[:, idx2[:number_of_features]].T.toarray())<EOL>for i in range(<NUM_LIT:1>, number_of_features):<EOL><INDENT>flag = False<EOL>maxd = np.mean(pw_corr[i, :][pw_corr[i, :] > <NUM_LIT:0>])<EOL>maxi = <NUM_LIT:0><EOL>for j in range(len(seeds)):<EOL><INDENT>if(pw_corr[np.where(idx2 == seeds[j][<NUM_LIT:0>])[<NUM_LIT:0>], i]<EOL>> maxd):<EOL><INDENT>maxd = pw_corr[np.where(idx2 == seeds[j][<NUM_LIT:0>])[<NUM_LIT:0>], i]<EOL>maxi = j<EOL>flag = True<EOL><DEDENT><DEDENT>if(not flag):<EOL><INDENT>seeds.append(np.array([idx2[i]]))<EOL><DEDENT>else:<EOL><INDENT>seeds[maxi] = np.append(seeds[maxi], idx2[i])<EOL><DEDENT><DEDENT>geneID_groups = []<EOL>for i in range(len(seeds)):<EOL><INDENT>geneID_groups.append(<EOL>all_gene_names[seeds[i]])<EOL><DEDENT>self.adata.uns['<STR_LIT>'] = geneID_groups<EOL>return geneID_groups<EOL><DEDENT>
A (hacky) method for binning groups of genes correlated along the
        SAM manifold.

        Parameters
        ----------
        number_of_features - int, optional, default None
            The number of genes to bin. Capped at 5000 due to memory
            considerations.

        input_gene - str, optional, default None
            If not None, use this gene as the first seed when growing the
            correlation bins.