Skip to contents

Plot smoothed trends for selected genes across pseudotime approximated from embeddings or grouped by clusters.

Usage

VisGeneTrend(
  object,
  features,
  by = "pseudotime",
  reduction = "umap",
  dims = 1:2,
  smooth.method = "loess",
  palette = "C",
  point_size = 2,
  point_alpha = 0.3,
  smooth_alpha = 0.3,
  smooth_linewidth = 1.5
)

Arguments

object

A Seurat object; UMAP/PCA is computed when absent.

features

Character vector of gene names; required.

by

Either 'pseudotime' or a metadata column to group by. Default: 'pseudotime'.

reduction

Reduction used for pseudotime when by='pseudotime' ('umap' or 'pca'). Default: 'umap'.

dims

Dimensions used for pseudotime ranking. Default: 1:2.

smooth.method

Smoothing method: 'loess' or 'gam'. Default: 'loess'.

palette

Viridis palette option for color/fill. Default: "C".

point_size

Point size. Default: 2.

point_alpha

Point alpha. Default: 0.3.

smooth_alpha

Smooth alpha. Default: 0.3.

smooth_linewidth

Smooth line width. Default: 1.5.

Value

A ggplot with smoothed curves per gene.

Author

benben-miao

Examples

obj <- SeuratVisProExample(
    n_cells = 300,
    n_genes = 1000,
    n_clusters = 10,
    seed = 123,
    genes_mt = "^MT-",
    neighbor_dims = 10,
    cluster_res = 0.5,
    umap_dims = 10,
    spatial = FALSE)
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#> 
#> Number of nodes: 300
#> Number of edges: 4508
#> 
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9485
#> Number of communities: 10
#> Elapsed time: 0 seconds

p <- VisGeneTrend(
  obj,
  features = c("G10", "G20", "G30"),
  by = "pseudotime",
  reduction = "umap",
  dims = 1:2,
  smooth.method = "loess",
  palette = "C",
  point_size = 2,
  point_alpha = 0.3,
  smooth_alpha = 0.3,
  smooth_linewidth = 1.5)
p
#> `geom_smooth()` using formula = 'y ~ x'