Skip to content

Commit 72cf683

Browse files
Merge pull request #20 from HiDiHlabs/18-fix-integrity-figure-display-size
figure height adaptable for integrity plots, UMAP axes removed
2 parents ef2428f + 355485a commit 72cf683

File tree

2 files changed

+51
-5
lines changed

2 files changed

+51
-5
lines changed

ovrlpy/_ovrlp.py

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,12 @@ def get_expression_vectors_at_rois(
326326

327327

328328
def plot_signal_integrity(
329-
integrity, signal, signal_threshold: float = 2.0, cmap="BIH", plot_hist: bool = True
329+
integrity,
330+
signal,
331+
signal_threshold: float = 2.0,
332+
cmap="BIH",
333+
figure_height: float = 10,
334+
plot_hist: bool = True,
330335
):
331336
"""
332337
Plots the determined signal integrity of the tissue sample in a signal integrity map.
@@ -346,18 +351,23 @@ def plot_signal_integrity(
346351
Whether to plot a histogram of integrity values alongside the map.
347352
"""
348353

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

351356
with plt.style.context("dark_background"):
352357
if cmap == "BIH":
353358
cmap = _BIH_CMAP
354359

355360
if plot_hist:
356361
fig, ax = plt.subplots(
357-
1, 2, figsize=(20, figure_height), gridspec_kw={"width_ratios": [6, 1]}
362+
1,
363+
2,
364+
figsize=(figure_height / figure_aspect_ratio * 1.4, figure_height),
365+
gridspec_kw={"width_ratios": [6, 1]},
358366
)
359367
else:
360-
fig, ax = plt.subplots(1, 1, figsize=(20, figure_height))
368+
fig, ax = plt.subplots(
369+
1, 1, figsize=(figure_height / figure_aspect_ratio, figure_height)
370+
)
361371
ax = [ax]
362372

363373
img = ax[0].imshow(
@@ -480,6 +490,41 @@ class Visualizer:
480490
Keyword arguments for 2D UMAP embedding.
481491
cumap_kwargs : dict, optional
482492
Keyword arguments for 3D UMAP embedding.
493+
494+
Attributes
495+
----------
496+
KDE_bandwidth : float
497+
The bandwidth of the KDE.
498+
celltyping_min_expression : int
499+
Minimum expression level for cell typing.
500+
celltyping_min_distance : int
501+
Minimum distance for cell typing.
502+
rois_celltyping_x : np.ndarray
503+
x-coordinates of cell typing regions of interest obtained through gene expression localmax sampling.
504+
rois_celltyping_y : np.ndarray
505+
y-coordinates of cell typing regions of interest obtained through gene expression localmax sampling.
506+
localmax_celltyping_samples : pd.DataFrame
507+
Gene expression matrix of the cell typing regions of interest.
508+
signatures : pd.DataFrame
509+
A matrix of celltypes x gene signatures to use to annotate the UMAP.
510+
celltype_centers : np.ndarray
511+
The center of gravity of each celltype in the 2d embedding, used for UMAP annotation.
512+
celltype_class_assignments : np.ndarray
513+
The class assignments of the cell types.
514+
pca_2d : PCA
515+
The PCA object used for the 2d embedding.
516+
embedder_2d : umap.UMAP
517+
The UMAP object used for the 2d embedding.
518+
pca_3d : PCA
519+
The PCA object used for the 3d RGB embedding.
520+
embedder_3d : umap.UMAP
521+
The UMAP object used for the 3d RGB embedding.
522+
n_components_pca : float
523+
Number of components for PCA.
524+
umap_kwargs : dict
525+
Keyword arguments for 2D UMAP embedding.
526+
cumap_kwargs : dict
527+
483528
"""
484529

485530
def __init__(
@@ -501,7 +546,6 @@ def __init__(
501546
"random_state": None,
502547
},
503548
) -> None:
504-
"""TODO: document attributes"""
505549
self.KDE_bandwidth = KDE_bandwidth
506550

507551
self.celltyping_min_expression = celltyping_min_expression

ovrlpy/_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ def _plot_embeddings(
176176
if ax is None:
177177
ax = plt.gca()
178178

179+
ax.axis("off")
180+
179181
alpha = 0.1 if "alpha" not in scatter_kwargs else scatter_kwargs.pop("alpha")
180182
marker = "." if "marker" not in scatter_kwargs else scatter_kwargs.pop("marker")
181183

0 commit comments

Comments
 (0)