def _create_m_objective(w, X, R):
clusters, cells = w.shape<EOL>genes = X.shape[<NUM_LIT:0>]<EOL>R1 = R.reshape((genes, <NUM_LIT:1>)).dot(np.ones((<NUM_LIT:1>, cells)))<EOL>def objective(m):<EOL><INDENT>m = m.reshape((X.shape[<NUM_LIT:0>], w.shape[<NUM_LIT:0>]))<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(m):<EOL><INDENT>m2 = m.reshape((X.shape[<NUM_LIT:0>], w.shape[<NUM_LIT:0>]))<EOL>d = m2.dot(w)+eps<EOL>temp = X/d<EOL>temp2 = (X+R1)/(d+R1)<EOL>w1 = w.dot(temp2.T)<EOL>w2 = w.dot(temp.T)<EOL>deriv = w1.T - w2.T<EOL>return deriv.flatten()/genes<EOL><DEDENT>return objective, deriv<EOL>
Creates an objective function and its derivative for M, given W and X

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