def initialize_means(data, clusters, k):
init_w = np.zeros((data.shape[<NUM_LIT:0>], k))<EOL>if sparse.issparse(data):<EOL><INDENT>for i in range(k):<EOL><INDENT>if data[:,clusters==i].shape[<NUM_LIT:1>]==<NUM_LIT:0>:<EOL><INDENT>point = np.random.randint(<NUM_LIT:0>, data.shape[<NUM_LIT:1>])<EOL>init_w[:,i] = data[:,point].toarray().flatten()<EOL><DEDENT>else:<EOL><INDENT>init_w[:,i] = np.array(data[:,clusters==i].mean(<NUM_LIT:1>)).flatten() + eps<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>for i in range(k):<EOL><INDENT>if data[:,clusters==i].shape[<NUM_LIT:1>]==<NUM_LIT:0>:<EOL><INDENT>point = np.random.randint(<NUM_LIT:0>, data.shape[<NUM_LIT:1>])<EOL>init_w[:,i] = data[:,point].flatten()<EOL><DEDENT>else:<EOL><INDENT>init_w[:,i] = data[:,clusters==i].mean(<NUM_LIT:1>) + eps<EOL><DEDENT><DEDENT><DEDENT>return init_w<EOL>
Initializes the M matrix given the data and a set of cluster labels.
Cluster centers are set to the mean of each cluster.

Args:
    data (array): genes x cells
    clusters (array): 1d array of ints (0...k-1)
    k (int): number of clusters