Skip to content

divergence regions when rooting #148

@rcannood

Description

@rcannood

What to do when rooting a trajectory with divergence regions? Should we remove the region and project the cell to the closest point in the trajectory? Or do we flip the divergence region and change the edges in the trajectory? We could make this a parameter of add_root().

Example code
library(tidyverse)
library(dyno)

cell_ids <- c("a", "b", "c", "d", "e", "f")
milestone_ids <- c("W", "X", "Y", "Z", "A")

milestone_network <- tribble(
  ~from, ~to, ~length, ~directed,
  "W", "X", 2, TRUE,
  "X", "Z", 4, TRUE,
  "X", "Y", 3, TRUE,
  "Z", "A", 5, TRUE
)

divergence_regions <- tribble(
  ~divergence_id, ~milestone_id, ~is_start,
  "XYZ", "X", TRUE,
  "XYZ", "Y", FALSE,
  "XYZ", "Z", FALSE
)

milestone_percentages <- tribble(
  ~cell_id, ~milestone_id, ~percentage,
  "a", "W", .9,
  "a", "X", .1,
  "b", "W", .2,
  "b", "X", .8,
  "c", "X", .8,
  "c", "Z", .2,
  "d", "X", .2,
  "d", "Y", .7,
  "d", "Z", .1,
  "e", "X", .3,
  "e", "Y", .2,
  "e", "Z", .5,
  "f", "Z", .8,
  "f", "A", .2
)

trajectory <- wrap_data(
  id = "test",
  cell_ids = cell_ids
) %>% add_trajectory(
  milestone_ids = milestone_ids,
  milestone_network = milestone_network,
  milestone_percentages = milestone_percentages,
  divergence_regions = divergence_regions
)

g1 <- plot_graph(trajectory, label_milestones = TRUE)

trajectory2 <- trajectory %>% add_root(root_milestone_id = "Y")
g2 <- plot_graph(trajectory2, label_milestones = TRUE)

patchwork::wrap_plots(g1, g2)

plot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions