This function infers a pseudo-time trajectory based on the supervised input. It was modified from the package ArchR addTrajectory to use a Seurat object as input. For more details, check here https://www.archrproject.com/reference/addTrajectory.html.
Author: Jeffrey Granja

AddTrajectory(
  object,
  name = "Trajectory",
  trajectory = NULL,
  group.by = NULL,
  reduction = NULL,
  dims = NULL,
  pre.filter.quantile = 0.9,
  post.filter.quantile = 0.9,
  use.all = FALSE,
  dof = 250,
  spar = 1,
  seed = 42
)

Arguments

object

A Seurat object

name

A string indicating the name of the fitted trajectory to be added in meta.data

trajectory

The order of cell groups to be used for constraining the initial supervised fitting procedure

group.by

The column name in metadata that contains the cell group definitions used in trajectory

reduction

Name of dimension reduction used to infer the trajectory

dims

How many dimensions to use

pre.filter.quantile

Prior to the initial supervised trajectory fitting, cells whose euclidean distance from the cell-grouping center is above the provided quantile will be excluded.

post.filter.quantile

After initial supervised trajectory fitting, cells whose euclidean distance from the cell-grouping center is above the provided quantile will be excluded.

use.all

Whether or not to use cells ourside of trajectory groups for post-fitting procedure

dof

The number of degrees of freedom to be used in the spline fit

spar

The sparsity to be used in the spline fit.

seed

Random seed

Value

Seurat object with inferred trajectory

Examples

if (FALSE) {
obj <- AddTrajectory(
   object = obj,
   trajectory = c(2, 1),
   group.by = "RNA_snn_res.0.2",
   reduction = "dm",
   dims = 1:3,
   use.all = FALSE
)
}