def fit_cluster(data, assignments, k, P_init, R_init, means):
for c in range(k):<EOL><INDENT>if data[:,assignments==c].shape[<NUM_LIT:1>] == <NUM_LIT:0>:<EOL><INDENT>_, assignments = kmeans_pp(data, k)<EOL><DEDENT><DEDENT>genes, cells = data.shape<EOL>nb_gene_indices = np.array([True for i in range(genes)])<EOL>for c in range(k):<EOL><INDENT>c_data = data[:,assignments==c]<EOL>nb_gene_indices = nb_gene_indices & find_nb_genes(c_data)<EOL><DEDENT>for c in range(k):<EOL><INDENT>c_data = data[:,assignments==c]<EOL>nb_genes = c_data[nb_gene_indices,:]<EOL>poisson_genes = c_data[~nb_gene_indices, :]<EOL>P_init[nb_gene_indices, c], R_init[nb_gene_indices, c] = nb_fit(nb_genes)<EOL>means[~nb_gene_indices, c] = poisson_genes.mean(<NUM_LIT:1>)<EOL><DEDENT>return nb_gene_indices<EOL>
Fits NB/poisson params to a cluster.