add_root {dynwrap}R Documentation

Root the trajectory

Description

Designates a milestone as root, and changes the direction of any edges so that they move away from the specified root (if flip_edges=TRUE, default).

Usage

add_root(
  trajectory,
  root_cell_id = trajectory$root_cell_id,
  root_milestone_id = trajectory$root_milestone_id,
  flip_edges = TRUE
)

add_root_using_expression(
  trajectory,
  features_oi,
  expression_source = "expression"
)

is_rooted(trajectory)

remove_root(trajectory)

Arguments

trajectory

The trajectory as created by infer_trajectory() or add_trajectory()

root_cell_id

The root cell id, not required if root_milestone_id is given

root_milestone_id

The root milestone id, not required if root_cell_id is given

flip_edges

Whether to flip edges which are going in the other direction compared to the root

features_oi

The feature ids which will be used to root

expression_source

Source of the expression, either a string or a matrix

Details

A root_cell_id can also be specified, and the root milestone will be determined as the milestone with the closest geodesic distance to this cell.

Value

A trajectory, with a root_milestone_id and with adapted milestone_network and progressions based on the rooting.

Examples

# add a root using a root cell
trajectory <- example_trajectory
trajectory <- add_root(
  trajectory,
  root_cell_id = sample(trajectory$cell_ids, 1)
)
trajectory$root_milestone_id

# add a root using a root milestone id
trajectory <- add_root(
  trajectory,
  root_milestone_id = "milestone_end"
)
trajectory$root_milestone_id
trajectory$milestone_network


[Package dynwrap version 1.2.4 Index]