CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-scanpy

Comprehensive toolkit for analyzing single-cell gene expression data with scalable Python implementation supporting preprocessing, visualization, clustering, trajectory inference, and differential expression testing.

Pending
Overview
Eval results
Files

visualization.mddocs/

Visualization

Scanpy's plotting module provides extensive visualization capabilities for single-cell data including scatter plots, heatmaps, violin plots, trajectory plots, and specialized single-cell visualizations. All plots are built on matplotlib and integrate seamlessly with the analysis workflow.

Capabilities

Embedding and Dimensionality Reduction Plots

Visualize low-dimensional representations of single-cell data.

def umap(adata, color=None, use_raw=None, edges=False, arrows=False, sort_order=True, groups=None, components=None, projection='2d', legend_loc='right margin', legend_fontsize=None, legend_fontweight='bold', palette=None, color_map=None, frameon=None, right_margin=None, left_margin=None, size=None, title=None, save=None, ax=None, return_fig=None, **kwargs):
    """
    Scatter plot in UMAP basis.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - color (str or list, optional): Keys for annotations of observations/cells or variables/genes
    - use_raw (bool, optional): Use raw attribute of adata
    - edges (bool): Show edges in neighborhood graph
    - arrows (bool): Show arrows for RNA velocity
    - sort_order (bool): Sort points by color values
    - groups (str or list, optional): Restrict to these groups
    - components (str or list, optional): Components to plot
    - projection (str): Type of projection ('2d' or '3d')
    - legend_loc (str): Location of legend
    - legend_fontsize (int, optional): Legend font size
    - legend_fontweight (str): Legend font weight
    - palette (str, optional): Color palette
    - color_map (str, optional): Colormap
    - frameon (bool, optional): Draw frame around plot
    - right_margin (float, optional): Right margin
    - left_margin (float, optional): Left margin
    - size (float, optional): Point size
    - title (str, optional): Plot title
    - save (str, optional): Save figure to file
    - ax (Axes, optional): Matplotlib axes object
    - return_fig (bool, optional): Return figure object
    - **kwargs: Additional parameters
    
    Returns:
    None or Figure: Plot or figure object (if return_fig=True)
    """

def tsne(adata, color=None, use_raw=None, sort_order=True, groups=None, components=None, projection='2d', legend_loc='right margin', legend_fontsize=None, palette=None, color_map=None, frameon=None, right_margin=None, size=None, title=None, save=None, ax=None, return_fig=None, **kwargs):
    """
    Scatter plot in t-SNE basis.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - color (str or list, optional): Keys for annotations
    - use_raw (bool, optional): Use raw attribute
    - sort_order (bool): Sort points by color values
    - groups (str or list, optional): Restrict to groups
    - components (str or list, optional): Components to plot
    - projection (str): Type of projection
    - legend_loc (str): Legend location
    - legend_fontsize (int, optional): Legend font size
    - palette (str, optional): Color palette
    - color_map (str, optional): Colormap
    - frameon (bool, optional): Draw frame
    - right_margin (float, optional): Right margin
    - size (float, optional): Point size
    - title (str, optional): Plot title
    - save (str, optional): Save figure
    - ax (Axes, optional): Matplotlib axes
    - return_fig (bool, optional): Return figure
    - **kwargs: Additional parameters
    
    Returns:
    None or Figure: Plot or figure object
    """

