Transfer labels from a reference Seurat object
transfer_labels.RdReference-based annotation wrapping Seurat's reference-mapping workflow
(Seurat::FindTransferAnchors() + Seurat::TransferData()) to annotate
query with labels (cell type, or any other categorical metadata) from an
already integrated and annotated reference object. Optionally also projects
query onto the reference's UMAP via Seurat::MapQuery().
Usage
transfer_labels(
query,
ref,
query_label_col,
ref_label_col,
query_assay,
ref_assay,
normalization,
ref_reduction = "pca",
num_dim,
anchor_reduction = "pcaproject",
ref_umap = FALSE,
verbose = TRUE
)Arguments
- query
Query Seurat object.
- ref
Reference Seurat object - already integrated and annotated.
- query_label_col
Metadata column name added to
queryfor the transferred labels.- ref_label_col
Metadata column in
refholding the labels to transfer (cell type, or any other category).- query_assay
Assay in
queryto use for anchor finding."RNA"(log-normalized) or"SCT", depending on howquerywas built. No default, like the params below: this andref_assay/normalization/num_dimall describe how a specific object was built.- ref_assay
Assay in
refto use for anchor finding.- normalization
Normalization method shared by
refandquery("log"/"LogNormalize"or"sct"/"SCT").Seurat::FindTransferAnchors()takes one value for both objects, sorefandquerymust actually share a method.- ref_reduction
Reduction in
refto projectqueryonto.- num_dim
Number of dimensions to use for anchor finding and label transfer.
- anchor_reduction
Dimensional reduction workflow
Seurat::FindTransferAnchors()uses to find anchors.- ref_umap
If
TRUE, also runsSeurat::MapQuery()and adds a"ref.umap"reduction toquery, projecting it ontoref's UMAP.refneeds a UMAP built withreturn.model = TRUE, which this function does not check for -MapQuery()errors on its own if it is missing.- verbose
Print progress messages.
Value
query with query_label_col (a factor) added to its metadata,
and a "ref.umap" reduction added if ref_umap = TRUE. Also writes
the predictions table (cell/predicted.id/prediction.score.max) to
annotation/annotation-transfer-label-<query_label_col>.csv.gz, and a
dr-<reduction>-<query_label_col>.png UMAP colored by the transferred
labels for each of "umap"/"ref.umap" already present on query.