def test_leng15(): training_data = datasets.leng15(mode='all') if not training_data.shape == (460, 19084): raise AssertionError() training_data = datasets.leng15(mode='sorted') if not training_data.shape == (247, 19084): raise AssertionError() training_data = datasets.leng15(mode='unsorted') if not training_data.shape == (213, 19084): raise AssertionError()
def test_cyclone_train_on_train(): print("") print("") print("## Testing correctness of cyclone()") print("") print("# Testing algorithm on training data") print("") settings.enable_fastmath = True settings.verbosity = 4 training_data = datasets.leng15(mode='sorted') scores = pairs.cyclone(training_data, datasets.default_cc_marker(), iterations=1000, min_iter=10, min_pairs=1) print(scores) test_quality = utils.evaluate_prediction(prediction=scores['max_class'], reference=ref_prediction) print(test_quality) assert np.allclose(np.array(test_quality.values, dtype=float), np.ones(shape=(4, 4)), atol=0.1)
def test_filter_unexpressed_genes(): data = datasets.leng15(mode='sorted', gene_sub=list(range(0, 10)), sample_sub=list(range(0, 10))) filtered, gene_names = utils.filter_unexpressed_genes(data.X, list(data.var_names)) if not filtered.shape == (10, 8): raise AssertionError() if not len(gene_names) == 8: raise AssertionError()
def test_cyclone_speed(): print("") print("") print("## Testing speed of cyclone()") print("") print("# Testing algorithm on minimal data, unjitted and single core") print("") marker = datasets.default_cc_marker() for p, m in marker.items(): marker[p] = m[:500] settings.enable_jit = False settings.n_jobs = 1 utils.benchmark_test(pairs.cyclone, { 'data': datasets.leng15(mode='sorted'), 'marker_pairs': marker }) print("") print("# Testing algorithm on minimal data, jitted and single core") print("") settings.enable_jit = True settings.n_jobs = 1 utils.benchmark_test(pairs.cyclone, { 'data': datasets.leng15(mode='sorted'), 'marker_pairs': marker }) print("") print("# Testing algorithm on minimal data, jitted and multi core") print("") settings.enable_jit = True settings.n_jobs = 4 utils.benchmark_test(pairs.cyclone, { 'data': datasets.leng15(mode='sorted'), 'marker_pairs': marker })
def test_sandbag_inputs(): print("") print("") print("## Testing different input types for sandbag()") settings.n_jobs = 4 settings.verbosity = 4 print("") print("# Testing AnnData obj, including annotation") print("") training_data = datasets.leng15(mode='sorted', gene_sub=list(range(0, 1000))) marker_pairs = pairs.sandbag(training_data) assert utils.same_marker(marker_pairs, ref_markers) print("") print("# Testing AnnData obj, with separate annotation") print("") annotation = { cat: [i for i, x in enumerate(training_data.obs['category']) if x == cat] for cat in ["G1", "S", "G2M"] } marker_pairs = pairs.sandbag(training_data, annotation=annotation) assert utils.same_marker(marker_pairs, ref_markers) print("") print("# Testing DataFrame obj, with separate annotation") print("") training_data_df = DataFrame(training_data.X) sample_names = list(training_data.obs_names) gene_names = list(training_data.var_names) training_data_df.Index = sample_names training_data_df.columns = gene_names marker_pairs = pairs.sandbag(training_data_df, annotation=annotation) assert utils.same_marker(marker_pairs, ref_markers) print("") print("# Testing DataFrame obj, with separate annotation and separate gene-/sample_names") print("") marker_pairs = pairs.sandbag(training_data_df, annotation, gene_names, sample_names) assert utils.same_marker(marker_pairs, ref_markers) print("") print("# Testing ndarray obj, with separate annotation and separate gene-/sample_names") print("") training_data_np = training_data_df.values marker_pairs = pairs.sandbag(training_data_np, annotation, gene_names, sample_names) assert utils.same_marker(marker_pairs, ref_markers)