-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
1,098 additions
and
30 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ dependencies = [ | |
"loguru", | ||
"logomaker", | ||
"pybigtools", | ||
"seaborn" | ||
] | ||
|
||
[project.optional-dependencies] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
from . import bar, heatmap, hist, scatter | ||
from ._contribution_scores import contribution_scores | ||
from ._utils import render_plot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from ._normalization_weights import normalization_weights | ||
from ._region import region, region_predictions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
"""Bar plot of normalization weights.""" | ||
|
||
from __future__ import annotations | ||
|
||
import matplotlib.pyplot as plt | ||
from anndata import AnnData | ||
|
||
from crested._logging import log_and_raise | ||
from crested.pl._utils import render_plot | ||
|
||
|
||
def normalization_weights(adata: AnnData, **kwargs): | ||
""" | ||
Plot the distribution of normalization scaling factors per cell type. | ||
Parameters | ||
---------- | ||
adata | ||
AnnData object containing the normalization weights in `obsm["weights"]`. | ||
kwargs | ||
Additional arguments passed to :func:`~crested.pl.render_plot` to | ||
control the final plot output. Please see :func:`~crested.pl.render_plot` | ||
for details. | ||
See Also | ||
-------- | ||
crested.pl.render_plot | ||
Example | ||
------- | ||
>>> crested.pl.bar.normalization_weights( | ||
... adata, | ||
... xlabel="Cell type", | ||
... ylabel="Scaling factor", | ||
... width=20, | ||
... height=3, | ||
... title="Normalization scaling factors", | ||
... ) | ||
.. image:: ../../../docs/_static/img/examples/bar_normalization_weights.png | ||
""" | ||
|
||
@log_and_raise(ValueError) | ||
def _check_input_params(): | ||
if "weights" not in adata.obsm: | ||
raise ValueError("Normalization weights not found in adata.obsm['weights']") | ||
|
||
_check_input_params() | ||
|
||
weights = adata.obsm["weights"] | ||
classes = list(adata.obs_names) | ||
|
||
fig, ax = plt.subplots() | ||
ax.bar(classes, weights) | ||
|
||
# default plot size | ||
default_width = 20 | ||
default_height = 3 | ||
|
||
if "width" not in kwargs: | ||
kwargs["width"] = default_width | ||
if "height" not in kwargs: | ||
kwargs["height"] = default_height | ||
|
||
render_plot(fig, **kwargs) |
Oops, something went wrong.