def generate_nb_data(P, R, n_cells, assignments=None):
genes, clusters = P.shape<EOL>output = np.zeros((genes, n_cells))<EOL>if assignments is None:<EOL><INDENT>cluster_probs = np.ones(clusters)/clusters<EOL><DEDENT>labels = []<EOL>for i in range(n_cells):<EOL><INDENT>if assignments is None:<EOL><INDENT>c = np.random.choice(range(clusters), p=cluster_probs)<EOL><DEDENT>else:<EOL><INDENT>c = assignments[i]<EOL><DEDENT>labels.append(c)<EOL>output[:,i] = np.random.negative_binomial(R[:,c], <NUM_LIT:1.0>-P[:,c])<EOL><DEDENT>return output, np.array(labels)<EOL>
Generates negative binomial data

Args:
    P (array): genes x clusters
    R (array): genes x clusters
    n_cells (int): number of cells
    assignments (list): cluster assignment of each cell. Default:
        random uniform

Returns:
    data array with shape genes x cells
    labels - array of cluster labels