
Import multiple cell-level annotation columns as landmark-level celltyping solutions
Source:R/celltype.R
import_cell_annotations.RdScans a cell-level metadata data.frame for categorical columns and
imports each as a named landmark-level celltyping solution via
celltyping Mode B. After importing, users can switch
between solutions with set_active_celltyping.
Usage
import_cell_annotations(x, ...)
# S3 method for class 'TDRObj'
import_cell_annotations(
x,
.cell.meta,
.sample.var,
.celltype.vec = NULL,
.verbose = TRUE,
...
)Arguments
- x
A
TDRObj, Seurat, or SingleCellExperiment object.- ...
Additional arguments passed to methods.
- .cell.meta
A
data.framewith rownames set to cell IDs (original IDs before the tinydenseR sample prefix). Must contain at least the.sample.varcolumn.- .sample.var
Character(1). Column name in
.cell.metaidentifying sample membership.- .celltype.vec
Character(1) or
NULL. If non-NULL, the name of a column in.cell.metathat should be set as the active$idsafter import.- .verbose
Logical (default
TRUE). IfTRUE, prints a message listing the imported columns.
Value
The updated object with imported celltyping solutions stored in
@landmark.annot$celltyping$<column_name>.
Details
This function is designed to be called after get.graph
and before get.map in the pipeline. Because
get.map() has not yet run, .refresh_celltyping() inside
each celltyping() call is a no-op, making the loop efficient.
Column selection criteria
A column in .cell.meta is imported if it is:
characterorfactortype (not numeric, logical, integer, etc.)Not the
.sample.varcolumnHas more than 1 unique non-NA value
Has fewer unique non-NA values than total cells (excludes ID-like columns)
Column name is not
"ids"(reserved by the multi-solution system)
Examples
if (FALSE) { # \dontrun{
tdr.obj <- setup.tdr.obj(.cells, .meta) |>
get.landmarks() |>
get.graph()
# Import all categorical cell-level columns
tdr.obj <- import_cell_annotations(tdr.obj,
.cell.meta = cell_metadata,
.sample.var = "sample_id",
.celltype.vec = "cell_type_l1"
)
# Check what was imported
list_celltyping_solutions(tdr.obj)
# Switch to a different annotation
tdr.obj <- set_active_celltyping(tdr.obj, "cell_type_l2")
} # }