def pca(adata, color=None, use_raw=None, sort_order=True, groups=None, components=None, projection='2d', legend_loc='right margin', legend_fontsize=None, palette=None, color_map=None, frameon=None, right_margin=None, size=None, title=None, save=None, ax=None, return_fig=None, **kwargs):
    """
    Scatter plot in PCA coordinates.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - color (str or list, optional): Keys for annotations
    - use_raw (bool, optional): Use raw attribute
    - sort_order (bool): Sort points by color values
    - groups (str or list, optional): Restrict to groups
    - components (str or list, optional): Components to plot
    - projection (str): Type of projection
    - legend_loc (str): Legend location
    - legend_fontsize (int, optional): Legend font size
    - palette (str, optional): Color palette
    - color_map (str, optional): Colormap
    - frameon (bool, optional): Draw frame
    - right_margin (float, optional): Right margin
    - size (float, optional): Point size
    - title (str, optional): Plot title
    - save (str, optional): Save figure
    - ax (Axes, optional): Matplotlib axes
    - return_fig (bool, optional): Return figure
    - **kwargs: Additional parameters
    
    Returns:
    None or Figure: Plot or figure object
    """

def diffmap(adata, color=None, components=None, **kwargs):
    """
    Scatter plot in diffusion map basis.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - color (str or list, optional): Keys for annotations
    - components (str or list, optional): Components to plot
    - **kwargs: Additional plotting parameters
    
    Returns:
    None or Figure: Plot or figure object
    """

def draw_graph(adata, color=None, layout=None, **kwargs):
    """
    Scatter plot in graph drawing coordinates.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - color (str or list, optional): Keys for annotations
    - layout (str, optional): Graph layout to use
    - **kwargs: Additional plotting parameters
    
    Returns:
    None or Figure: Plot or figure object
    """

def embedding(adata, basis, color=None, **kwargs):
    """
    Scatter plot for any embedding in adata.obsm.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - basis (str): Basis key in obsm
    - color (str or list, optional): Keys for annotations
    - **kwargs: Additional plotting parameters
    
    Returns:
    None or Figure: Plot or figure object
    """

Gene Expression Plots

Visualize gene expression patterns across cells.

def scatter(adata, x=None, y=None, color=None, use_raw=None, layers=None, sort_order=True, alpha=None, basis=None, groups=None, components=None, projection='2d', legend_loc='right margin', legend_fontsize=None, legend_fontweight='bold', palette=None, color_map=None, frameon=None, right_margin=None, left_margin=None, size=None, title=None, save=None, ax=None, return_fig=None, **kwargs):
    """
    Scatter plot along observations or variables axes.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - x (str, optional): x-coordinate
    - y (str, optional): y-coordinate  
    - color (str or list, optional): Keys for annotations
    - use_raw (bool, optional): Use raw attribute
    - layers (str, optional): Layer to use for coloring
    - sort_order (bool): Sort points by color values
    - alpha (float, optional): Point transparency
    - basis (str, optional): Embedding basis
    - groups (str or list, optional): Restrict to groups
    - components (str or list, optional): Components to plot
    - projection (str): Type of projection
    - legend_loc (str): Legend location
    - legend_fontsize (int, optional): Legend font size
    - legend_fontweight (str): Legend font weight
    - palette (str, optional): Color palette
    - color_map (str, optional): Colormap
    - frameon (bool, optional): Draw frame
    - right_margin (float, optional): Right margin
    - left_margin (float, optional): Left margin
    - size (float, optional): Point size
    - title (str, optional): Plot title
    - save (str, optional): Save figure
    - ax (Axes, optional): Matplotlib axes
    - return_fig (bool, optional): Return figure
    - **kwargs: Additional parameters
    
    Returns:
    None or Figure: Plot or figure object
    """

def violin(adata, keys, groupby=None, log=False, use_raw=None, stripplot=True, jitter=0.4, size=1, layer=None, scale='width', order=None, multi_panel=None, xlabel='', ylabel='', rotation=None, ax=None, save=None, **kwds):
    """
    Violin plot of gene expression.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - keys (str or list): Keys for accessing variables
    - groupby (str, optional): Key for grouping observations
    - log (bool): Plot on log scale
    - use_raw (bool, optional): Use raw attribute
    - stripplot (bool): Add strip plot
    - jitter (float): Strip plot jitter
    - size (float): Strip plot point size
    - layer (str, optional): Layer to use
    - scale (str): Violin scaling method
    - order (list, optional): Order of groups
    - multi_panel (bool, optional): Create multi-panel plot
    - xlabel (str): x-axis label
    - ylabel (str): y-axis label
    - rotation (float, optional): Label rotation
    - ax (Axes, optional): Matplotlib axes
    - save (str, optional): Save figure
    - **kwds: Additional parameters
    
    Returns:
    None or Axes: Plot or axes object
    """

def heatmap(adata, var_names, groupby=None, use_raw=None, log=False, num_categories=7, figsize=None, dendrogram=False, gene_symbols=None, var_group_positions=None, var_group_labels=None, var_group_rotation=None, layer=None, standard_scale=None, swap_axes=False, show_gene_labels=None, save=None, ax=None, vmin=None, vmax=None, vcenter=None, **kwds):
    """
    Heatmap of gene expression across groups.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - var_names (list): Variable names
    - groupby (str, optional): Key for grouping observations
    - use_raw (bool, optional): Use raw attribute
    - log (bool): Log transform values
    - num_categories (int): Number of categories for continuous variables
    - figsize (tuple, optional): Figure size
    - dendrogram (bool): Show dendrogram
    - gene_symbols (str, optional): Key for gene symbols
    - var_group_positions (list, optional): Variable group positions
    - var_group_labels (list, optional): Variable group labels
    - var_group_rotation (float, optional): Variable group label rotation
    - layer (str, optional): Layer to use
    - standard_scale (str, optional): Standardization method
    - swap_axes (bool): Swap axes
    - show_gene_labels (bool, optional): Show gene labels
    - save (str, optional): Save figure
    - ax (Axes, optional): Matplotlib axes
    - vmin (float, optional): Minimum value for colormap
    - vmax (float, optional): Maximum value for colormap
    - vcenter (float, optional): Center value for colormap
    - **kwds: Additional parameters
    
    Returns:
    dict: Plot information
    """

Specialized Plot Types

Advanced plotting functions for specific analysis types.

def dotplot(adata, var_names, groupby, use_raw=None, log=False, num_categories=7, figsize=None, gene_symbols=None, var_group_positions=None, var_group_labels=None, var_group_rotation=None, layer=None, standard_scale=None, largest_dot=200.0, title=None, colorbar_title='Mean expression\\nin group', size_title='Fraction of cells\\nin group (%)', save=None, ax=None, return_fig=False, **kwds):
    """
    Makes a dot plot of the expression values.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - var_names (list): Variable names to plot
    - groupby (str): Key for grouping observations
    - use_raw (bool, optional): Use raw attribute
    - log (bool): Log transform values
    - num_categories (int): Number of categories
    - figsize (tuple, optional): Figure size
    - gene_symbols (str, optional): Key for gene symbols
    - var_group_positions (list, optional): Variable group positions
    - var_group_labels (list, optional): Variable group labels
    - var_group_rotation (float, optional): Variable group label rotation
    - layer (str, optional): Layer to use
    - standard_scale (str, optional): Standardization method
    - largest_dot (float): Size of largest dot
    - title (str, optional): Plot title
    - colorbar_title (str): Colorbar title
    - size_title (str): Size legend title
    - save (str, optional): Save figure
    - ax (Axes, optional): Matplotlib axes
    - return_fig (bool): Return figure object
    - **kwds: Additional parameters
    
    Returns:
    DotPlot or Figure: Plot object or figure
    """

def matrixplot(adata, var_names, groupby, use_raw=None, log=False, num_categories=7, figsize=None, gene_symbols=None, var_group_positions=None, var_group_labels=None, var_group_rotation=None, layer=None, standard_scale=None, colorbar_title='Mean expression\\nin group', title=None, save=None, ax=None, return_fig=False, **kwds):
    """
    Creates a heatmap of the mean expression values per group.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - var_names (list): Variable names to plot
    - groupby (str): Key for grouping observations
    - use_raw (bool, optional): Use raw attribute
    - log (bool): Log transform values
    - num_categories (int): Number of categories
    - figsize (tuple, optional): Figure size
    - gene_symbols (str, optional): Key for gene symbols
    - var_group_positions (list, optional): Variable group positions
    - var_group_labels (list, optional): Variable group labels
    - var_group_rotation (float, optional): Variable group label rotation
    - layer (str, optional): Layer to use
    - standard_scale (str, optional): Standardization method
    - colorbar_title (str): Colorbar title
    - title (str, optional): Plot title
    - save (str, optional): Save figure
    - ax (Axes, optional): Matplotlib axes
    - return_fig (bool): Return figure object
    - **kwds: Additional parameters
    
    Returns:
    MatrixPlot or Figure: Plot object or figure
    """

def stacked_violin(adata, var_names, groupby, use_raw=None, log=False, num_categories=7, figsize=None, gene_symbols=None, var_group_positions=None, var_group_labels=None, var_group_rotation=None, layer=None, standard_scale=None, title=None, save=None, ax=None, return_fig=False, **kwds):
    """
    Stacked violin plots.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - var_names (list): Variable names to plot
    - groupby (str): Key for grouping observations
    - use_raw (bool, optional): Use raw attribute
    - log (bool): Log transform values
    - num_categories (int): Number of categories
    - figsize (tuple, optional): Figure size
    - gene_symbols (str, optional): Key for gene symbols
    - var_group_positions (list, optional): Variable group positions
    - var_group_labels (list, optional): Variable group labels
    - var_group_rotation (float, optional): Variable group label rotation
    - layer (str, optional): Layer to use
    - standard_scale (str, optional): Standardization method
    - title (str, optional): Plot title
    - save (str, optional): Save figure
    - ax (Axes, optional): Matplotlib axes
    - return_fig (bool): Return figure object
    - **kwds: Additional parameters
    
    Returns:
    StackedViolin or Figure: Plot object or figure
    """

def tracksplot(adata, var_names, groupby, use_raw=None, log=False, dendrogram=False, gene_symbols=None, var_group_positions=None, var_group_labels=None, var_group_rotation=None, layer=None, standard_scale=None, title=None, save=None, ax=None, return_fig=False, **kwds):
    """
    Plot gene expression as tracks along groups.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - var_names (list): Variable names to plot
    - groupby (str): Key for grouping observations
    - use_raw (bool, optional): Use raw attribute
    - log (bool): Log transform values
    - dendrogram (bool): Show dendrogram
    - gene_symbols (str, optional): Key for gene symbols
    - var_group_positions (list, optional): Variable group positions
    - var_group_labels (list, optional): Variable group labels
    - var_group_rotation (float, optional): Variable group label rotation
    - layer (str, optional): Layer to use
    - standard_scale (str, optional): Standardization method
    - title (str, optional): Plot title
    - save (str, optional): Save figure
    - ax (Axes, optional): Matplotlib axes
    - return_fig (bool): Return figure object
    - **kwds: Additional parameters
    
    Returns:
    None or Figure: Plot or figure object
    """

Trajectory and Pseudotime Plots

Visualize developmental trajectories and pseudotime analysis.

def paga(adata, basis='umap', color=None, alpha=None, groups=None, components=None, projection='2d', legend_loc='right margin', legend_fontsize=None, legend_fontweight='bold', palette=None, color_map=None, frameon=None, right_margin=None, left_margin=None, size=None, title=None, save=None, ax=None, return_fig=None, pos=None, labels=None, layout=None, init_pos=None, random_state=0, root=0, transitions=None, solid_edges='connectivities', dashed_edges=None, single_component=False, fontsize=None, fontcolor=None, textstyle='italic', fontweight='bold', fontfamily='sans-serif', edge_width_scale=5, arrowsize=30, node_size_scale=1.0, node_size_power=0.5, min_edge_width=None, max_edge_width=None, threshold=None, normalize_to_zero_one=False, cmap=None, use_raw=None, export_to_gexf=False, plot=True, **kwargs):
    """
    Plot the abstracted graph through PAGA.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - basis (str): Embedding basis for nodes
    - color (str or list, optional): Keys for node coloring
    - alpha (float, optional): Transparency
    - groups (str or list, optional): Restrict to groups
    - components (str or list, optional): Components to plot
    - projection (str): Type of projection
    - legend_loc (str): Legend location
    - legend_fontsize (int, optional): Legend font size
    - legend_fontweight (str): Legend font weight
    - palette (str, optional): Color palette
    - color_map (str, optional): Colormap
    - frameon (bool, optional): Draw frame
    - right_margin (float, optional): Right margin
    - left_margin (float, optional): Left margin
    - size (float, optional): Point size
    - title (str, optional): Plot title
    - save (str, optional): Save figure
    - ax (Axes, optional): Matplotlib axes
    - return_fig (bool, optional): Return figure
    - pos (array, optional): Node positions
    - labels (list, optional): Node labels
    - layout (str, optional): Graph layout
    - init_pos (array, optional): Initial positions
    - random_state (int): Random seed
    - root (int): Root node
    - transitions (str, optional): Transitions to show
    - solid_edges (str): Solid edge type
    - dashed_edges (str, optional): Dashed edge type
    - single_component (bool): Show single component
    - fontsize (int, optional): Font size
    - fontcolor (str, optional): Font color
    - textstyle (str): Text style
    - fontweight (str): Font weight
    - fontfamily (str): Font family
    - edge_width_scale (float): Edge width scaling
    - arrowsize (int): Arrow size
    - node_size_scale (float): Node size scaling
    - node_size_power (float): Node size power
    - min_edge_width (float, optional): Minimum edge width
    - max_edge_width (float, optional): Maximum edge width
    - threshold (float, optional): Edge threshold
    - normalize_to_zero_one (bool): Normalize edge weights
    - cmap (str, optional): Colormap
    - use_raw (bool, optional): Use raw attribute
    - export_to_gexf (bool): Export to GEXF format
    - plot (bool): Whether to plot
    - **kwargs: Additional parameters
    
    Returns:
    None or Figure: Plot or figure object
    """

def dpt_groups_pseudotime(adata, color_map=None, palette=None, save=None, **kwargs):
    """
    Plot groups and pseudotime.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - color_map (str, optional): Colormap
    - palette (str, optional): Color palette
    - save (str, optional): Save figure
    - **kwargs: Additional parameters
    
    Returns:
    None: Creates plot
    """

def dpt_timeseries(adata, color_map=None, save=None, **kwargs):
    """
    Heatmap of pseudotime series.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - color_map (str, optional): Colormap
    - save (str, optional): Save figure
    - **kwargs: Additional parameters
    
    Returns:
    None: Creates plot
    """

Spatial Transcriptomics

Visualize spatial transcriptomics data.

def spatial(adata, basis='spatial', color=None, use_raw=None, sort_order=True, alpha=None, groups=None, components=None, dimensions=None, layer=None, bw=None, contour=False, title=None, save=None, ax=None, return_fig=None, **kwargs):
    """
    Plot spatial transcriptomics data.
    
    Parameters:
    - adata (AnnData): Annotated data object with spatial coordinates
    - basis (str): Spatial coordinates key in obsm
    - color (str or list, optional): Keys for coloring
    - use_raw (bool, optional): Use raw attribute
    - sort_order (bool): Sort points by color values
    - alpha (float, optional): Transparency
    - groups (str or list, optional): Restrict to groups
    - components (str or list, optional): Components to plot
    - dimensions (tuple, optional): Dimensions to plot
    - layer (str, optional): Layer to use
    - bw (str or float, optional): Bandwidth for density estimation
    - contour (bool): Add contour lines
    - title (str, optional): Plot title
    - save (str, optional): Save figure
    - ax (Axes, optional): Matplotlib axes
    - return_fig (bool, optional): Return figure
    - **kwargs: Additional parameters
    
    Returns:
    None or Figure: Plot or figure object
    """

Ranking and Comparison Plots

Visualize gene rankings and group comparisons.

def rank_genes_groups(adata, groups=None, n_genes=25, groupby=None, key='rank_genes_groups', fontsize=8, ncols=4, sharey=True, show=None, save=None, ax=None, **kwds):
    """
    Plot ranking of genes using dotplot, heatmap or stacked_violin.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - groups (str or list, optional): Groups to plot
    - n_genes (int): Number of genes to show
    - groupby (str, optional): Key for grouping
    - key (str): Key for ranked genes results
    - fontsize (int): Font size
    - ncols (int): Number of columns
    - sharey (bool): Share y-axis
    - show (bool, optional): Show plot
    - save (str, optional): Save figure
    - ax (Axes, optional): Matplotlib axes
    - **kwds: Additional parameters
    
    Returns:
    None: Creates plot
    """

def rank_genes_groups_dotplot(adata, **kwargs):
    """Dotplot of ranked genes."""
    
def rank_genes_groups_heatmap(adata, **kwargs):
    """Heatmap of ranked genes."""
    
def rank_genes_groups_stacked_violin(adata, **kwargs):
    """Stacked violin plot of ranked genes."""
    
def rank_genes_groups_violin(adata, **kwargs):
    """Violin plot of ranked genes."""
    
def rank_genes_groups_tracksplot(adata, **kwargs):
    """Tracks plot of ranked genes."""
    
def rank_genes_groups_matrixplot(adata, **kwargs):
    """Matrix plot of ranked genes."""

Quality Control Plots

Visualize data quality metrics and preprocessing results.

def highest_expr_genes(adata, n_top=30, show=None, save=None, ax=None, **kwds):
    """
    Plot the fraction of counts assigned to each gene over all cells.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - n_top (int): Number of top genes to show
    - show (bool, optional): Show plot
    - save (str, optional): Save figure
    - ax (Axes, optional): Matplotlib axes
    - **kwds: Additional parameters
    
    Returns:
    None: Creates plot
    """

def filter_genes_dispersion(adata, log=False, save=None, **kwds):
    """
    Plot dispersions versus means for genes.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - log (bool): Log transform axes
    - save (str, optional): Save figure
    - **kwds: Additional parameters
    
    Returns:
    None: Creates plot
    """

def highly_variable_genes(adata, log=False, save=None, **kwds):
    """
    Plot dispersions versus means for genes.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - log (bool): Log transform axes
    - save (str, optional): Save figure
    - **kwds: Additional parameters
    
    Returns:
    None: Creates plot
    """

def scrublet_score_distribution(adata, save=None, **kwds):
    """
    Plot histogram of doublet scores.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - save (str, optional): Save figure
    - **kwds: Additional parameters
    
    Returns:
    None: Creates plot
    """

PCA-specific Plots

Specialized plots for principal component analysis results.

def pca_loadings(adata, components=None, save=None, **kwds):
    """
    Rank and plot PCA loadings.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - components (str or list, optional): Components to plot
    - save (str, optional): Save figure
    - **kwds: Additional parameters
    
    Returns:
    None: Creates plot
    """

def pca_overview(adata, save=None, **kwds):
    """
    Plot PCA results overview.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - save (str, optional): Save figure
    - **kwds: Additional parameters
    
    Returns:
    None: Creates plot
    """

def pca_variance_ratio(adata, log=False, n_pcs=50, save=None, **kwds):
    """
    Variance ratio plot for PCA.
    
    Parameters:
    - adata (AnnData): Annotated data object
    - log (bool): Log scale y-axis
    - n_pcs (int): Number of PCs to show
    - save (str, optional): Save figure
    - **kwds: Additional parameters
    
    Returns:
    None: Creates plot
    """

Plot Configuration

Functions for configuring plot appearance and behavior.

def set_rcParams_scanpy(fontsize=14, color_map=None):
    """
    Set matplotlib rcParams for scanpy.
    
    Parameters:
    - fontsize (float): Font size
    - color_map (str, optional): Default colormap
    
    Returns:
    None: Modifies matplotlib rcParams
    """

def set_rcParams_defaults():
    """
    Reset matplotlib rcParams to defaults.
    
    Returns:
    None: Resets matplotlib rcParams
    """

Plot Classes

Object-oriented plotting interface for complex visualizations.

class DotPlot:
    """Dotplot of gene expression."""
    
    def __init__(self, adata, var_names, groupby, **kwargs):
        """Initialize DotPlot object."""
        
    def add_totals(self, **kwargs):
        """Add total counts."""
        
    def legend(self, **kwargs):
        """Add legend."""
        
    def show(self, **kwargs):
        """Show plot."""
        
    def save(self, filename, **kwargs):
        """Save plot."""

class MatrixPlot:
    """Matrix plot of gene expression."""
    
    def __init__(self, adata, var_names, groupby, **kwargs):
        """Initialize MatrixPlot object."""
        
    def add_totals(self, **kwargs):
        """Add total counts."""
        
    def show(self, **kwargs):
        """Show plot."""
        
    def save(self, filename, **kwargs):
        """Save plot."""

class StackedViolin:
    """Stacked violin plot."""
    
    def __init__(self, adata, var_names, groupby, **kwargs):
        """Initialize StackedViolin object."""
        
    def add_totals(self, **kwargs):
        """Add total counts."""
        
    def show(self, **kwargs):
        """Show plot."""  
        
    def save(self, filename, **kwargs):
        """Save plot."""

Usage Examples

Basic Embedding Visualization

import scanpy as sc

# UMAP with cluster coloring
sc.pl.umap(adata, color='leiden', legend_loc='on data', 
           title='Leiden clustering', frameon=False, save='.pdf')

# Multiple features
sc.pl.umap(adata, color=['leiden', 'CD3E', 'CD14'], ncols=3)

# Gene expression
sc.pl.umap(adata, color='CD3E', use_raw=False, color_map='viridis')

Gene Expression Analysis

# Violin plots
sc.pl.violin(adata, ['CD3E', 'CD14', 'CD79A'], groupby='leiden')

# Heatmap
sc.pl.heatmap(adata, var_names=['CD3E', 'CD14'], groupby='leiden', 
              show_gene_labels=True)

# Dotplot for marker genes
marker_genes = ['CD3E', 'CD4', 'CD8A', 'CD14', 'CD68', 'CD79A']
sc.pl.dotplot(adata, marker_genes, groupby='leiden')

Trajectory Visualization

# PAGA plot
sc.pl.paga(adata, plot=False)  # compute positions
sc.pl.paga(adata, color=['leiden'], title='PAGA graph')

# Pseudotime
sc.pl.umap(adata, color=['leiden', 'dpt_pseudotime'], 
           legend_loc='on data')

Quality Control Visualization

# QC metrics
sc.pl.violin(adata, ['n_genes_by_counts', 'total_counts', 'pct_counts_mt'],
             jitter=0.4, multi_panel=True)

# Highest expressing genes
sc.pl.highest_expr_genes(adata, n_top=20)

# Highly variable genes
sc.pl.highly_variable_genes(adata)

# PCA variance
sc.pl.pca_variance_ratio(adata, log=True, n_pcs=50)

Install with Tessl CLI

npx tessl i tessl/pypi-scanpy

docs

analysis-tools.md

data-io.md

datasets.md

external-tools.md

index.md

preprocessing.md

queries.md

spatial-analysis.md

utilities.md

visualization.md

tile.json