Creating a TI method: Wrapping trajectories


Common trajectory model

dynwrap always represents trajectories in the same way, as illustrated here with a tree trajectory

milestone_network <- tribble(
  ~from, ~to, ~length, ~directed,
  "A", "B", 1, FALSE,
  "B", "C", 2, FALSE,
  "B", "D", 1, FALSE,
  "C", "E", 1, FALSE,
  "C", "F", 1.5, FALSE
milestone_network$from <- paste0("Milestone_", milestone_network$from)
milestone_network$to <- paste0("Milestone_", milestone_network$to)
milestone_ids <- paste0("Milestone_", c("A", "B", "C", "D", "E", "F"))
cell_ids <- paste0("Cell_", letters)
progressions <- milestone_network %>% 
  sample_n(length(cell_ids), replace = TRUE, weight = length) %>% 
    cell_id = cell_ids,
    percentage = runif(n())
  ) %>% 
  select(cell_id, from, to, percentage)
milestone_percentages <- dynwrap::convert_progressions_to_milestone_percentages(cell_ids, milestone_ids, milestone_network, progressions) %>% arrange(cell_id, milestone_id)
head(milestone_percentages, 10)
head(progressions, 10)
divergence_regions <- tribble(
  ~divergence_id, ~milestone_id, ~is_start,
  "Divergence_1", "Milestone_B", TRUE,
  "Divergence_1", "Milestone_C", FALSE,
  "Divergence_1", "Milestone_D", FALSE

Direct wrapping

These three objects (with either milestone percentages or progressions) are enough to form a trajectory using add_trajectory.

trajectory <- wrap_data(cell_ids = cell_ids) %>% 
    milestone_network = milestone_network, 
    milestone_percentages = milestone_percentages,
    divergence_regions = divergence_regions

Indirect wrapping

Often, you don't want to directly output the milestone network and percentages, but want to output an alternative representation that is converted by dynwrap to the common representation:

Check out the reference documentation for an overview and examples of the different wrappers

Try the dynwrap package in your browser

Any scripts or data that you put into this service are public.

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