View source: R/wrap_add_trajectory.R
add_trajectory | R Documentation |
Construct a trajectory given its milestone network and milestone percentages or progressions
add_trajectory(
dataset,
milestone_ids = NULL,
milestone_network,
divergence_regions = NULL,
milestone_percentages = NULL,
progressions = NULL,
allow_self_loops = FALSE,
...
)
is_wrapper_with_trajectory(trajectory)
dataset |
A dataset created by |
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). |
divergence_regions |
A data frame specifying the divergence regions between milestones (e.g. a bifurcation). Type: Data frame(divergence_id = character, milestone_id = character, is_start = logical). |
milestone_percentages |
A data frame specifying what percentage milestone each cell consists of. Type: Data frame(cell_id = character, milestone_id = character, percentage = numeric). |
progressions |
Specifies the progression of a cell along a transition in the milestone_network. Type: Data frame(cell_id = character, from = character, to = character, percentage = numeric). |
allow_self_loops |
Whether to allow self loops Type: Logical |
... |
extra information to be stored in the dataset |
trajectory |
The trajectory as created by |
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).
library(dplyr)
library(tibble)
dataset <- wrap_data(cell_ids = letters)
milestone_network <- tribble(
~from, ~to, ~length, ~directed,
"A", "B", 1, FALSE,
"B", "C", 2, FALSE,
"B", "D", 1, FALSE,
)
milestone_network
progressions <- milestone_network %>%
sample_n(length(dataset$cell_ids), replace = TRUE, weight = length) %>%
mutate(
cell_id = dataset$cell_ids,
percentage = runif(n())
) %>%
select(cell_id, from, to, percentage)
progressions
divergence_regions <- tribble(
~divergence_id, ~milestone_id, ~is_start,
"1", "A", TRUE,
"1", "B", FALSE,
"1", "C", FALSE
)
divergence_regions
trajectory <- add_trajectory(
dataset,
milestone_network = milestone_network,
divergence_regions = divergence_regions,
progressions = progressions
)
# for plotting the result, install dynplot
#- dynplot::plot_graph(trajectory)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.