add_branch_trajectory {dynwrap} | R Documentation |
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.
add_branch_trajectory(
dataset,
branch_network,
branches,
branch_progressions,
...
)
dataset |
A dataset created by |
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 |
The resulting trajectory will always be directed.
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).
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)