def test_numpy_dense_matrix(self): m, g, t = _prepare_input(expression_data=df.to_numpy(), gene_names=list(df.columns), tf_names=tfs) self.assertTrue(isinstance(m, np.ndarray)) self.assertEquals((500, 50), m.shape) self.assertEquals(50, len(g)) self.assertEquals(4, len(t))
def test_DataFrame(self): m, g, t = _prepare_input(expression_data=df, gene_names=None, tf_names=tfs) self.assertTrue(isinstance(m, np.ndarray)) self.assertEquals((500, 50), m.shape) self.assertEquals(50, len(g)) self.assertEquals(4, len(t))
def test_scipy_csc_matrix(self): csc = csc_matrix(df.to_numpy()) m, g, t = _prepare_input(expression_data=csc, gene_names=list(df.columns), tf_names=tfs) self.assertTrue(isinstance(m, csc_matrix)) self.assertEquals((500, 50), m.shape) self.assertEquals(50, len(g)) self.assertEquals(4, len(t))
#cells = ds.ca[args.cell_id_attribute] else: ex_matrix = pd.DataFrame(data=ds[:, :], index=ds.ra[args.gene_attribute], columns=ds.ca[args.cell_id_attribute]).T gene_names = pd.Series(ds.ra[args.gene_attribute]) end_time = time.time() print( f'Loaded expression matrix of {ex_matrix.shape[0]} cells and {ex_matrix.shape[1]} genes in {end_time - start_time} seconds...', file=sys.stderr) tf_names = load_tf_names(args.tfs_fname.name) print(f'Loaded {len(tf_names)} TFs...', file=sys.stderr) ex_matrix, gene_names, tf_names = _prepare_input(ex_matrix, gene_names, tf_names) tf_matrix, tf_matrix_gene_names = to_tf_matrix(ex_matrix, gene_names, tf_names) print(f'starting {args.method} using {args.num_workers} processes...', file=sys.stderr) start_time = time.time() with Pool(args.num_workers) as p: adjs = list( tqdm.tqdm(p.imap(run_infer_partial_network, target_gene_indices(gene_names, target_genes='all'), chunksize=1), total=len(gene_names)))