def cell_normalize(data):
if sparse.issparse(data):<EOL><INDENT>data = sparse.csc_matrix(data.astype(float))<EOL>sparse_cell_normalize(data.data,<EOL>data.indices,<EOL>data.indptr,<EOL>data.shape[<NUM_LIT:1>],<EOL>data.shape[<NUM_LIT:0>])<EOL>return data<EOL><DEDENT>data_norm = data.astype(float)<EOL>total_umis = []<EOL>for i in range(data.shape[<NUM_LIT:1>]):<EOL><INDENT>di = data_norm[:,i]<EOL>total_umis.append(di.sum())<EOL>di /= total_umis[i]<EOL><DEDENT>med = np.median(total_umis)<EOL>data_norm *= med<EOL>return data_norm<EOL>
Returns the data where the expression is normalized so that the total
count per cell is equal.