
Store the leaf coordinates of a Bonsai tree as an embedding
set_bonsai_embedding.RdWrites the 2D position of every leaf, cell or metacell, into the object's embeddings, so the usual embedding plots can use it. The tree has to have been built over the object's current cells (or all of its metacells), in the same order.
Arguments
- object
SingleCellsorMetaCellsclass.- tree
A
BonsaiTree, frombonsai_sc()on this object.- name
String. Name of the embedding.
Examples
# Bonsai leaf coordinates next to the other embeddings
sc <- demo_single_cells(
prepped = FALSE,
syn_data_params = params_sc_synthetic_data(n_cells = 200L, n_genes = 50L)
)
tree <- bonsai_sc(sc, .verbose = FALSE)
sc <- set_bonsai_embedding(sc, tree)
get_available_embeddings(sc)
#> [1] "bonsai"
unlink(sc@dir_data, recursive = TRUE, force = TRUE)