Plot a trajectory as a graph
plot_graph(
trajectory,
color_cells = c("auto", "none", "grouping", "feature", "milestone", "pseudotime"),
color_milestones = c("auto", "given", "cubeHelix", "Set3", "rainbow"),
grouping = NULL,
groups = NULL,
feature_oi = NULL,
pseudotime = NULL,
expression_source = "expression",
milestones = NULL,
milestone_percentages = NULL,
size_trajectory = 3,
size_milestones = 8,
alpha_cells = 1,
size_cells = 2.5,
border_radius_percentage = 0.1,
arrow = grid::arrow(length = grid::unit(1, "cm"), type = "closed"),
label_milestones = dynwrap::is_wrapper_with_milestone_labelling(trajectory),
plot_milestones = FALSE,
adjust_weights = FALSE
)The trajectory as created by infer_trajectory() or add_trajectory()
How to color the cells.
"auto": Try to figure out how to color cells depending on whether
one of the grouping, feature_io, milestones or pseudotime parameters are defined.
"none": Cells are not coloured.
"grouping": Cells are coloured according to a grouping (e.g. clustering).
Either the grouping parameter or trajectory$grouping must be a named character vector.
"feature": Cells are coloured according to the values of a given feature (e.g. gene expression).
Either the expression_source parameter or get_expression(trajectory) must be a matrix.
Parameter feature_oi must also be defined.
"milestone" (recommended): Cells are coloured according their position in the trajectory. The positioning of the
cells are determined by parameter milestone_percentages or else by trajectory$milestone_percentages. The colours
of the milestones can be determined automatically or can be specified by passing a tibble containing character columns
milestone_id and color (See add_milestone_coloring() for help in constructing this object).
"pseudotime": Cells are coloured according to the pseudotime value from the root.
Which palette to use for colouring the milestones
auto: Determine colours automatically. If color is already specified in
milestones tibble, this will be used. Otherwise, the colour scheme is determined by
milestone_palette_list$auto.
given: The milestones object already contains a column color.
cubeHelix: Use the rje::cubeHelix() palette.
Set3: Use the RColorBrewer::brewer.pal(name = "Set3") palette.
rainbow: Use the grDevices::rainbow() palette.
A grouping of the cells (e.g. clustering) as a named character vector.
A tibble containing character columns group_id and color. If NULL, this object is inferred from the grouping itself.
The name of a feature to use for colouring the cells.
The pseudotime from the root of the trajectory to the cells as a named numeric vector.
Source of the feature expression, defaults to get_expression(trajectory).
Tibble containing the column milestone_id (character).
If color_milestones is set to "given", this tibble should also contain a column
color (character), containing colour hex codes (e.g. "#123456").
The milestone percentages.
The size of the transition lines between milestones.
The size of milestones.
The alpha of the cells.
The size of the cells.
The fraction of the radius that is used for the border.
The type and size of arrow in case of directed trajectories. Set to NULL to remove arrow altogether.
How to label the milestones. Can be TRUE (in which case the labels within the trajectory will be used), "all" (in which case both given labels and milestone_ids will be used), a named character vector, or FALSE
Whether to plot the milestones.
Whether or not to rescale the milestone network weights
A graph ggplot of a trajectory.
# NOT RUN {
data(example_disconnected)
plot_graph(example_disconnected)
plot_graph(example_disconnected, color_cells = "pseudotime")
plot_graph(
example_disconnected,
color_cells = "grouping",
grouping = dynwrap::group_onto_nearest_milestones(example_disconnected)
)
data(example_tree)
plot_graph(example_tree)
# }
Run the code above in your browser using DataLab