Infer spatial vector fields describing communication directions.
Compute spatial vector fields representing the average direction of cell-cell communication signals from senders to receivers.
Usage
communication_direction(
seurat_obj,
database_name,
lr_pair = NULL,
pathway_name = NULL,
spatial_coords = NULL,
k = 5L,
bandwidth = NULL,
kernel = c("exp", "lorentz"),
normalize = TRUE,
verbose = TRUE
)Arguments
- seurat_obj
Seurat object with COMMOTR results from
spatial_communication.- database_name
Name of database used in spatial_communication.
- lr_pair
Specific LR pair name (e.g., "Tgfb1-Tgfbr1_Tgfbr2"). If NULL, uses pathway_name.
- pathway_name
Pathway name. Used if lr_pair is NULL. If both NULL, uses "total".
- spatial_coords
Spatial coordinates: NULL (auto-detect), character (reduction name), or matrix.
- k
Number of nearest neighbors for spatial smoothing (default: 5).
- bandwidth
Bandwidth for kernel smoothing. If NULL, estimated from k.
- kernel
Smoothing kernel: "exp" (exponential, default) or "lorentz".
- normalize
Logical, normalize vectors to unit length (default: TRUE).
- verbose
Logical, print progress messages (default: TRUE).
Details
For each cell, the function computes:
Sender vector field: weighted average direction toward receiver cells
Receiver vector field: weighted average direction from sender cells
The weights are communication matrix values smoothed with a spatial kernel.
The resulting vector fields can be visualized using
plot_cell_communication.
Examples
if (FALSE) { # \dontrun{
# Compute direction for TGFb pathway
seurat_obj <- communication_direction(
seurat_obj,
database_name = "CellChat",
pathway_name = "TGFb",
k = 5
)
# Visualize
plot_cell_communication(seurat_obj, "CellChat", pathway_name = "TGFb")
} # }