Skip to content

Commit

Permalink
Merge pull request #24 from MICS-Lab/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
quentinblampey authored Nov 6, 2023
2 parents 491ec29 + 9ad372a commit e936351
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "scyan"
version = "1.5.1"
version = "1.5.2"
description = "Single-cell Cytometry Annotation Network"
documentation = "https://mics-lab.github.io/scyan/"
homepage = "https://mics-lab.github.io/scyan/"
Expand Down
2 changes: 1 addition & 1 deletion scyan/module/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def compute_modes(self):
self.factor[self.is_continuum_marker] = 5
self.factor = self.factor[None, None, :]

self.modes = self.rho[None, ...] / self.factor
self.register_buffer("modes", self.rho[None, ...] / self.factor)

@property
def prior_h(self) -> distributions.Distribution:
Expand Down
7 changes: 5 additions & 2 deletions scyan/plot/ratios.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def pop_percentage(
adata: AnnData,
groupby: Union[str, List[str], None] = None,
key: str = "scyan_pop",
figsize: tuple[float, float] = None,
show: bool = True,
):
"""Show populations percentages. Depending on `groupby`, this is either done globally, or as a stacked bar plot (one bar for each group).
Expand All @@ -27,14 +28,15 @@ def pop_percentage(
adata: An `AnnData` object.
groupby: Key(s) of `adata.obs` used to create groups (e.g. the patient ID).
key: Key of `adata.obs` containing the population names (or the values) for which percentage will be displayed.
figsize: matplotlib figure size.
show: Whether or not to display the figure.
"""
if groupby is None:
adata.obs[key].value_counts(normalize=True).mul(100).plot.bar()
adata.obs[key].value_counts(normalize=True).mul(100).plot.bar(figsize=figsize)
else:
adata.obs.groupby(groupby)[key].value_counts(normalize=True).mul(
100
).unstack().plot.bar(stacked=True)
).unstack().plot.bar(stacked=True, figsize=figsize)
plt.legend(
bbox_to_anchor=(1.04, 0.5), loc="center left", borderaxespad=0, frameon=False
)
Expand Down Expand Up @@ -79,6 +81,7 @@ def pop_dynamics(
groupby = ([groupby] if isinstance(groupby, str) else groupby) + [time_key]

df = cell_type_ratios(adata, groupby=groupby, key=key, normalize="%", among=among)
df.index = df.index.set_levels(df.index.levels[-1].astype(str), level=-1)
df_log_count = np.log(
1 + cell_type_ratios(adata, groupby=groupby, key=key, normalize=False)
)
Expand Down
2 changes: 1 addition & 1 deletion scyan/tools/gating.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class PolygonGatingScatter:
!!! note
If used on a Jupyter Notebook, you should first run `%matplotlib tk` on a blank jupyter cell. After the selection, you can run `%matplotlib inline` to retrieve the default behavior.
If used on a Jupyter Notebook, you should first run `%matplotlib tk`. After the selection, you can run `%matplotlib inline` to retrieve the default behavior.
```py
# Usage example (`%matplotlib tk` is required for the cell selection on jupyter notebooks)
Expand Down

0 comments on commit e936351

Please sign in to comment.