@@ -326,7 +326,12 @@ def get_expression_vectors_at_rois(
326326
327327
328328def 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
0 commit comments