Skip to contents

This function computes and visualizes the average expression of consensus SE marker genes across SEs.

Usage

AverageConsensusMarkers(obj, group.by = "SE", markers = NULL)

Arguments

obj

A Seurat object containing normalized gene expression data.

group.by

Character. Metadata column used to group cells for average expression (default: "SE"). Each group will form one column in the output.

markers

A named list of marker gene sets, where each element corresponds to a spatial ecotype and contains a vector of gene names. If NULL (default), a predefined set of consensus SE marker genes will be used. Marker genes not present in the dataset are automatically excluded. If no markers from a given gene set are detected, NA values are returned for that set.

Value

A list containing:

AvgExp

A scaled numeric matrix of average expression values, where rows correspond to marker gene sets and columns correspond to SEs.

p

A heatmap object generated by HeatmapView visualizing the average expression matrix.

Examples

if (FALSE) { # \dontrun{
# Load Seurat object
obj <- readRDS("WU2161_seurat_obj.rds")

# Normalize data
obj <- NormalizeData(obj)

# Extract normalized expression matrix
normdata <- GetAssayData(obj, layer = "data")

# Recover spatial ecotypes (SEs)
sepreds <- RecoverSE(normdata, celltypes = ctann)
obj <- AddMetaData(obj, sepreds)

# Compute and visualize average expression of SE markers
res <- AverageConsensusMarkers(obj, markers = markers)

# Plot heatmap
draw(res$p)

# Access averaged expression matrix
res$AvgExp
} # }