add_dimred_projection {dynwrap} | R Documentation |
A dimensionality reduction of cells and milestones is used, along with the milestone network, to project cells onto the nearest edge. Optionally, a cell grouping can be given which will restrict the edges on which a cell can be projected.
add_dimred_projection(
dataset,
milestone_ids = NULL,
milestone_network,
dimred,
dimred_milestones,
grouping = NULL,
...
)
dataset |
A dataset created by |
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). |
dimred |
Can be
|
dimred_milestones |
An optional dimensionality reduction of the milestones. A matrix with milestones in rows and components (comp_1, comp_2, ...) in columns This will be automatically calculated if |
grouping |
A grouping of the cells, can be a named vector or a dataframe with group_id and cell_id |
... |
extra information to be stored in the wrapper. |
The dataset object with trajectory information, including:
milestone_ids: The names of the milestones, a character vector.
milestone_network: The network between the milestones, a dataframe with the from milestone, to milestone, length of the edge, and whether it is directed.
divergence_regions: The regions between three or more milestones where cells are diverging, a dataframe with the divergence id (divergence_id), the milestone id (milestone_id) and whether this milestone is the start of the divergence (is_start)
milestone_percentages: For each cell its closeness to a particular milestone, a dataframe with the cell id (cell_id), the milestone id (milestone_id), and its percentage (a number between 0 and 1 where higher values indicate that a cell is close to the milestone).
progressions: For each cell its progression along a particular edge of the milestone_network. Contains the same information as milestone_percentages. A dataframe with cell id (cell_id), from milestone, to milestone, and its percentage (a number between 0 and 1 where higher values indicate that a cell is close to the to milestone and far from the from milestone).
library(tibble)
dataset <- wrap_data(cell_ids = letters)
milestone_network <- tibble::tibble(
from = c("A", "B", "B"),
to = c("B", "C", "D"),
directed = TRUE,
length = 1
)
milestone_network
dimred <- matrix(
runif(length(dataset$cell_ids) * 2),
ncol = 2,
dimnames = list(dataset$cell_ids, c("comp_1", "comp_2"))
)
dimred
dimred_milestones <- matrix(
runif(2*4),
ncol = 2,
dimnames = list(c("A", "B", "C", "D"), c("comp_1", "comp_2"))
)
dimred_milestones
trajectory <- add_dimred_projection(
dataset,
milestone_network = milestone_network,
dimred = dimred,
dimred_milestones = dimred_milestones
)
# for plotting the result, install dynplot
#- dynplot::plot_graph(trajectory)