From 789487e3d26daa6f85fbdffbf92d33604d8714af Mon Sep 17 00:00:00 2001 From: Bo Li Date: Sun, 2 Jun 2024 10:41:21 -0700 Subject: [PATCH 1/2] Updated compo_plot function --- pegasus/plotting/plot_library.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pegasus/plotting/plot_library.py b/pegasus/plotting/plot_library.py index e5eed19..e89bcf2 100644 --- a/pegasus/plotting/plot_library.py +++ b/pegasus/plotting/plot_library.py @@ -797,6 +797,8 @@ def compo_plot( bottom: Optional[float] = 0.15, wspace: Optional[float] = 0.3, hspace: Optional[float] = 0.15, + xticklabels_rotation: Optional[float] = 90.0, + yticklabels_rotation: Optional[float] = 0.0, return_fig: Optional[bool] = False, dpi: Optional[float] = 300.0, **kwargs, @@ -836,6 +838,10 @@ def compo_plot( This parameter sets the width between panels and also the figure's right margin as a fraction of panel's width (wspace * panel_size[0]). hspace: ``float``, optional (defualt: ``0.15``) This parameter sets the height between panels and also the figure's top margin as a fraction of panel's height (hspace * panel_size[1]). + xticklabels_rotation: Optional[float] = 90.0, + Rotation of x-axis tick labels. + yticklabels_rotation: Optional[float] = 0.0, + Rotation of y-axis tick labels. return_fig: ``bool``, optional, default: ``False`` Return a ``Figure`` object if ``True``; return ``None`` otherwise. dpi: ``float``, optional, default: ``300.0`` @@ -904,14 +910,13 @@ def compo_plot( ax.grid(False) if not switch_axes: ax.set_xlabel(groupby_label) + ax.set_xticklabels(ax.get_xticklabels(), rotation=xticklabels_rotation, ha='center') ax.set_ylabel("Percentage") else: ax.set_xlabel("Percentage") ax.set_ylabel(groupby_label) - ax.legend(loc="center left", bbox_to_anchor=(1.05, 0.5)) - - if len(max(df.index.astype(str), key=len)) >= 5: - ax.set_xticklabels(ax.get_xticklabels(), rotation=-45, ha='left') + ax.set_yticklabels(ax.get_yticklabels(), rotation=yticklabels_rotation, ha='center') + ax.legend(loc="center left", bbox_to_anchor=(1.05, 0.5)) return fig if return_fig else None From 326687968614dae4dc887fc5d3c9a0d9a667b843 Mon Sep 17 00:00:00 2001 From: Bo Li Date: Tue, 4 Jun 2024 19:45:44 -0700 Subject: [PATCH 2/2] Updated some docstring in pseudobulk function --- pegasus/tools/pseudobulk.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pegasus/tools/pseudobulk.py b/pegasus/tools/pseudobulk.py index 75e8493..e50a940 100644 --- a/pegasus/tools/pseudobulk.py +++ b/pegasus/tools/pseudobulk.py @@ -30,12 +30,12 @@ def get_pseudobulk_count(X, df, attr, bulk_list): @timer(logger=logger) def pseudobulk( - data: MultimodalData, + data: Union[MultimodalData, UnimodalData], groupby: str, attrs: Optional[Union[List[str], str]] = None, mat_key: str = "counts", condition: Optional[str] = None, -) -> UnimodalData: +) -> MultimodalData: """Generate Pseudo-bulk count matrices. Parameters @@ -157,9 +157,7 @@ def deseq2( compute_all: bool = False, n_jobs: int = -1, ) -> None: - """Perform Differential Expression (DE) Analysis using DESeq2 on pseduobulk data. This function calls R package DESeq2, requiring DESeq2 in R installed. - - DE analysis will be performed on all pseudo-bulk matrices in pseudobulk. + """Perform Differential Expression (DE) Analysis using DESeq2 on pseduobulk data. Parameters ----------