Repository: theislab/cellrank (language: python)

Issue:
Ordering of macrostates
<!-- Describe the feature request in the block below: -->
Hi @michalk8, I'm looking into the new ordering methods you introduced for the `plot_coarse_T` method and I have a few remarks:
- could you please invert the sorting? Most users read figures from left to right, top to bottom. That means the early states, i.e. low stability, should be in the top left corner. Currently, it's the other way around, see Fig. 1 below. 
- this should be consistent across all ordering options - i.e. whatever sorting I use, I should always find my putative early states in the top left corner, and my putative late states in the lower right corner. It's also inverted for `stat_dist` at the moment, see Fig. 2.
- could you add add mode `outgoing` please? 

## Fig. 1
<img width="821" alt="Screenshot 2022-03-06 at 15 16 04" src="https://user-images.githubusercontent.com/24494650/156940567-dc122e48-69d2-41a9-b6de-3046342ef958.png">

## Fig. 2
<img width="821" alt="Screenshot 2022-03-06 at 15 19 50" src="https://user-images.githubusercontent.com/24494650/156940660-f96b045a-5003-44a3-8085-cfefa7d19e97.png">




Discussion / hints:
Re 1 and 2: ok, that's not a problem.
Re 3: it always sums to 1, so I think it's meaningless.

Fix patch:
diff --git a/cellrank/tl/estimators/terminal_states/_gpcca.py b/cellrank/tl/estimators/terminal_states/_gpcca.py
index 33047aac9..13b6358b4 100644
--- a/cellrank/tl/estimators/terminal_states/_gpcca.py
+++ b/cellrank/tl/estimators/terminal_states/_gpcca.py
@@ -49,6 +49,7 @@ class TermStatesMethod(ModeEnum):  # noqa: D101
 class CoarseTOrder(ModeEnum):  # noqa: D101
     STABILITY = auto()  # diagonal
     INCOMING = auto()
+    OUTGOING = auto()
     STAT_DIST = auto()
 
 
@@ -438,7 +439,9 @@ def plot_coarse_T(
         self,
         show_stationary_dist: bool = True,
         show_initial_dist: bool = False,
-        order: Optional[Literal["stability", "incoming", "stat_dist"]] = "stability",
+        order: Optional[
+            Literal["stability", "incoming", "outgoing", "stat_dist"]
+        ] = "stability",
         cmap: Union[str, ListedColormap] = "viridis",
         xtick_rotation: float = 45,
         annotate: bool = True,
@@ -464,6 +467,7 @@ def plot_coarse_T(
 
                 - `{o.STABILITY!r}` - order by the values on the diagonal.
                 - `{o.INCOMING!r}` - order by the incoming mass, excluding the diagonal.
+                - `{o.OUTGOING!r}` - order by the outgoing mass, excluding the diagonal.
                 - `{o.STAT_DIST!r}` - order by coarse stationary distribution. If not present, use `{o.STABILITY!r}`.
         cmap
             Colormap to use.
@@ -506,13 +510,14 @@ def order_matrix(
 
             if order == CoarseTOrder.INCOMING:
                 values = (coarse_T.sum(0) - np.diag(coarse_T)).argsort(kind="stable")
-                names = values.index[values][::-1]
+                names = values.index[values]
+            elif order == CoarseTOrder.OUTGOING:
+                values = (coarse_T.sum(1) - np.diag(coarse_T)).argsort(kind="stable")
+                names = values.index[values]
             elif order == CoarseTOrder.STABILITY:
-                names = coarse_T.index[
-                    np.argsort(np.diag(coarse_T), kind="stable")[::-1]
-                ]
+                names = coarse_T.index[np.argsort(np.diag(coarse_T), kind="stable")]
             elif order == CoarseTOrder.STAT_DIST:
-                names = stat_d.index[stat_d.argsort(kind="stable")][::-1]
+                names = stat_d.index[stat_d.argsort(kind="stable")]
             else:
                 raise NotImplementedError(f"Order `{order}` is not yet implemented.")
 


Test patch:
diff --git a/tests/_ground_truth_figures/gpcca_coarse_T.png b/tests/_ground_truth_figures/gpcca_coarse_T.png
index 62f3c7a92..d137dad0c 100644
Binary files a/tests/_ground_truth_figures/gpcca_coarse_T.png and b/tests/_ground_truth_figures/gpcca_coarse_T.png differ
diff --git a/tests/_ground_truth_figures/gpcca_coarse_T_cmap.png b/tests/_ground_truth_figures/gpcca_coarse_T_cmap.png
index 7ee5fbea7..f6793da34 100644
Binary files a/tests/_ground_truth_figures/gpcca_coarse_T_cmap.png and b/tests/_ground_truth_figures/gpcca_coarse_T_cmap.png differ
diff --git a/tests/_ground_truth_figures/gpcca_coarse_T_init_dist.png b/tests/_ground_truth_figures/gpcca_coarse_T_init_dist.png
index 951945a5b..08931a2b9 100644
Binary files a/tests/_ground_truth_figures/gpcca_coarse_T_init_dist.png and b/tests/_ground_truth_figures/gpcca_coarse_T_init_dist.png differ
diff --git a/tests/_ground_truth_figures/gpcca_coarse_T_no_annot.png b/tests/_ground_truth_figures/gpcca_coarse_T_no_annot.png
index 2b0d5b72e..d02ebe986 100644
Binary files a/tests/_ground_truth_figures/gpcca_coarse_T_no_annot.png and b/tests/_ground_truth_figures/gpcca_coarse_T_no_annot.png differ
diff --git a/tests/_ground_truth_figures/gpcca_coarse_T_no_cbar.png b/tests/_ground_truth_figures/gpcca_coarse_T_no_cbar.png
index c763f3ade..8480d9e33 100644
Binary files a/tests/_ground_truth_figures/gpcca_coarse_T_no_cbar.png and b/tests/_ground_truth_figures/gpcca_coarse_T_no_cbar.png differ
diff --git a/tests/_ground_truth_figures/gpcca_coarse_T_stat_dist.png b/tests/_ground_truth_figures/gpcca_coarse_T_stat_dist.png
index 1c05a1910..a1de9eb29 100644
Binary files a/tests/_ground_truth_figures/gpcca_coarse_T_stat_dist.png and b/tests/_ground_truth_figures/gpcca_coarse_T_stat_dist.png differ
diff --git a/tests/_ground_truth_figures/gpcca_coarse_T_stat_init_dist.png b/tests/_ground_truth_figures/gpcca_coarse_T_stat_init_dist.png
index 90b2a398a..a7d1a3d4f 100644
Binary files a/tests/_ground_truth_figures/gpcca_coarse_T_stat_init_dist.png and b/tests/_ground_truth_figures/gpcca_coarse_T_stat_init_dist.png differ
diff --git a/tests/_ground_truth_figures/gpcca_coarse_T_xtick_rot.png b/tests/_ground_truth_figures/gpcca_coarse_T_xtick_rot.png
index 588305daf..c493314d3 100644
Binary files a/tests/_ground_truth_figures/gpcca_coarse_T_xtick_rot.png and b/tests/_ground_truth_figures/gpcca_coarse_T_xtick_rot.png differ