def select_genes(embedding):
if not ( isinstance( embedding, np.ndarray)):<EOL><INDENT>raise TypeError( '<STR_LIT>')<EOL><DEDENT>print ("<STR_LIT>")<EOL>start=time.time() <EOL>k = min_conn_k(embedding) <EOL>print (k, "<STR_LIT>") <EOL>print ("<STR_LIT>")<EOL>r = embedding.shape[<NUM_LIT:0>]<EOL>c = embedding.shape[<NUM_LIT:1>]<EOL>print ("<STR_LIT>")<EOL>traj_dist = sps.distance.squareform(sps.distance.pdist(embedding)) <EOL>print ("<STR_LIT>")<EOL>print ("<STR_LIT>")<EOL>adj_mat = adaptive_knn_graph(traj_dist,k) <EOL>print ("<STR_LIT>")<EOL>sel_vals = selection_val(embedding,adj_mat) <EOL>print ("<STR_LIT>") <EOL>genes = np.where(sel_vals > <NUM_LIT:1>) <EOL>print ("<STR_LIT>",time.time()-start, "<STR_LIT>") <EOL>print ("<STR_LIT>")<EOL>return np.squeeze( genes)<EOL>
Wrapper function to perform neighborhood variance based feature selection, will throw error if input is not ndarray
:param embedding: ndarray representing gene expression, consists of cells as rows and genes as columns
:return genes_mat: ndarray of selected genes