add_branch_trajectory: Construct a trajectory given its branch network and the...

View source: R/wrap_add_branch_trajectory.R

add_branch_trajectoryR Documentation

Construct a trajectory given its branch network and the pseudotime of the cells on one of the branches.

Description

The branch network is converted to a milestone network by giving each branch a start and end milestone. If two branches are connected in the branch network, the end milestone of branch 1 and start milestone of branch 2 will be merged.

Usage

add_branch_trajectory(
  dataset,
  branch_network,
  branches,
  branch_progressions,
  ...
)

Arguments

dataset

A dataset created by wrap_data() or wrap_expression()

branch_network

The network between branches, a dataframe with a from and to branch identifier

branches

The length and directedness of the branches, a dataframe with the branch identifier (branch_id), the length of the branch (length) and whether it is directed

branch_progressions

Specifies the progression of a cell along a transition in the branch network. A dataframe containing the cell_id, branch_id and its progression along the edge (percentage, between 0 and 1)

...

extra information to be stored in the trajectory

Details

The resulting trajectory will always be directed.

Value

A trajectory object

Examples

dataset <- wrap_data(cell_ids = letters)

branch_network <- tibble::tibble(from = c("A", "A"), to = c("B", "C"))
branch_network
branches <- tibble::tibble(branch_id = c("A", "B", "C"), length = 1, directed = TRUE)
branches
branch_progressions <- tibble::tibble(
  cell_id = dataset$cell_ids,
  branch_id = sample(branches$branch_id, length(dataset$cell_ids), replace = TRUE),
  percentage = runif(length(dataset$cell_ids))
)
branch_progressions

trajectory <- add_branch_trajectory(
  dataset,
  branch_network,
  branches,
  branch_progressions
)

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

dynwrap documentation built on July 26, 2023, 5:15 p.m.