Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 49 additions & 5 deletions ovrlpy/_ovrlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,12 @@ def get_expression_vectors_at_rois(


def plot_signal_integrity(
integrity, signal, signal_threshold: float = 2.0, cmap="BIH", plot_hist: bool = True
integrity,
signal,
signal_threshold: float = 2.0,
cmap="BIH",
figure_height: float = 10,
plot_hist: bool = True,
):
"""
Plots the determined signal integrity of the tissue sample in a signal integrity map.
Expand All @@ -346,18 +351,23 @@ def plot_signal_integrity(
Whether to plot a histogram of integrity values alongside the map.
"""

figure_height = int(15 * integrity.shape[0] / integrity.shape[1]) + 1
figure_aspect_ratio = integrity.shape[0] / integrity.shape[1]

with plt.style.context("dark_background"):
if cmap == "BIH":
cmap = _BIH_CMAP

if plot_hist:
fig, ax = plt.subplots(
1, 2, figsize=(20, figure_height), gridspec_kw={"width_ratios": [6, 1]}
1,
2,
figsize=(figure_height / figure_aspect_ratio * 1.4, figure_height),
gridspec_kw={"width_ratios": [6, 1]},
)
else:
fig, ax = plt.subplots(1, 1, figsize=(20, figure_height))
fig, ax = plt.subplots(
1, 1, figsize=(figure_height / figure_aspect_ratio, figure_height)
)
ax = [ax]

img = ax[0].imshow(
Expand Down Expand Up @@ -480,6 +490,41 @@ class Visualizer:
Keyword arguments for 2D UMAP embedding.
cumap_kwargs : dict, optional
Keyword arguments for 3D UMAP embedding.

Attributes
----------
KDE_bandwidth : float
The bandwidth of the KDE.
celltyping_min_expression : int
Minimum expression level for cell typing.
celltyping_min_distance : int
Minimum distance for cell typing.
rois_celltyping_x : np.ndarray
x-coordinates of cell typing regions of interest obtained through gene expression localmax sampling.
rois_celltyping_y : np.ndarray
y-coordinates of cell typing regions of interest obtained through gene expression localmax sampling.
localmax_celltyping_samples : pd.DataFrame
Gene expression matrix of the cell typing regions of interest.
signatures : pd.DataFrame
A matrix of celltypes x gene signatures to use to annotate the UMAP.
celltype_centers : np.ndarray
The center of gravity of each celltype in the 2d embedding, used for UMAP annotation.
celltype_class_assignments : np.ndarray
The class assignments of the cell types.
pca_2d : PCA
The PCA object used for the 2d embedding.
embedder_2d : umap.UMAP
The UMAP object used for the 2d embedding.
pca_3d : PCA
The PCA object used for the 3d RGB embedding.
embedder_3d : umap.UMAP
The UMAP object used for the 3d RGB embedding.
n_components_pca : float
Number of components for PCA.
umap_kwargs : dict
Keyword arguments for 2D UMAP embedding.
cumap_kwargs : dict

"""

def __init__(
Expand All @@ -501,7 +546,6 @@ def __init__(
"random_state": None,
},
) -> None:
"""TODO: document attributes"""
self.KDE_bandwidth = KDE_bandwidth

self.celltyping_min_expression = celltyping_min_expression
Expand Down
2 changes: 2 additions & 0 deletions ovrlpy/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ def _plot_embeddings(
if ax is None:
ax = plt.gca()

ax.axis("off")

alpha = 0.1 if "alpha" not in scatter_kwargs else scatter_kwargs.pop("alpha")
marker = "." if "marker" not in scatter_kwargs else scatter_kwargs.pop("marker")

Expand Down