add_trajectory {dynwrap}R Documentation

Construct a trajectory given its milestone network and milestone percentages or progressions

Description

Construct a trajectory given its milestone network and milestone percentages or progressions

Usage

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)

Arguments

dataset

A dataset created by wrap_data() or wrap_expression()

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 infer_trajectory() or add_trajectory()

Value

The dataset object with trajectory information, including:

Examples

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)

[Package dynwrap version 1.2.4 Index]