Skip to contents

Plot dynamic features across pseudotime

Usage

DynamicPlot(
  srt,
  lineages,
  features,
  group.by = NULL,
  cells = NULL,
  layer = "counts",
  assay = NULL,
  family = NULL,
  exp_method = c("log1p", "raw", "zscore", "fc", "log2fc"),
  lib_normalize = identical(layer, "counts"),
  libsize = NULL,
  compare_lineages = TRUE,
  compare_features = FALSE,
  add_line = TRUE,
  add_interval = TRUE,
  line.size = 1,
  line_palette = "Dark2",
  line_palcolor = NULL,
  add_point = TRUE,
  pt.size = 1,
  point_palette = "Paired",
  point_palcolor = NULL,
  add_rug = TRUE,
  flip = FALSE,
  reverse = FALSE,
  x_order = c("value", "rank"),
  aspect.ratio = NULL,
  legend.position = "right",
  legend.direction = "vertical",
  theme_use = "theme_scop",
  theme_args = list(),
  combine = TRUE,
  nrow = NULL,
  ncol = NULL,
  byrow = TRUE,
  seed = 11
)

Arguments

srt

A Seurat object.

lineages

A character vector specifying the lineages to plot.

features

A character vector specifying the features to plot.

group.by

A character specifying a metadata column to group the cells by. Default is NULL.

cells

A character vector specifying the cells to include in the plot. Default is NULL.

layer

A character string specifying the layer to use for the analysis. Default is "counts".

assay

A character string specifying the assay to use for the analysis. Default is NULL.

family

A character specifying the model used to calculate the dynamic features if needed. By default, this parameter is set to NULL, and the appropriate family will be automatically determined.

exp_method

A character specifying the method to transform the expression values. Default is "log1p" with options "log1p", "raw", "zscore", "fc", "log2fc".

lib_normalize

A boolean specifying whether to normalize the expression values using library size. Default the layer is counts, this parameter is set to TRUE. Otherwise, it is set to FALSE.

libsize

A numeric vector specifying the library size for each cell. Default is NULL.

compare_lineages

A boolean specifying whether to compare the lineages in the plot. Default is TRUE.

compare_features

A boolean specifying whether to compare the features in the plot. Default is FALSE.

add_line

A boolean specifying whether to add lines to the plot. Default is TRUE.

add_interval

A boolean specifying whether to add confidence intervals to the plot. Default is TRUE.

line.size

A numeric specifying the size of the lines. Default is 1.

line_palette

A character string specifying the name of the palette to use for the line colors. Default is "Dark2".

line_palcolor

A vector specifying the colors to use for the line palette. Default is NULL.

add_point

A boolean specifying whether to add points to the plot. Default is TRUE.

pt.size

A numeric specifying the size of the points. Default is 1.

point_palette

A character string specifying the name of the palette to use for the point colors. Default is "Paired".

point_palcolor

A vector specifying the colors to use for the point palette. Default is NULL.

add_rug

A boolean specifying whether to add rugs to the plot. Default is TRUE.

flip

A boolean specifying whether to flip the x-axis. Default is FALSE.

reverse

A boolean specifying whether to reverse the x-axis. Default is FALSE.

x_order

A character specifying the order of the x-axis values. Default is c("value", "rank").

aspect.ratio

A numeric specifying the aspect ratio of the plot. Default is NULL.

legend.position

A character string specifying the position of the legend in the plot. Default is "right".

legend.direction

A character string specifying the direction of the legend in the plot. Default is "vertical".

theme_use

A character string specifying the name of the theme to use for the plot. Default is "theme_scop".

theme_args

A list specifying the arguments to pass to the theme function. Default is list().

combine

A boolean specifying whether to combine multiple plots into a single plot. Default is TRUE.

nrow

A numeric specifying the number of rows in the combined plot. Default is NULL.

ncol

A numeric specifying the number of columns in the combined plot. Default is NULL.

byrow

A boolean specifying whether to fill plots by row in the combined plot. Default is TRUE.

seed

A numeric specifying the random seed. Default is 11.

Examples

