Skip to contents

Writes 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.

Usage

set_bonsai_embedding(object, tree, name = "bonsai")

Arguments

object

SingleCells or MetaCells class.

tree

A BonsaiTree, from bonsai_sc() on this object.

name

String. Name of the embedding.

Value

The object with the embedding added.

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)