Skip to content

Commit

Permalink
update tests, mostly related to expecting names as strings and the re…
Browse files Browse the repository at this point in the history
…levant stringlist, namedlist classes from biocutils
  • Loading branch information
jkanche committed Jan 4, 2024
1 parent 1ddc23d commit b98e97d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
8 changes: 4 additions & 4 deletions tests/test_aggregate_across_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def test_aggregate_across_cells_simple():
x = numpy.round(numpy.random.rand(1000, 8) * 5)
y = scranpy.aggregate_across_cells(x, groups)

assert y.col_data.column("factor_1") == ["A", "B", "C", "D"]
assert list(y.col_data.column("factor_1")) == ["A", "B", "C", "D"]
assert list(y.col_data.column("counts")) == [3, 2, 2, 1]

obs_a = y.assay("sums")[:, 0]
Expand All @@ -27,7 +27,7 @@ def test_aggregate_across_cells_combinations():
y = scranpy.aggregate_across_cells(x, {"group": groups, "batch": batches})

assert y.col_data.column("group") == ["A", "A", "B", "B"]
assert y.col_data.column("batch") == [1, 2, 1, 2]
assert y.col_data.column("batch") == ["1", "2", "1", "2"]
assert list(y.col_data.column("counts")) == [2, 2, 2, 2]

obs_a = y.assay("sums")[:, 1]
Expand All @@ -41,10 +41,10 @@ def test_aggregate_across_cells_combinations():
# Try out different input types.
y2 = scranpy.aggregate_across_cells(x, (groups, batches))
assert y2.col_data.column("factor_1") == ["A", "A", "B", "B"]
assert y2.col_data.column("factor_2") == [1, 2, 1, 2]
assert y2.col_data.column("factor_2") == ["1", "2", "1", "2"]
assert (y2.assay("sums") == y.assay("sums")).all()

y2 = scranpy.aggregate_across_cells(x, BiocFrame({"g": groups, "b": batches}))
assert y2.col_data.column("g") == ["A", "A", "B", "B"]
assert y2.col_data.column("b") == [1, 2, 1, 2]
assert y2.col_data.column("b") == ["1", "2", "1", "2"]
assert (y2.assay("detected") == y.assay("detected")).all()
2 changes: 1 addition & 1 deletion tests/test_analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ def test_analyze_summarizedexperiment(mock_data):
sce.alternative_experiments = { "adt": adt_se }
out = analyze_sce(sce, adt_exp = "adt", assay_type="counts")
assert out.gene_variances.row_names == se.row_names
assert out.adt_markers[0].row_names == adt_se.row_names
assert out.adt_markers["0"].row_names == adt_se.row_names
18 changes: 9 additions & 9 deletions tests/test_score_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,29 @@ def test_score_markers(mock_data):
res = score_markers(out, grouping=grouping)

assert res is not None
assert "means" in res[1].columns
assert isinstance(res[1].column("delta_detected"), BiocFrame)
assert "means" in res["1"].columns
assert isinstance(res["1"].column("delta_detected"), BiocFrame)

# Works when blocks are supplied.
resb = score_markers(
out, grouping=grouping, options=ScoreMarkersOptions(block=mock_data.block)
)
assert resb is not None
assert "detected" in resb[1].columns
assert isinstance(resb[1].column("lfc"), BiocFrame)
assert "detected" in resb["1"].columns
assert isinstance(resb["1"].column("lfc"), BiocFrame)

# Same results in parallel.
resp = score_markers(
out, grouping=grouping, options=ScoreMarkersOptions(num_threads=3)
)
assert (res[0].column("means") == resp[0].column("means")).all()
assert (res["0"].column("means") == resp["0"].column("means")).all()
assert (
res[1].column("cohen").column("mean") == resp[1].column("cohen").column("mean")
res["1"].column("cohen").column("mean") == resp["1"].column("cohen").column("mean")
).all()
assert (
res[2].column("auc").column("min_rank")
== resp[2].column("auc").column("min_rank")
res["2"].column("auc").column("min_rank")
== resp["2"].column("auc").column("min_rank")
).all()
assert (
res[3].column("lfc").column("min") == resp[3].column("lfc").column("min")
res["3"].column("lfc").column("min") == resp["3"].column("lfc").column("min")
).all()
4 changes: 4 additions & 0 deletions tests/test_suggest_adt_qc_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def test_suggest_adt_qc_filters_custom(mock_data):
assert list(filters_custom.column("detected")) == [4, 5, 6]
assert list(filters_custom.column("subset_totals").column("foo")) == [7, 8, 9]

print("HEREEEEE")

# Now with some blocks, out of order.
filters_custom = suggest_adt_qc_filters(
result,
Expand All @@ -93,6 +95,8 @@ def test_suggest_adt_qc_filters_custom(mock_data):
),
)

print("filters_custom", filters_custom)

assert filters_custom.shape[0] == 3
assert list(filters_custom.column("detected")) == [6, 5, 4]
assert list(filters_custom.column("subset_totals").column("foo")) == [9, 8, 7]

0 comments on commit b98e97d

Please sign in to comment.