chrysalis.plot

chrysalis.plot(adata: AnnData, dim: int = 8, hexcodes: Optional[List[str]] = None, seed: Optional[int] = None, sample_id: Optional[Union[int, str]] = None, sample_col: str = 'sample', spot_size: float = 1.05, marker: str = 'h', figsize: Tuple[int, int] = (5, 5), ax: Optional[Axes] = None, dpi: int = 100, selected_comp: Union[int, str] = 'all', rotation: int = 0, uns_spatial_key: Optional[str] = None, **scr_kw)

Visualize tissue compartments using MIP (Maximum Intensity Projection).

Tissue compartments need to be calculated using chrysalis.aa. If no hexcodes are provided, random colors are generated for the individual tissue compartments. Spot size is calculated automatically, however it can be fine-tuned using the spot_size parameter.

Parameters:
  • adata – The AnnData data matrix of shape n_obs × n_vars. Rows correspond to cells and columns to genes.

  • dim – Number of components to visualize.

  • hexcodes – List of hexadecimal colors to replace the default colormap.

  • seed – Random seed, used for mixing colors.

  • sample_id – ID corresponding to the sample as defined in the sample column, stored .obs[‘sample’] by default.

  • sample_col – The .obs column storing the sample_id information, ‘sample’ by default.

  • spot_size – Adjust the final spot size.

  • marker – Marker type.

  • figsize – Figure size as a tuple.

  • ax – Draw plot on a specific Matplotlib axes instead of a figure if specified.

  • dpi – Optional DPI value used when ax is specified.

  • selected_comp – Show only the selected compartment if specified.

  • rotation – Rotate markers for alternative lattice arrangements.

  • uns_spatial_key – Alternative key in .uns[‘spatial’] storing spot size and scaling factor.

  • scr_kw – Matplotlib scatterplot keyword arguments.

Example usage:

>>> import chrysalis as ch
>>> import scanpy as sc
>>> import matplotlib.pyplot as plt
>>> adata = sc.datasets.visium_sge(sample_id='V1_Human_Lymph_Node')
>>> sc.pp.calculate_qc_metrics(adata, inplace=True)
>>> sc.pp.filter_cells(adata, min_counts=6000)
>>> sc.pp.filter_genes(adata, min_cells=10)
>>> ch.detect_svgs(adata)
>>> sc.pp.normalize_total(adata, inplace=True)
>>> sc.pp.log1p(adata)
>>> ch.pca(adata)
>>> ch.aa(adata, n_pcs=20, n_archetypes=8)
>>> ch.plot(adata, dim=8)
>>> plt.show()