Skip to content

Conversation

@mbuttner
Copy link
Contributor

@mbuttner mbuttner commented May 2, 2024

Hi there,
I wrote a color annotation function for the Baseplot class called add_colorblocks(), which borrows some functionality of the add_totals() function and creates a colorblock for the annotation each assigned group.

sc.pl.dotplot(adata, ["CD79A", "MS4A1"], "bulk_labels", return_fig=True, show=False,
                   #swap_axes=True
                   ).add_colorblocks(color='Paired', size=0.1).show()

image

  • Release notes not necessary because:

@codecov
Copy link

codecov bot commented May 2, 2024

❌ 29 Tests Failed:

Tests completed Failed Passed Skipped
1968 29 1939 93
View the top 3 failed test(s) by shortest run time
tests/test_plotting.py::test_dotplot_matrixplot_stacked_violin[matrixplot_std_scale_group]
Stack Traces | 0.12s run time
image_comparer = <function image_comparer.<locals>.save_and_compare at 0x7f6ecc9e6c00>
id = 'matrixplot_std_scale_group'
fn = functools.partial(<function matrixplot at 0x7f6efaf98860>, groupby='cell_type', use_raw=False, standard_scale='group', title='scale_group, swap_axes', swap_axes=True)

    @pytest.mark.parametrize(("id", "fn"), params_dotplot_matrixplot_stacked_violin)
    def test_dotplot_matrixplot_stacked_violin(image_comparer, id, fn):
        save_and_compare_images = partial(image_comparer, ROOT, tol=5)
    
        adata = krumsiek11()
        adata.obs["numeric_column"] = adata.X[:, 0]
        adata.layers["test"] = -1 * adata.X.copy()
        genes_dict = {
            "group a": ["Gata2", "Gata1"],
            "group b": ["Fog1", "EKLF", "Fli1", "SCL"],
            "group c": ["Cebpa", "Pu.1", "cJun", "EgrNab", "Gfi1"],
        }
    
        if id.endswith("dict"):
            fn(adata, genes_dict, show=False)
        else:
            fn(adata, adata.var_names, show=False)
>       save_and_compare_images(id)
#x1B[1m#x1B[31mE       AssertionError: Image files did not match.#x1B[0m
#x1B[1m#x1B[31mE       RMS Value:  19.899309932124144#x1B[0m
#x1B[1m#x1B[31mE       Expected:   file:.../_images/matrixplot_std_scale_group/expected.png#x1B[0m
#x1B[1m#x1B[31mE       Actual:     file:.../_images/matrixplot_std_scale_group/actual.png#x1B[0m
#x1B[1m#x1B[31mE       Difference: file:.../_images/matrixplot_std_scale_group/actual-failed-diff.png#x1B[0m
#x1B[1m#x1B[31mE       Tolerance:  5#x1B[0m

#x1B[1m#x1B[31mtests/test_plotting.py#x1B[0m:361: AssertionError
tests/test_plotting.py::test_genes_symbols[matrixplot-matrixplot]
Stack Traces | 0.123s run time
image_comparer = <function image_comparer.<locals>.save_and_compare at 0x7f6eb01cfe20>
id = 'matrixplot', fn = <function matrixplot at 0x7f6efaf98860>

    @pytest.mark.parametrize(
        ("id", "fn"),
        [
            ("heatmap", sc.pl.heatmap),
            ("dotplot", sc.pl.dotplot),
            ("matrixplot", sc.pl.matrixplot),
            ("stacked_violin", sc.pl.stacked_violin),
            ("tracksplot", sc.pl.tracksplot),
        ],
    )
    def test_genes_symbols(image_comparer, id, fn):
        save_and_compare_images = partial(image_comparer, ROOT, tol=15)
    
        adata = krumsiek11()
    
        # add a 'symbols' column
        adata.var["symbols"] = adata.var.index.map(lambda x: f"symbol_{x}")
        symbols = [f"symbol_{x}" for x in adata.var_names]
    
        fn(adata, symbols, "cell_type", dendrogram=True, gene_symbols="symbols", show=False)
>       save_and_compare_images(f"{id}_gene_symbols")
#x1B[1m#x1B[31mE       AssertionError: Image files did not match.#x1B[0m
#x1B[1m#x1B[31mE       RMS Value:  23.7054961727241#x1B[0m
#x1B[1m#x1B[31mE       Expected:   file:.../_images/matrixplot_gene_symbols/expected.png#x1B[0m
#x1B[1m#x1B[31mE       Actual:     file:.../_images/matrixplot_gene_symbols/actual.png#x1B[0m
#x1B[1m#x1B[31mE       Difference: file:.../_images/matrixplot_gene_symbols/actual-failed-diff.png#x1B[0m
#x1B[1m#x1B[31mE       Tolerance:  15#x1B[0m

#x1B[1m#x1B[31mtests/test_plotting.py#x1B[0m:1031: AssertionError
tests/test_plotting.py::test_genes_symbols[dotplot-dotplot]
Stack Traces | 0.156s run time
image_comparer = <function image_comparer.<locals>.save_and_compare at 0x7f6eb018e660>
id = 'dotplot', fn = <function dotplot at 0x7f6efaf7e660>

    @pytest.mark.parametrize(
        ("id", "fn"),
        [
            ("heatmap", sc.pl.heatmap),
            ("dotplot", sc.pl.dotplot),
            ("matrixplot", sc.pl.matrixplot),
            ("stacked_violin", sc.pl.stacked_violin),
            ("tracksplot", sc.pl.tracksplot),
        ],
    )
    def test_genes_symbols(image_comparer, id, fn):
        save_and_compare_images = partial(image_comparer, ROOT, tol=15)
    
        adata = krumsiek11()
    
        # add a 'symbols' column
        adata.var["symbols"] = adata.var.index.map(lambda x: f"symbol_{x}")
        symbols = [f"symbol_{x}" for x in adata.var_names]
    
        fn(adata, symbols, "cell_type", dendrogram=True, gene_symbols="symbols", show=False)
>       save_and_compare_images(f"{id}_gene_symbols")
#x1B[1m#x1B[31mE       AssertionError: Image files did not match.#x1B[0m
#x1B[1m#x1B[31mE       RMS Value:  24.382759427296776#x1B[0m
#x1B[1m#x1B[31mE       Expected:   file:.../_images/dotplot_gene_symbols/expected.png#x1B[0m
#x1B[1m#x1B[31mE       Actual:     file:.../_images/dotplot_gene_symbols/actual.png#x1B[0m
#x1B[1m#x1B[31mE       Difference: file:.../_images/dotplot_gene_symbols/actual-failed-diff.png#x1B[0m
#x1B[1m#x1B[31mE       Tolerance:  15#x1B[0m

#x1B[1m#x1B[31mtests/test_plotting.py#x1B[0m:1031: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@flying-sheep flying-sheep added this to the 1.12.0 milestone Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants