Plotting Module

The plots module provides a set of visualization tools designed to make single-cell data exploration intuitive and informative. These functions enable users to create publication-ready figures for quality control, feature exploration, dimensionality reduction, and clustering results.

Violin and Scatter Plots

Violin and scatter plots are essential for examining cell-level metrics, such as gene counts, total expression, or mitochondrial content. The violin function offers compact summaries of distributions, while scatter allows for flexible 2D comparisons between features, optionally colored by additional metadata.

Highly Variable Genes Visualization

The hvg_scatter function provides a dual-panel visualization of gene variability metrics, distinguishing highly variable genes (HVGs) from background genes. This plot is especially useful for evaluating gene selection prior to dimensionality reduction.

Dimensionality Reduction Plots

The plot_variance_ratio function visualizes the explained variance of each principal component, helping users decide how many PCs to retain. plot_umap projects cells into a low-dimensional embedding using UMAP, colored by user-specified labels to reveal structure and cluster separation.

Color Palettes

Color plays a vital role in visual clarity. Juscan.jl includes palette expansion and colormap utilities to generate well-balanced, customizable color schemes. These utilities ensure consistency across all plots.

By combining visual elegance with analytical depth, the plots module empowers users to communicate insights clearly and effectively.


QC and Feature Plots

Juscan.Pl.violinFunction
violin(adata::AnnData, keys; kwargs...)

Draws violin plots for one or more features stored in adata.obs.

Arguments

  • adata::AnnData: Annotated data object.
  • keys::Union{String, Vector{String}}: One or more feature names from adata.obs to plot.

Keyword Arguments

  • width::Real=600: Width of each subplot.
  • height::Real=400: Height of the plot.
  • jitter::Union{Bool, Real}=0.5: Jitter width or true to apply default jitter.
  • dot_size::Real=2: Size of jittered dots.
  • title::String="violin plot": Title of the full figure.
  • palette_name::String="friendly": Color palette name.
  • fill_alpha::Real=1.0: Transparency of the violin fill.
  • downsample_strategy::String="evenly": Strategy for downsampling color palette.
  • savefig::Union{Bool, String}=false: Whether to save the figure, or path to save.

Returns

  • A CairoMakie.Figure or true if savefig=true.
source
Juscan.Pl.scatterFunction
scatter(adata::AnnData, x_key, y_key; kwargs...)

Generates a scatter plot from two features in adata.obs, optionally colored by a third.

Arguments

  • adata::AnnData: Annotated data object.
  • x_key::String: Feature name for x-axis.
  • y_key::String: Feature name for y-axis.

Keyword Arguments

  • color_key::Union{String, Nothing}=nothing: Feature used for point colors.
  • title::String="scatter plot": Plot title.
  • width::Real=600: Width of the plot.
  • height::Real=400: Height of the plot.
  • colormap_name::String="viridis": Colormap for color_key.
  • ncolors::Int=265: Number of colors in colormap.
  • downsample_strategy::String="evenly": Strategy for colormap downsampling.
  • savefig::Union{Bool, String}=false: Whether to save the figure.

Returns

  • A Figure or true if savefig=true.
source

HVG Visualization

Juscan.Pl.hvg_scatterFunction
hvg_scatter(adata::AnnData; savefig=false)

Plots mean expression vs dispersion for genes, highlighting highly variable genes (HVGs).

Arguments

  • adata::AnnData: Annotated data object with highly_variable, means, variances, and variances_norm in adata.var.

Keyword Arguments

  • savefig::Union{Bool, String}=false: Whether to save the figure.

Returns

  • A Figure or true if savefig=true.
source

Dimensionality Reduction

Juscan.Pl.plot_variance_ratioFunction
plot_variance_ratio(adata::AnnData; key="pca_variance", n=50, savefig=false)

Plots the explained variance ratio for the top principal components (PCA).

Arguments

  • adata::AnnData: Annotated data object.
  • key::AbstractString="pca_variance": Key in adata.uns for PCA singular values.
  • n::Real=50: Number of PCs to plot.

Keyword Arguments

  • savefig::Union{Bool, String}=false: Whether to save the figure.

Returns

  • A Figure or true if savefig=true.
source
Juscan.Pl.plot_umapFunction
plot_umap(adata; kwargs...)

Plots UMAP embedding colored by a categorical label in adata.obs.

Keyword Arguments

  • color_by::String="clusters_0.6": Observation field to color points.
  • key::String="umap": Key in adata.obsm containing UMAP coordinates.
  • palette_name::String="rainbow": Color palette name.
  • width::Real=800: Width of the plot.
  • height::Real=600: Height of the plot.
  • downsample_strategy::String="evenly": Color downsampling strategy.
  • savefig::Union{Bool, String}=false: Save to file if true or path given.

Returns

  • A Figure or true if savefig=true.

Throws

  • Error if umap_coords is not found in adata.obsm.
source

Color Utilities

Juscan.Pl.expand_paletteFunction
expand_palette(base_colors::Vector{<:Colorant}, n::Int)

Return n interpolated colors based on the base_colors using cgrad.

source
Juscan.Pl.get_continuous_colormapFunction
get_continuous_colormap(name::String, n::Int=265)

Get n evenly spaced colors from a predefined continuous colormap in ColorSchemes.jl. Available names: :viridis, :inferno, :plasma, :magma, :turbo, :cividis, etc.

source