xCell2GetLineage: xCell2GetLineage function

View source: R/xCell2GetLineage.R

xCell2GetLineageR Documentation

xCell2GetLineage function

Description

This function identify the descendants and ancestors of each cell type based on the cell ontology tree. If no output file is specified, the function returns a list of cell type dependencies. If an output file is specified, the function writes the cell type dependencies to a TSV file.

Usage

xCell2GetLineage(labels, outFile = NULL)

Arguments

labels

A data frame with four columns: "ont": the cell type ontology as a character (i.e., "CL:0000545" or NA if there is no ontology). "label": the cell type name as a character (i.e., "T-helper 1 cell"). "sample": the cell type sample that match the column name in ref. "dataset": sample's source dataset or subject (can be the same for all sample if no such information).

outFile

An optional output file name to write the cell type dependencies.

Value

A list of cell type dependencies, or a TSV file containing the cell type dependencies if an output file is specified.

Examples

# For detailed example read xCell2 vignette.

# Extract reference matrix
data(dice_demo_ref, package = "xCell2")
dice_ref <- as.matrix(dice_demo_ref@assays@data$logcounts)
colnames(dice_ref) <- make.unique(colnames(dice_ref)) # Make samples samples unique

# Extract reference metadata
dice_labels <- as.data.frame(dice_demo_ref@colData)

# Prepare labels data frame
dice_labels$ont <- NA
dice_labels$sample <- colnames(dice_ref)
dice_labels$dataset <- "DICE"

# Assign cell type ontology (optional but recommended)
dice_labels[dice_labels$label == "B cells", ]$ont <- "CL:0000236"
dice_labels[dice_labels$label == "Monocytes", ]$ont <- "CL:0000576"
dice_labels[dice_labels$label == "NK cells", ]$ont <- "CL:0000623"
dice_labels[dice_labels$label == "T cells, CD8+", ]$ont <- "CL:0000625"
dice_labels[dice_labels$label == "T cells, CD4+", ]$ont <- "CL:0000624"
dice_labels[dice_labels$label == "T cells, CD4+, memory", ]$ont <- "CL:0000897"

# Identify cell type lineage (dependencies)
xCell2::xCell2GetLineage(labels = dice_labels, outFile = "demo_dice_dep.tsv")
# Open `demo_dice_dep.tsv` and check if the lineage assigned to each cell type makes sense.
# Note that "T cells, CD4+, memory" assigned as a descendant of "T cells, CD4+"


AlmogAngel/xCell2 documentation built on Oct. 14, 2024, 4:51 a.m.