Example #1
0
 def test_plot_kwargs(self, ligrec_result: Mapping[str, pd.DataFrame]):
     # color_on is intentionally ignored
     pl.ligrec(ligrec_result,
               grid=False,
               color_on="square",
               x_padding=2,
               y_padding=2)
Example #2
0
 def test_invalid_means_range_size(self,
                                   ligrec_result: Mapping[str,
                                                          pd.DataFrame]):
     with pytest.raises(
             ValueError,
             match=
             r"Expected `means_range` to be a sequence of size `2`, found `3`."
     ):
         pl.ligrec(ligrec_result, means_range=[0, 1, 2])
Example #3
0
    def test_all_interactions_empty(self,
                                    ligrec_result: Mapping[str, pd.DataFrame]):
        empty = pd.DataFrame(np.nan,
                             index=ligrec_result["pvalues"].index,
                             columns=ligrec_result["pvalues"].columns)

        with pytest.raises(
                ValueError,
                match=
                r"After removing rows with only NaN interactions, none remain."
        ):
            pl.ligrec({
                "means": empty,
                "pvalues": empty,
                "metadata": empty
            },
                      remove_empty_interactions=True)
Example #4
0
 def test_plot_swap_axes(self, ligrec_result: Mapping[str, pd.DataFrame]):
     pl.ligrec(ligrec_result, swap_axes=True)
Example #5
0
 def test_plot_dendrogram_both(self, ligrec_result: Mapping[str,
                                                            pd.DataFrame]):
     np.random.seed(42)
     pl.ligrec(ligrec_result, dendrogram="both")
Example #6
0
 def test_plot_dendrogram_clusters(self,
                                   ligrec_result: Mapping[str,
                                                          pd.DataFrame]):
     # this currently "fails" (i.e. no dendrogram)
     np.random.seed(42)
     pl.ligrec(ligrec_result, dendrogram="interacting_clusters")
Example #7
0
 def test_plot_dendrogram_pairs(self, ligrec_result: Mapping[str,
                                                             pd.DataFrame]):
     np.random.seed(42)
     pl.ligrec(ligrec_result, dendrogram="interacting_molecules")
Example #8
0
 def test_plot_means_range(self, ligrec_result: Mapping[str, pd.DataFrame]):
     pl.ligrec(ligrec_result, means_range=(0.5, 1))
Example #9
0
 def test_invalid_key(self, adata: AnnData):
     with pytest.raises(
             KeyError,
             match=r"Key `foobar_ligrec` not found in `adata.uns`."):
         pl.ligrec(adata, cluster_key="foobar")
Example #10
0
 def test_plot_cmap(self, ligrec_result: Mapping[str, pd.DataFrame]):
     pl.ligrec(ligrec_result, cmap="inferno")
Example #11
0
 def test_plot_target_clusters(self, ligrec_result: Mapping[str,
                                                            pd.DataFrame]):
     tgt_cls = ligrec_result["pvalues"].columns.get_level_values(1)[0]
     pl.ligrec(ligrec_result, target_groups=tgt_cls)
Example #12
0
 def test_plot_source_clusters(self, ligrec_result: Mapping[str,
                                                            pd.DataFrame]):
     src_cls = ligrec_result["pvalues"].columns.get_level_values(0)[0]
     pl.ligrec(ligrec_result, source_groups=src_cls)
Example #13
0
 def test_invalid_clusters(self, ligrec_result: Mapping[str, pd.DataFrame]):
     with pytest.raises(ValueError,
                        match=r"No valid clusters have been selected."):
         pl.ligrec(ligrec_result, source_groups="foo", target_groups="bar")
Example #14
0
 def test_invalid_alpha(self, ligrec_result: Mapping[str, pd.DataFrame]):
     with pytest.raises(ValueError, match=r"Expected `alpha`"):
         pl.ligrec(ligrec_result, alpha=1.2)
Example #15
0
 def test_valid_key_invalid_object(self, adata: AnnData):
     adata.uns["foobar_ligrec"] = "baz"
     with pytest.raises(TypeError,
                        match=r"Expected `adata` .+ found `str`."):
         pl.ligrec(adata, cluster_key="foobar")
Example #16
0
 def test_plot_swap_axes_dedrogram(self,
                                   ligrec_result: Mapping[str,
                                                          pd.DataFrame]):
     pl.ligrec(ligrec_result,
               swap_axes=True,
               dendrogram="interacting_molecules")
Example #17
0
 def test_plot_alpha(self, ligrec_result: Mapping[str, pd.DataFrame]):
     pl.ligrec(ligrec_result, alpha=1)
Example #18
0
 def test_plot_no_remove_empty_interactions(
         self, ligrec_result: Mapping[str, pd.DataFrame]):
     tmp = deepcopy(ligrec_result)
     tmp["pvalues"].values[:2, :] = np.nan
     pl.ligrec(tmp, remove_empty_interactions=False)
Example #19
0
 def test_plot_pvalue_threshold(self, ligrec_result: Mapping[str,
                                                             pd.DataFrame]):
     pl.ligrec(ligrec_result, pvalue_threshold=0.05)
Example #20
0
 def test_invalid_type(self):
     with pytest.raises(TypeError,
                        match=r"Expected `adata` .+ found `int`."):
         pl.ligrec(42)