Visualization: Single Cell Omics - iffatAGheyas/bioinformatics-tutorial-wiki GitHub Wiki

6.1.9 Visualization

High-quality figures help you communicate single-cell results. We’ll show how to make feature plots, dot plots, heatmaps, and—when you have trajectories—velocity/trajectory streamlines in both R (Seurat) and Python (Scanpy + scVelo).


A. Feature Plots

Seurat (R)

# UMAP with expression of two genes
FeaturePlot(
  object    = seurat_obj,
  features  = c("GeneA","GeneB"),
  pt.size   = 0.2,
  cols      = c("lightgrey","blue")
)

Scanpy (Python)

import scanpy as sc

# UMAP colored by expression
sc.pl.umap(
    adata,
    color=['GeneA','GeneB'],
    size=20,
    cmap='viridis'
)

B. Dot Plots

Seurat (R)

# DotPlot shows pct. cells expressing + avg expression
DotPlot(
  seurat_obj,
  features = c("GeneA","GeneB","GeneC"),
  cols     = c("lightgrey","red")
) + RotatedAxis()

Scanpy (Python)

# groupby cluster, genes list
sc.pl.dotplot(
    adata,
    var_names=["GeneA","GeneB","GeneC"],
    groupby="leiden",
    standard_scale="var"   # scale per gene
)
C. Heatmaps

Seurat (R)

# Top 20 markers heatmap
top20 <- markers_wilcox %>% 
  group_by(cluster) %>% 
  top_n(n = 20, wt = avg_log2FC) %>% 
  pull(gene)
DoHeatmap(
  seurat_obj,
  features = top20,
  size = 3
) + NoLegend()

Scanpy (Python)

# heatmap of top markers per cluster
import pandas as pd
groups = adata.obs['leiden'].cat.categories
# get top 5 genes per cluster
top_genes = []
for g in groups:
    df = sc.get.rank_genes_groups_df(adata, group=g)
    top_genes += list(df['names'].head(5))
sc.pl.heatmap(
    adata,
    var_names=top_genes,
    groupby='leiden',
    use_raw=False,
    show_gene_labels=True,
    cmap='RdBu_r'
)
D. Trajectory & Velocity Streamlines

Monocle 3 (R) – trajectory on UMAP:

plot_cells(
  cds,
  color_cells_by = "pseudotime",
  label_cell_groups = FALSE,
  label_leaves = FALSE,
  label_branch_points = FALSE,
  graph_label_size = 1.5
)

scVelo (Python) – RNA velocity streamlines on UMAP:

import scvelo as scv

# Precomputed in adata
scv.pl.velocity_embedding_stream(
    adata,
    basis='umap',
    color='leiden',
    legend_loc='right margin',
    arrow_length=3,
    arrow_size=1
)

Pro tips:

  • Adjust pt.size/size so individual points are visible but not overplotted.

  • Use consistent color palettes (e.g. viridis, RColorBrewer) across panels.

  • For publication figures, export at high resolution (300 dpi) or as vector graphics (SVG/PDF).