Learn R Programming

easybio (version 1.2.2)

check_marker: Verify and Explore Cell Type Annotations

Description

A post-analysis function that helps to verify and explore the automated cell type annotations generated by matchCellMarker2. It retrieves marker genes for the top-matching cell types of specified clusters, allowing for deeper inspection of the annotation results.

Usage

check_marker(marker, cl = c(), topcellN = 2, cis = FALSE)

Value

A named list. Each name in the list is a cell type, and each element is a character vector of its corresponding marker genes.

Arguments

marker

A data.table object, which is the result of a call to matchCellMarker2(). This object must contain the attributes set by matchCellMarker2 for the function to work correctly.

cl

A numeric or character vector specifying the cluster IDs to be inspected.

topcellN

An integer. For each cluster in cl, the function will retrieve markers for the top topcellN cell type annotations. Defaults to 2.

cis

A logical value that switches the function's mode. See Details. Defaults to FALSE.

Details

The function provides two distinct modes for marker retrieval, controlled by the cis parameter. This allows the user to answer two different, important questions:

  • cis = FALSE (Default): "Is the annotation correct?" This mode answers the question by fetching the canonical markers for the annotated cell type from the reference database (via get_marker). It automatically uses the same filtering criteria (species, tissue, etc.) that were used in the original matchCellMarker2 call, ensuring consistency.

  • cis = TRUE: "Why was this annotation made?" This mode answers the question by extracting the local markers from the user's own data (i.e., the differentially expressed genes from the marker input) that led to the annotation. This helps understand the evidence behind the match.

See Also

matchCellMarker2 to generate the input for this function. get_marker which is used internally when cis = FALSE. plotSeuratDot to visualize the results.

Examples

Run this code
if (FALSE) {
library(easybio)
data(pbmc.markers)

# Step 1: Generate cell type annotations
matched_cells <- matchCellMarker2(pbmc.markers, n = 50, spc = "Human")

# Step 2: Verify the annotation for cluster 0.
# Let's check the top annotation (topcellN = 1).

# Question 1: "Is cluster 0 really a CD4-positive T cell?
# Let's see the canonical markers for it."
# Note: We don't need to pass 'spc' here; it's retrieved from matched_cells.
reference_markers <- check_marker(matched_cells, cl = 0, topcellN = 1)
print(reference_markers)
# Now you would typically use these markers in Seurat::DotPlot() or Seurat::FeaturePlot()

# Question 2: "Which of my genes made the algorithm think cluster 0
# is a CD4-positive T cell?"
local_markers <- check_marker(matched_cells, cl = 0, topcellN = 1, cis = TRUE)
print(local_markers)
}

Run the code above in your browser using DataLab