transferLabelsSeurat: Transfer labels from a reference Seurat object to a query...

View source: R/Seurat.Utils.Metadata.R

transferLabelsSeuratR Documentation

Transfer labels from a reference Seurat object to a query Seurat object

Description

Function to transfer labels from a reference Seurat object to a query Seurat object using anchoring and transfer data methods from the Seurat package. It then visualizes the reference and the combined objects using Uniform Manifold Approximation and Projection (UMAP).

Usage

transferLabelsSeurat(
  query_obj,
  reference_obj,
  reference_path = NULL,
  reference_ident,
  anchors = NULL,
  new_ident = gsub(pattern = "ordered", replacement = "transferred", x = reference_ident),
  predictions_col = "predicted.id",
  predictions_score = sppp(new_ident, "score"),
  save_anchors = TRUE,
  reference_suffix = "REFERENCE.obj",
  plot_suffix = NULL,
  plot_reference = TRUE,
  w = 12,
  h = 9,
  ...
)

Arguments

query_obj

A Seurat object for which the labels are to be transferred.

reference_obj

Alternative to reference_path. If provided, the path is not used to load the reference data.

reference_path

A character string indicating the file path to the reference Seurat object. The path must exist.

reference_ident

A character string specifying the name of the identity class to be used from the reference Seurat object. Default is 'RNA_snn_res.0.3.ordered.ManualNames'.

anchors

A list of anchors obtained from the FindTransferAnchors function. If NULL, the

new_ident

A character string specifying the name of the new identity class to be created in the query Seurat object. Default is obtained by replacing 'ordered' with 'transferred' in reference_ident.

predictions_col

A character string specifying the column in the metadata of the transferred Seurat object containing the transferred labels. Default is 'predicted.id'.

predictions_score

A character string specifying the column in the metadata of the transferred Seurat object containing the scores of the transferred labels. Default is 'transferred.score'.

save_anchors

A logical indicating whether to save the anchors as an RDS file. Default is TRUE.

reference_suffix

A character string to be used as in the subtitle of the reference UMAP plot. Default is 'REFERENCE.obj'.

plot_suffix

A character string to be added to the UMAP with the new identity. Default is NULL.

plot_reference

A logical indicating whether to plot the reference UMAP. Default is TRUE.

w

Width for the saved image. Default: 9

h

Height for the saved image. Default: 12

...

Additional arguments passed to the Seurat.utils::clUMAP function.

Value

The modified query Seurat object with the transferred labels as a new identity class.

Examples

# combined.objX <- transferLabelsSeurat(reference_ident = 'RNA_snn_res.0.3.ordered.ManualNames',
#                                     reference_obj = reference_obj,
#                                     query_obj = combined.obj)


vertesy/Seurat.utils documentation built on Dec. 4, 2024, 5:20 p.m.