def _create_w_objective(m, X):
genes, clusters = m.shape<EOL>cells = X.shape[<NUM_LIT:1>]<EOL>m_sum = m.sum(<NUM_LIT:0>)<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>temp = X/d<EOL>m2 = m.T.dot(temp)<EOL>deriv = m_sum.reshape((clusters, <NUM_LIT:1>)) - m2<EOL>return np.sum(d - X*np.log(d))/genes, deriv.flatten()/genes<EOL><DEDENT>return objective<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