def _create_w_objective(m, X, R):
genes, clusters = m.shape<EOL>cells = X.shape[<NUM_LIT:1>]<EOL>R1 = R.reshape((genes, <NUM_LIT:1>)).dot(np.ones((<NUM_LIT:1>, cells)))<EOL>def objective(w):<EOL><INDENT>w = w.reshape((m.shape[<NUM_LIT:1>], X.shape[<NUM_LIT:1>]))<EOL>d = m.dot(w)+eps<EOL>return np.sum((X + R1)*np.log(d + R1) - X*np.log(d))/genes<EOL><DEDENT>def deriv(w):<EOL><INDENT>w2 = w.reshape((m.shape[<NUM_LIT:1>], X.shape[<NUM_LIT:1>]))<EOL>d = m.dot(w2)+eps<EOL>temp = X/d<EOL>temp2 = (X+R1)/(d+R1)<EOL>m1 = m.T.dot(temp2)<EOL>m2 = m.T.dot(temp)<EOL>deriv = m1 - m2<EOL>return deriv.flatten()/genes<EOL><DEDENT>return objective, deriv<EOL>
Creates an objective function and its derivative for W, given M and X (data)

Args:
    m (array): genes x clusters
    X (array): genes x cells
    R (array): 1 x genes