This function calculates a signature score for cell clusters based on the embeddings of cells and genes in a Seurat object. The score measures how well the genes linked to specific clusters are separated in the embedding space. The function also supports returning a weighted mean score across all clusters.

SigScore(seu, reduction, label, gclink, return.mean = TRUE)

Arguments

seu

A Seurat object containing the single-cell RNA-seq data.

reduction

A character string specifying the name of the dimensional reduction to use (e.g., "caesar").

label

A character string specifying the column name in the Seurat object's metadata that contains the cell type or cluster labels.

gclink

A data frame with two columns: `gene` and `cluster`, where `gene` corresponds to gene names and `cluster` corresponds to the associated cell cluster.

return.mean

Logical, indicating whether to return the weighted mean signature score across all clusters. If FALSE, returns the score for each gene-cluster pair. Default is TRUE.

Value

If return.mean = TRUE, a numeric value representing the weighted mean signature score across all clusters. If return.mean = FALSE, a numeric vector containing the signature score for each gene-cluster pair.

Details

The function computes the distance between gene embeddings and cell embeddings using a custom distance metric. It then calculates a score for each gene-cluster pair by evaluating how well the genes associated with a specific cluster are ordered in proximity to the cells of that cluster. The score is normalized between 0 and 1, where 1 indicates perfect separation.

Examples

library(Seurat)
#> Attaching SeuratObject
data(toydata)

seu <- toydata$seu

seu$cluster <- Idents(seu)

gclink <- data.frame(
    gene = c(
        "FBLN1", "CCDC80", "LYPD3", "MLPH", "HOXD9", "EGFL7",
        "HAVCR2", "IGSF6", "KRT5", "KRT6B", "CD79A", "DERL3",
        "CAV1", "AVPR1A", "CD3G", "CD3D"
    ),
    cluster = c(
        "CAFs", "CAFs", "Cancer Epithelial", "Cancer Epithelial",
        "Endothelial", "Endothelial", "Myeloid", "Myeloid",
        "Normal Epithelial", "Normal Epithelial", "Plasmablasts",
        "Plasmablasts", "PVL", "PVL", "T-cells", "T-cells"
    )
)

score <- SigScore(
    seu, reduction = "caesar", label = "cluster", gclink = gclink,
    return.mean = TRUE
)
print(score)
#>           [,1]
#> [1,] 0.8684347

score <- SigScore(
    seu, reduction = "caesar", label = "cluster",
    gclink = gclink, return.mean = FALSE
)
print(score)
#>  [1] 0.8313747 0.7728953 0.9773859 0.9773091 0.8145074 0.8172510 0.5958643
#>  [8] 0.6352022 0.5899346 0.7191827 0.8536427 0.7750554 0.6115290 0.8379278
#> [15] 0.5547680 0.6330431