Learn R Programming

dynwrap (version 1.2.4)

add_dimred_projection: Constructs a trajectory by projecting cells within a dimensionality reduction

Description

A dimensionality reduction of cells and milestones is used, along with the milestone network, to project cells onto the nearest edge. Optionally, a cell grouping can be given which will restrict the edges on which a cell can be projected.

Usage

add_dimred_projection(
  dataset,
  milestone_ids = NULL,
  milestone_network,
  dimred,
  dimred_milestones,
  grouping = NULL,
  ...
)

Value

A trajectory object

Arguments

dataset

A dataset created by wrap_data() or wrap_expression()

milestone_ids

The ids of the milestones in the trajectory. Type: Character vector.

milestone_network

The network of the milestones. Type: Data frame(from = character, to = character, length = numeric, directed = logical).

dimred

Can be

  • A function which will perform the dimensionality reduction, see dyndimred::list_dimred_methods()

  • A matrix with the dimensionality reduction, with cells in rows and dimensions (comp_1, comp_2, ...) in columns

dimred_milestones

An optional dimensionality reduction of the milestones. A matrix with milestones in rows and components (comp_1, comp_2, ...) in columns

This will be automatically calculated if project_trajectory = TRUE

grouping

A grouping of the cells, can be a named vector or a dataframe with group_id and cell_id

...

extra information to be stored in the wrapper.

Examples

Run this code
library(tibble)
dataset <- wrap_data(cell_ids = letters)

milestone_network <- tibble::tibble(
  from = c("A", "B", "B"),
  to = c("B", "C", "D"),
  directed = TRUE,
  length = 1
)
milestone_network
dimred <- matrix(
  runif(length(dataset$cell_ids) * 2),
  ncol = 2,
  dimnames = list(dataset$cell_ids, c("comp_1", "comp_2"))
)
dimred
dimred_milestones <- matrix(
  runif(2*4),
  ncol = 2,
  dimnames = list(c("A", "B", "C", "D"), c("comp_1", "comp_2"))
)
dimred_milestones
trajectory <- add_dimred_projection(
  dataset,
  milestone_network = milestone_network,
  dimred = dimred,
  dimred_milestones = dimred_milestones
)

# for plotting the result, install dynplot
#- dynplot::plot_graph(trajectory)

Run the code above in your browser using DataLab