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.
Juscan.Pl.expand_palette
Juscan.Pl.get_continuous_colormap
Juscan.Pl.hvg_scatter
Juscan.Pl.plot_umap
Juscan.Pl.plot_variance_ratio
Juscan.Pl.scatter
Juscan.Pl.violin
QC and Feature Plots
Juscan.Pl.violin
— Functionviolin(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 fromadata.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 ortrue
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
ortrue
ifsavefig=true
.
Juscan.Pl.scatter
— Functionscatter(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 forcolor_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
ortrue
ifsavefig=true
.
HVG Visualization
Juscan.Pl.hvg_scatter
— Functionhvg_scatter(adata::AnnData; savefig=false)
Plots mean expression vs dispersion for genes, highlighting highly variable genes (HVGs).
Arguments
adata::AnnData
: Annotated data object withhighly_variable
,means
,variances
, andvariances_norm
inadata.var
.
Keyword Arguments
savefig::Union{Bool, String}=false
: Whether to save the figure.
Returns
- A
Figure
ortrue
ifsavefig=true
.
Dimensionality Reduction
Juscan.Pl.plot_variance_ratio
— Functionplot_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 inadata.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
ortrue
ifsavefig=true
.
Juscan.Pl.plot_umap
— Functionplot_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 inadata.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 iftrue
or path given.
Returns
- A
Figure
ortrue
ifsavefig=true
.
Throws
- Error if
umap_coords
is not found inadata.obsm
.
Color Utilities
Juscan.Pl.expand_palette
— Functionexpand_palette(base_colors::Vector{<:Colorant}, n::Int)
Return n
interpolated colors based on the base_colors
using cgrad
.
Juscan.Pl.get_continuous_colormap
— Functionget_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.