Learn R Programming

dynwrap (version 1.2.1)

add_cluster_graph: Constructs a trajectory using a cell grouping and a network between groups. Will use an existing grouping if it is present in the dataset.

Description

A trajectory in this form will rarely be useful, given that cells are only placed at the milestones themselves, but not on the edges between milestones. A better alternative might be to project the cells using a dimensionality reduction, see add_dimred_projection().

Usage

add_cluster_graph(
  dataset,
  milestone_network,
  grouping = NULL,
  explicit_splits = FALSE,
  ...
)

Arguments

dataset

A dataset created by wrap_data() or wrap_expression()

milestone_network

A network of milestones.

grouping

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

explicit_splits

Whether to make splits specific by adding a starting node. For example: A->B, A->C becomes A->X, X->B, X->C

...

extra information to be stored in the wrapper.

Value

The dataset object with trajectory information, including:

  • milestone_ids: The names of the milestones, a character vector.

  • milestone_network: The network between the milestones, a dataframe with the from milestone, to milestone, length of the edge, and whether it is directed.

  • divergence_regions: The regions between three or more milestones where cells are diverging, a dataframe with the divergence id (divergence_id), the milestone id (milestone_id) and whether this milestone is the start of the divergence (is_start)

  • milestone_percentages: For each cell its closeness to a particular milestone, a dataframe with the cell id (cell_id), the milestone id (milestone_id), and its percentage (a number between 0 and 1 where higher values indicate that a cell is close to the milestone).

  • progressions: For each cell its progression along a particular edge of the milestone_network. Contains the same information as milestone_percentages. A dataframe with cell id (cell_id), from milestone, to milestone, and its percentage (a number between 0 and 1 where higher values indicate that a cell is close to the to milestone and far from the from milestone).

Examples

Run this code
# NOT RUN {
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
grouping <- sample(c("A", "B", "C", "D"), length(dataset$cell_ids), replace = TRUE)
grouping
trajectory <- add_cluster_graph(dataset, milestone_network, grouping)

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

Run the code above in your browser using DataLab