Skip to contents

Compute simple ligand-receptor co-expression scores across groups and visualize as a heatmap.

Usage

VisLigRec(
  object,
  assay = NULL,
  lr_table,
  group.by = "seurat_clusters",
  palette = "C",
  tile_alpha = 0.8
)

Arguments

object

A Seurat object; required.

assay

Assay name. Default: Seurat::DefaultAssay(object).

lr_table

Data frame with columns ligand and receptor; required.

group.by

Metadata column for groups (e.g., clusters). Default: "seurat_clusters".

palette

Viridis palette option for color/fill. Default: "C".

tile_alpha

Tile alpha. Default: 0.8.

Value

A list with scores (data.frame) and plot (heatmap ggplot).

Author

benben-miao

Examples

obj <- SeuratVisProExample(
    n_cells = 300,
    n_genes = 1000,
    n_clusters = 10,
    seed = 123,
    genes_mt = "^MT-",
    neighbor_dims = 10,
    cluster_res = 0.5,
    umap_dims = 10,
    spatial = FALSE)
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#> 
#> Number of nodes: 300
#> Number of edges: 4508
#> 
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9485
#> Number of communities: 10
#> Elapsed time: 0 seconds

lr <- data.frame(
  ligand = paste0('G', 1:5),
  receptor = paste0('G', 6:10))

res <- VisLigRec(
  obj,
  assay = NULL,
  lr_table = lr,
  group.by = "seurat_clusters",
  palette = "C",
  tile_alpha = 0.8)

res$plot

head(res$scores)
#> # A tibble: 6 × 3
#>   source target score
#>   <chr>  <chr>  <dbl>
#> 1 g0     g0      74.8
#> 2 g0     g1      80.5
#> 3 g0     g2      74.3
#> 4 g0     g3      74.0
#> 5 g0     g4      72.1
#> 6 g0     g5      71.4