data(pancreas_sub)
pancreas_sub <- standard_scop(pancreas_sub)
#>  [2025-09-20 13:15:26] Start standard scop workflow...
#>  [2025-09-20 13:15:27] Checking a list of <Seurat> object...
#> ! [2025-09-20 13:15:27] Data 1/1 of the `srt_list` is "unknown"
#>  [2025-09-20 13:15:27] Perform `NormalizeData()` with `normalization.method = 'LogNormalize'` on the data 1/1 of the `srt_list`...
#>  [2025-09-20 13:15:29] Perform `Seurat::FindVariableFeatures()` on the data 1/1 of the `srt_list`...
#>  [2025-09-20 13:15:29] Use the separate HVF from srt_list
#>  [2025-09-20 13:15:29] Number of available HVF: 2000
#>  [2025-09-20 13:15:30] Finished check
#>  [2025-09-20 13:15:30] Perform `Seurat::ScaleData()`
#> Warning: Different features in new layer data than already exists for scale.data
#>  [2025-09-20 13:15:30] Perform pca linear dimension reduction
#> StandardPC_ 1 
#> Positive:  Aplp1, Cpe, Gnas, Fam183b, Map1b, Hmgn3, Pcsk1n, Chga, Tuba1a, Bex2 
#> 	   Syt13, Isl1, 1700086L19Rik, Pax6, Chgb, Scgn, Rbp4, Scg3, Gch1, Camk2n1 
#> 	   Cryba2, Pcsk2, Pyy, Tspan7, Mafb, Hist3h2ba, Dbpht2, Abcc8, Rap1b, Slc38a5 
#> Negative:  Spp1, Anxa2, Sparc, Dbi, 1700011H14Rik, Wfdc2, Gsta3, Adamts1, Clu, Mgst1 
#> 	   Bicc1, Ldha, Vim, Cldn3, Cyr61, Rps2, Mt1, Ptn, Phgdh, Nudt19 
#> 	   Smtnl2, Smco4, Habp2, Mt2, Col18a1, Rpl12, Galk1, Cldn10, Acot1, Ccnd1 
#> StandardPC_ 2 
#> Positive:  Rbp4, Tagln2, Tuba1b, Fkbp2, Pyy, Pcsk2, Iapp, Tmem27, Meis2, Tubb4b 
#> 	   Pcsk1n, Dbpht2, Rap1b, Dynll1, Tubb2a, Sdf2l1, Scgn, 1700086L19Rik, Scg2, Abcc8 
#> 	   Atp1b1, Hspa5, Fam183b, Papss2, Slc38a5, Scg3, Mageh1, Tspan7, Ppp1r1a, Ociad2 
#> Negative:  Neurog3, Btbd17, Gadd45a, Ppp1r14a, Neurod2, Sox4, Smarcd2, Mdk, Pax4, Btg2 
#> 	   Sult2b1, Hes6, Grasp, Igfbpl1, Gpx2, Cbfa2t3, Foxa3, Shf, Mfng, Tmsb4x 
#> 	   Amotl2, Gdpd1, Cdc14b, Epb42, Rcor2, Cotl1, Upk3bl, Rbfox3, Cldn6, Cer1 
#> StandardPC_ 3 
#> Positive:  Nusap1, Top2a, Birc5, Aurkb, Cdca8, Pbk, Mki67, Tpx2, Plk1, Ccnb1 
#> 	   2810417H13Rik, Incenp, Cenpf, Ccna2, Prc1, Racgap1, Cdk1, Aurka, Cdca3, Hmmr 
#> 	   Spc24, Kif23, Sgol1, Cenpe, Cdc20, Hist1h1b, Cdca2, Mxd3, Kif22, Ska1 
#> Negative:  Anxa5, Pdzk1ip1, Acot1, Tpm1, Anxa2, Dcdc2a, Capg, Sparc, Ttr, Pamr1 
#> 	   Clu, Cxcl12, Ndrg2, Hnf1aos1, Gas6, Gsta3, Krt18, Ces1d, Atp1b1, Muc1 
#> 	   Hhex, Acadm, Spp1, Enpp2, Bcl2l14, Sat1, Smtnl2, 1700011H14Rik, Tgm2, Fam159a 
#> StandardPC_ 4 
#> Positive:  Glud1, Tm4sf4, Akr1c19, Cldn4, Runx1t1, Fev, Pou3f4, Gm43861, Pgrmc1, Arx 
#> 	   Cd200, Lrpprc, Hmgn3, Ppp1r14c, Pam, Etv1, Tsc22d1, Slc25a5, Akap17b, Pgf 
#> 	   Fam43a, Emb, Jun, Krt8, Dnajc12, Mid1ip1, Ids, Rgs17, Uchl1, Alcam 
#> Negative:  Ins2, Ins1, Ppp1r1a, Nnat, Calr, Sytl4, Sdf2l1, Iapp, Pdia6, Mapt 
#> 	   G6pc2, C2cd4b, Npy, Gng12, P2ry1, Ero1lb, Adra2a, Papss2, Arhgap36, Fam151a 
#> 	   Dlk1, Creld2, Gip, Tmem215, Gm27033, Cntfr, Prss53, C2cd4a, Lyve1, Ociad2 
#> StandardPC_ 5 
#> Positive:  Pdx1, Nkx6-1, Npepl1, Cldn4, Cryba2, Fev, Jun, Chgb, Gng12, Adra2a 
#> 	   Mnx1, Sytl4, Pdk3, Gm27033, Nnat, Chga, Ins2, 1110012L19Rik, Enho, Krt7 
#> 	   Mlxipl, Tmsb10, Flrt1, Pax4, Tubb3, Prrg2, Gars, Frzb, BC023829, Gm2694 
#> Negative:  Irx2, Irx1, Gcg, Ctxn2, Tmem27, Ctsz, Tmsb15l, Nap1l5, Pou6f2, Gria2 
#> 	   Ghrl, Peg10, Smarca1, Arx, Lrpap1, Rgs4, Ttr, Gast, Tmsb15b2, Serpina1b 
#> 	   Slc16a10, Wnk3, Ly6e, Auts2, Sct, Arg1, Dusp10, Sphkap, Dock11, Edn3 
#>  [2025-09-20 13:15:31] Perform `Seurat::FindClusters()` with louvain and `cluster_resolution` = 0.6
#>  [2025-09-20 13:15:31] Reorder clusters...
#> ! [2025-09-20 13:15:31] Using `Seurat::AggregateExpression()` to calculate pseudo-bulk data for <Assay5>
#>  [2025-09-20 13:15:31] Perform umap nonlinear dimension reduction
#>  [2025-09-20 13:15:31] Non-linear dimensionality reduction (umap) using (Standardpca) dims (1-50) as input
#>  [2025-09-20 13:15:31] UMAP will return its model
#>  [2025-09-20 13:15:35] Non-linear dimensionality reduction (umap) using (Standardpca) dims (1-50) as input
#>  [2025-09-20 13:15:35] UMAP will return its model
#>  [2025-09-20 13:15:39] Run scop standard workflow done
pancreas_sub <- RunSlingshot(
  pancreas_sub,
  group.by = "SubCellType",
  reduction = "UMAP"
)
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: Removed 8 rows containing missing values or values outside the scale range
#> (`geom_path()`).
#> Warning: Removed 8 rows containing missing values or values outside the scale range
#> (`geom_path()`).


CellDimPlot(
  pancreas_sub,
  group.by = "SubCellType",
  reduction = "UMAP",
  lineages = paste0("Lineage", 1:2),
  lineages_span = 0.1
)
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.


DynamicPlot(
  pancreas_sub,
  lineages = "Lineage1",
  features = c("Arxes1", "Ncoa2", "G2M_score"),
  group.by = "SubCellType",
  compare_features = TRUE
)
#>  [2025-09-20 13:15:41] Installing: MatrixGenerics...
#>  
#> → Will install 1 package.
#> → The package (0 B) is cached.
#> + MatrixGenerics   1.20.0 [bld]
#>   
#>  No downloads are needed, 1 pkg is cached
#>  Got MatrixGenerics 1.20.0 (source) (31.97 kB)
#>  Building MatrixGenerics 1.20.0
#>  Built MatrixGenerics 1.20.0 (2.3s)
#>  Installed MatrixGenerics 1.20.0  (1s)
#>  1 pkg + 1 dep: kept 1, added 1, dld 1 (31.97 kB) [4.2s]
#>  [2025-09-20 13:15:46] MatrixGenerics installed successfully
#>  [2025-09-20 13:15:46] Start find dynamic features
#>  [2025-09-20 13:15:46] Installing: mgcv...
#>  
#>   
#>  No downloads are needed
#>  1 pkg + 3 deps: kept 3 [559ms]
#> ! [2025-09-20 13:15:46] Failed to install: mgcv. Please install manually
#>  [2025-09-20 13:15:47] Data type is raw counts
#>  [2025-09-20 13:15:47] Number of candidate features (union): 3
#>  [2025-09-20 13:15:48] Data type is raw counts
#> ! [2025-09-20 13:15:48] Negative values detected
#>  [2025-09-20 13:15:48] Calculating dynamic features for "Lineage1"...
#>  [2025-09-20 13:15:48] Using 1 core
#> ⠙ [2025-09-20 13:15:48] Running [1/3] ETA:  0s
#>  [2025-09-20 13:15:48] Completed 3 tasks in 119ms
#> 
#>  [2025-09-20 13:15:48] Building results
#>  [2025-09-20 13:15:48] Find dynamic features done


