def preproc_data(data, gene_subset=False, **kwargs):
import uncurl<EOL>from uncurl.preprocessing import log1p, cell_normalize<EOL>from sklearn.decomposition import TruncatedSVD<EOL>data_subset = data<EOL>if gene_subset:<EOL><INDENT>gene_subset = uncurl.max_variance_genes(data)<EOL>data_subset = data[gene_subset, :]<EOL><DEDENT>tsvd = TruncatedSVD(min(<NUM_LIT:8>, data_subset.shape[<NUM_LIT:0>] - <NUM_LIT:1>))<EOL>data_tsvd = tsvd.fit_transform(log1p(cell_normalize(data_subset)).T)<EOL>return data_tsvd<EOL>
basic data preprocessing before running gap score

Assumes that data is a matrix of shape (genes, cells).

Returns a matrix of shape (cells, 8), using the first 8 SVD
components. Why 8? It's an arbitrary selection...