def nb_ll(data, P, R):
<EOL>genes, cells = data.shape<EOL>clusters = P.shape[<NUM_LIT:1>]<EOL>lls = np.zeros((cells, clusters))<EOL>for c in range(clusters):<EOL><INDENT>P_c = P[:,c].reshape((genes, <NUM_LIT:1>))<EOL>R_c = R[:,c].reshape((genes, <NUM_LIT:1>))<EOL>ll = gammaln(R_c + data) - gammaln(R_c) <EOL>ll += data*np.log(P_c) + xlog1py(R_c, -P_c)<EOL>lls[:,c] = ll.sum(<NUM_LIT:0>)<EOL><DEDENT>return lls<EOL>
Returns the negative binomial log-likelihood of the data.

Args:
    data (array): genes x cells
    P (array): NB success probability param - genes x clusters
    R (array): NB stopping param - genes x clusters

Returns:
    cells x clusters array of log-likelihoods