Main function to extract cell-to-cell communication edges from expression data. This function identifies potential ligand-receptor mediated interactions between cell clusters based on expression patterns.
Usage
ExtractEdges(
object,
annotation = NULL,
species = "human",
id_type = "symbol",
database = "lrc2p",
assay = NULL,
slot = "data",
cluster_col = NULL,
min_cells = 3,
workers = 0,
verbose = TRUE
)Arguments
- object
Input data: Seurat object, expression matrix, or file path
- annotation
Cell annotation (required if object is matrix/file). Should be a data.frame with columns 'cell' and 'cluster', or a named vector.
- species
Species name (default: "human"). See
supported_species.- id_type
Gene ID type in the expression matrix (default: "symbol"). See
supported_id_types.- database
Ligand-receptor database: "lrc2p" (default, literature-supported), "lrc2a" (all pairs including putative), or a custom data.frame with columns 'ligand' and 'receptor'.
- assay
Assay name for Seurat objects (default: DefaultAssay).
- slot
Data slot for Seurat objects (default: "data").
- cluster_col
Column name in metadata for cluster identity (Seurat only).
- min_cells
Minimum number of cells per cluster (default: 3).
- workers
Number of parallel workers (0 = auto, 1 = sequential).
- verbose
Print progress messages (default: TRUE).
Value
A list of class "NOVAResult" containing:
edges: data.table of all detected edges with expression and specificity
ligand_stats: Ligand expression statistics per cluster
receptor_stats: Receptor expression statistics per cluster
cluster_mapping: Cell to cluster mapping
lr_pairs: Ligand-receptor pairs used
parameters: Analysis parameters
Details
The function computes the following metrics for each ligand-receptor pair between each sending and target cluster:
- Detection rate
Proportion of cells expressing the gene (expression > 0)
- Mean expression
Average expression across all cells in the cluster
- Total expression
Sum of expression across all cells in the cluster
- Specificity
Proportion of total expression in this cluster relative to the sum across all clusters. Calculated as:
mean_in_cluster / sum(mean_in_all_clusters)- Edge weight
Product of ligand and receptor expression/specificity
Examples
if (FALSE) { # \dontrun{
# From Seurat object
result <- ExtractEdges(seurat_obj, species = "mouse")
# From expression matrix
result <- ExtractEdges(expr_matrix, annotation = cell_ann, species = "human")
# With custom LR database
my_lr <- data.frame(ligand = c("TGFB1", "IL6"), receptor = c("TGFBR1", "IL6R"))
result <- ExtractEdges(seurat_obj, database = my_lr)
} # }