DynamicPlot(
  pancreas_sub,
  lineages = c("Lineage1", "Lineage2"),
  features = c("Arxes1", "Ncoa2", "G2M_score"),
  group.by = "SubCellType",
  compare_lineages = TRUE,
  compare_features = FALSE
)
#>  [2025-09-20 13:15:48] MatrixGenerics installed successfully
#>  [2025-09-20 13:15:48] Start find dynamic features
#>  [2025-09-20 13:15:48] Installing: mgcv...
#>  
#>   
#>  No downloads are needed
#>  1 pkg + 3 deps: kept 3 [569ms]
#> ! [2025-09-20 13:15:49] Failed to install: mgcv. Please install manually
#>  [2025-09-20 13:15:50] Data type is raw counts
#>  [2025-09-20 13:15:50] Number of candidate features (union): 3
#>  [2025-09-20 13:15:51] Data type is raw counts
#> ! [2025-09-20 13:15:51] Negative values detected
#>  [2025-09-20 13:15:51] Calculating dynamic features for "Lineage1"...
#>  [2025-09-20 13:15:51] Using 1 core
#> ⠙ [2025-09-20 13:15:51] Running [1/3] ETA:  0s
#>  [2025-09-20 13:15:51] Completed 3 tasks in 118ms
#> 
#>  [2025-09-20 13:15:51] Building results
#>  [2025-09-20 13:15:51] Find dynamic features done
#>  [2025-09-20 13:15:51] Start find dynamic features
#>  [2025-09-20 13:15:51] Installing: mgcv...
#>  
#>   
#>  No downloads are needed
#>  1 pkg + 3 deps: kept 3 [574ms]
#> ! [2025-09-20 13:15:51] Failed to install: mgcv. Please install manually
#>  [2025-09-20 13:15:52] Data type is raw counts
#>  [2025-09-20 13:15:52] Number of candidate features (union): 3
#>  [2025-09-20 13:15:53] Data type is raw counts
#> ! [2025-09-20 13:15:53] Negative values detected
#>  [2025-09-20 13:15:53] Calculating dynamic features for "Lineage2"...
#>  [2025-09-20 13:15:53] Using 1 core
#> ⠙ [2025-09-20 13:15:53] Running [1/3] ETA:  0s
#>  [2025-09-20 13:15:53] Completed 3 tasks in 128ms
#> 
#>  [2025-09-20 13:15:53] Building results
#>  [2025-09-20 13:15:53] Find dynamic features done
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.


DynamicPlot(
  pancreas_sub,
  lineages = c("Lineage1", "Lineage2"),
  features = c("Arxes1", "Ncoa2", "G2M_score"),
  group.by = "SubCellType",
  compare_lineages = FALSE,
  compare_features = FALSE
)
#>  [2025-09-20 13:15:54] MatrixGenerics installed successfully
#>  [2025-09-20 13:15:54] Start find dynamic features
#>  [2025-09-20 13:15:54] Installing: mgcv...
#>  
#>   
#>  No downloads are needed
#>  1 pkg + 3 deps: kept 3 [773ms]
#> ! [2025-09-20 13:15:55] Failed to install: mgcv. Please install manually
#>  [2025-09-20 13:15:56] Data type is raw counts
#>  [2025-09-20 13:15:56] Number of candidate features (union): 3
#>  [2025-09-20 13:15:57] Data type is raw counts
#> ! [2025-09-20 13:15:57] Negative values detected
#>  [2025-09-20 13:15:57] Calculating dynamic features for "Lineage1"...
#>  [2025-09-20 13:15:57] Using 1 core
#> ⠙ [2025-09-20 13:15:57] Running [1/3] ETA:  0s
#>  [2025-09-20 13:15:57] Completed 3 tasks in 124ms
#> 
#>  [2025-09-20 13:15:57] Building results
#>  [2025-09-20 13:15:57] Find dynamic features done
#>  [2025-09-20 13:15:57] Start find dynamic features
#>  [2025-09-20 13:15:57] Installing: mgcv...
#>  
#>   
#>  No downloads are needed
#>  1 pkg + 3 deps: kept 3 [572ms]
#> ! [2025-09-20 13:15:57] Failed to install: mgcv. Please install manually
#>  [2025-09-20 13:15:58] Data type is raw counts
#>  [2025-09-20 13:15:58] Number of candidate features (union): 3
#>  [2025-09-20 13:15:59] Data type is raw counts
#> ! [2025-09-20 13:15:59] Negative values detected
#>  [2025-09-20 13:15:59] Calculating dynamic features for "Lineage2"...
#>  [2025-09-20 13:15:59] Using 1 core
#> ⠙ [2025-09-20 13:15:59] Running [1/3] ETA:  0s
#>  [2025-09-20 13:15:59] Completed 3 tasks in 136ms
#> 
#>  [2025-09-20 13:15:59] Building results
#>  [2025-09-20 13:15:59] Find dynamic features done
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.