| Title: | Infer Cell-Cell Communication from Spatial Transcriptomics |
|---|---|
| Description: | Identifies cell-cell communication hotspots in spatial transcriptomics data using bivariate Local Moran's I statistics on hexagonally binned cells. Provides functions for spatial weighting, ligand-receptor pair filtering, hotspot detection, and visualisation of sender-receiver cell-type interactions. |
| Authors: | Yunshun Chen [aut, cre], Lei Qin [aut], Lizhong Chen [aut] |
| Maintainer: | Yunshun Chen <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.2.0 |
| Built: | 2026-06-03 09:44:34 UTC |
| Source: | https://github.com/cran/blisa |
Tools for spatial cell-cell communication analysis of spatial transcriptomics data.
Generic function for running BLISA (Bivariate Local Indicator of Spatial
Association). Dispatches on the class of x:
blisa.default accepts a pre-binned gene-by-bin count
matrix and a matching bins polygon object.
blisa.SpatialExperiment accepts a cell-level
SpatialExperiment object and bins cells into hexagonal tiles
internally via hexBinCells before running the analysis.
blisa(x, ...) ## Default S3 method: blisa( x, bins, LR_df = NULL, bin_size = 50, dmax = 250, nsim = 999, p_cutoff = 0.05, min_ligand = 10, min_receptor = 10, min_cells = 1, n_cells_col = NA, annotation_col = "annotation", default_mode = "diffuse", diffuse_category = c("Secreted Signaling", "Non-protein Signaling"), species = c("human", "mouse"), genes = NULL, counts_by_group = NULL, ... ) ## S3 method for class 'SpatialExperiment' blisa(x, bin_size = 50, LR_df = NULL, group = "cell_type", genes = NULL, ...)blisa(x, ...) ## Default S3 method: blisa( x, bins, LR_df = NULL, bin_size = 50, dmax = 250, nsim = 999, p_cutoff = 0.05, min_ligand = 10, min_receptor = 10, min_cells = 1, n_cells_col = NA, annotation_col = "annotation", default_mode = "diffuse", diffuse_category = c("Secreted Signaling", "Non-protein Signaling"), species = c("human", "mouse"), genes = NULL, counts_by_group = NULL, ... ) ## S3 method for class 'SpatialExperiment' blisa(x, bin_size = 50, LR_df = NULL, group = "cell_type", genes = NULL, ...)
x |
A gene-by-bin count matrix (for |
... |
Additional arguments passed to the relevant method. |
bins |
An |
LR_df |
Data frame of ligand-receptor pairs with columns
|
bin_size |
Numeric. Width of each hexagonal bin in coordinate units
(e.g. microns). Passed to |
dmax |
Numeric. Maximum distance for diffuse-mode neighbours.
Default |
nsim |
Integer. Number of permutations for Moran's I significance.
Default |
p_cutoff |
Numeric. P-value threshold for High-High hotspots.
Default |
min_ligand |
Numeric. Minimum ligand count threshold. Default |
min_receptor |
Numeric. Minimum receptor count threshold.
Default |
min_cells |
Integer. Bins with fewer cells are excluded from
Moran's I and assigned neutral statistics (p = 1, LISA = 0).
Ignored when |
n_cells_col |
Character or |
annotation_col |
Character. Column in |
default_mode |
Character. CCC mode assigned to LR pairs whose
annotation does not match |
diffuse_category |
Character vector of annotation categories treated as diffuse signalling. |
species |
Character. Which CellChatDB to download when
|
genes |
Character vector of gene names to consider when matching
ligand-receptor pairs. Defaults to |
counts_by_group |
Named list of gene-by-bin count matrices, one per
group level (e.g. cell type), as returned by |
group |
Character. Column name in |
A list; see individual method documentation for details.
An object of class blisa with four components:
Data frame of BLISA results for each LR pair, including
ccc_mode, sig_numbers, sig_index, sig_pval,
all_pval, all_lisa, all_quadrant, and original
columns from LR_df. all_quadrant is a character vector
of spdep::hotspot quadrant labels ("High-High",
"Low-Low", etc.) for every bin; non-tested bins are NA.
Bin-level sf object of hexagonal polygons.
Spatial weights list from computeSpatialWeights.
NULL unless counts_by_group is supplied,
in which case a wide data frame of interaction scores from
runCCI: rows are "Sender->Receiver" group pairs,
columns are LR pairs.
blisa(default): Method for a gene-by-bin count matrix.
blisa(SpatialExperiment): Method for a cell-level SpatialExperiment object.
Bins cells into hexagonal tiles via hexBinCells then
delegates to blisa.default.
Builds queen (nearby) and distance-decay (diffuse) spatial weight matrices
from a bin-level sf object, excluding isolated bins and optionally
excluding low-cell bins. A second-pass isolation check further removes bins
that become isolated after the initial subset.
computeSpatialWeights( bins, bin_size = 50, dmax = 250, min_cells = 1, n_cells_col = NA )computeSpatialWeights( bins, bin_size = 50, dmax = 250, min_cells = 1, n_cells_col = NA )
bins |
An |
bin_size |
Numeric. Bin spacing used to define queen adjacency
( |
dmax |
Numeric. Maximum distance for diffuse-mode neighbours. |
min_cells |
Integer. Minimum cell count for a bin to be
included. Ignored when |
n_cells_col |
Character or |
A list with:
Spatial weights list for nearby (queen) mode.
Spatial weights list for diffuse (distance-decay) mode.
Integer indices of bins used in queen-mode Moran.
Integer indices of bins used in diffuse-mode Moran.
Integer indices of original queen-mode isolates.
Integer indices of original diffuse-mode isolates.
Integer indices of bins excluded for low cell counts.
Full (unsubset) neighbour list for nearby mode, indexed over all bins.
Full (unsubset) neighbour list for diffuse mode, indexed over all bins.
Retains only LR pairs where at least one bin/spot has counts at or above
min_ligand for every ligand subunit and min_receptor for every
receptor subunit.
filterLRpairs( counts, min_ligand = 10, min_receptor = 10, LR_df = NULL, species = c("human", "mouse") )filterLRpairs( counts, min_ligand = 10, min_receptor = 10, LR_df = NULL, species = c("human", "mouse") )
counts |
Gene-by-bin count matrix (dense or sparse). Row names must be gene symbols. |
min_ligand |
Numeric. Minimum count threshold for ligand genes. At least one bin must meet or exceed this value. Default 10. |
min_receptor |
Numeric. Minimum count threshold for receptor genes. At least one bin must meet or exceed this value. Default 10. |
LR_df |
Data frame of ligand-receptor pairs with columns
|
species |
Character. Which CellChatDB to download when |
A subset of LR_df containing only pairs that pass the
expression thresholds for both ligand and receptor.
Aggregates single-cell spatial data into hexagonal bins and returns a
bin-level count matrix together with a matching sf polygon object,
ready to pass directly to blisa.default.
hexBinCells( coords_df, counts_matrix, bin_size = 50, min_cells = 1, group = NULL )hexBinCells( coords_df, counts_matrix, bin_size = 50, min_cells = 1, group = NULL )
coords_df |
Data frame or matrix with columns |
counts_matrix |
Gene-by-cell count matrix (dense or sparse). Row names
must be gene symbols; column names must be cell IDs present in
|
bin_size |
Numeric. Approximate width of each hexagonal bin in
coordinate units (e.g. microns). Analogous to |
min_cells |
Integer. Bins containing fewer than |
group |
Factor or character vector of length |
A list with:
Gene-by-bin sparse count matrix (all cells combined).
Column i corresponds to row i of bins.
An sf object of hexagonal bin polygons with an
n_cells column recording how many cells fall in each bin. Row
order matches the columns of counts_matrix.
(Only when group is supplied.) A named list
of gene-by-bin sparse matrices, one per cell-type level, with the same
bin order as counts_matrix.
Test if an object is a blisa object
is.blisa(x)is.blisa(x)
x |
Any R object. |
Logical.
Generic function. Draws a clustered heatmap (via ComplexHeatmap)
with rows as Sender Receiver cell-type pairs and columns
as LR pairs. Row annotations colour-code the sender and receiver cell types.
plotCCI(x, ...) ## S3 method for class 'blisa' plotCCI( x, top_lr = 20, top_pairs = 30, sender = NULL, receiver = NULL, colors = NULL, colours = NULL, ... ) ## Default S3 method: plotCCI( x, top_lr = 20, top_pairs = 30, sender = NULL, receiver = NULL, colors = NULL, colours = NULL, ... )plotCCI(x, ...) ## S3 method for class 'blisa' plotCCI( x, top_lr = 20, top_pairs = 30, sender = NULL, receiver = NULL, colors = NULL, colours = NULL, ... ) ## Default S3 method: plotCCI( x, top_lr = 20, top_pairs = 30, sender = NULL, receiver = NULL, colors = NULL, colours = NULL, ... )
x |
A |
... |
Additional arguments passed to the relevant method. |
top_lr |
Integer or |
top_pairs |
Integer or |
sender |
Character vector or |
receiver |
Character vector or |
colors |
Named character vector mapping cell-type names to colours,
used for the sender/receiver row annotations. When |
colours |
Alias for |
Invisibly returns the Heatmap object.
plotCCI(blisa): Method for a blisa object. Extracts
CCI_scores and delegates to plotCCI.default. Stops with an
informative error if CCI_scores is NULL.
plotCCI(default): Method for a CCI scores data frame (e.g. the
CCI_scores slot of a blisa object).
plotCCILR for a sender-by-receiver heatmap of a
single LR pair; plotCCIsummary for an aggregated
sender-by-receiver heatmap across all LR pairs.
Generic function. Reshapes the CCI data frame into a receiver-by-sender cell-type matrix for one selected LR pair and draws a clustered heatmap.
plotCCILR(x, ...) ## S3 method for class 'blisa' plotCCILR(x, index = 1, ligand = NULL, receptor = NULL, ...) ## Default S3 method: plotCCILR(x, lr_pair, ...)plotCCILR(x, ...) ## S3 method for class 'blisa' plotCCILR(x, index = 1, ligand = NULL, receptor = NULL, ...) ## Default S3 method: plotCCILR(x, lr_pair, ...)
x |
A |
... |
Additional arguments passed to the relevant method. |
index |
Integer. Row index into |
ligand |
Character. Ligand gene symbol. When both |
receptor |
Character. Receptor gene symbol. Must be supplied together
with |
lr_pair |
Character. Column name in the CCI scores data frame
corresponding to the ligand-receptor pair to visualise
(e.g. |
A Heatmap object.
plotCCILR(blisa): Method for a blisa object. The LR pair is
selected by index (default 1, the top-ranked pair) unless both
ligand and receptor are supplied, in which case the matching
row is located automatically and index is ignored. Stops with an
informative error if CCI_scores is NULL or the selected LR
pair has no significant hotspots.
plotCCILR(default): Method for a CCI scores data frame (e.g. the
CCI_scores slot of a blisa object). The LR pair is selected
by column name via lr_pair.
plotCCI for an overview heatmap across all LR pairs;
plotCCIsummary for an aggregated sender-by-receiver heatmap.
For a selected ligand-receptor pair, identifies the dominant interacting cell-type pair at each significant hotspot bin and draws a spatial map of the tissue coloured by those pairs. Receiver cells are those inside hotspot bins; sender cells are drawn from the immediate neighbourhood.
plotCCIspatial( x, counts_by_group, index = 1, ligand = NULL, receptor = NULL, top_pairs = 30 )plotCCIspatial( x, counts_by_group, index = 1, ligand = NULL, receptor = NULL, top_pairs = 30 )
x |
A |
counts_by_group |
Named list of gene-by-bin count matrices, one per
cell type. Typically the |
index |
Integer. Row index into |
ligand |
Character. Ligand gene symbol. When both |
receptor |
Character. Receptor gene symbol. Must be supplied together
with |
top_pairs |
Integer. Maximum number of distinct cell-type pairs to show
in the legend; remaining pairs are grouped as |
A ggplot object.
plotHotspots for a significance-based spatial map of
hotspot bins.
Generic function. Aggregates CCI scores across all (or the top-ranked)
ligand-receptor pairs and draws a clustered receiver-by-sender heatmap, one
cell per Sender Receiver combination.
plotCCIsummary(x, ...) ## S3 method for class 'blisa' plotCCIsummary( x, top_lr = NULL, sender = NULL, receiver = NULL, agg_fun = sum, ... ) ## Default S3 method: plotCCIsummary( x, top_lr = NULL, sender = NULL, receiver = NULL, agg_fun = sum, ... )plotCCIsummary(x, ...) ## S3 method for class 'blisa' plotCCIsummary( x, top_lr = NULL, sender = NULL, receiver = NULL, agg_fun = sum, ... ) ## Default S3 method: plotCCIsummary( x, top_lr = NULL, sender = NULL, receiver = NULL, agg_fun = sum, ... )
x |
A |
... |
Additional arguments passed to the relevant method. |
top_lr |
Integer or |
sender |
Character vector or |
receiver |
Character vector or |
agg_fun |
Function used to aggregate scores across LR pairs for each
Sender |
A Heatmap object.
plotCCIsummary(blisa): Method for a blisa object. Stops with an
informative error if CCI_scores is NULL.
plotCCIsummary(default): Method for a CCI scores data frame (e.g. the
CCI_scores slot of a blisa object).
plotCCILR for a per-LR-pair version of this plot;
plotCCI for a heatmap with LR pairs as columns.
Generic function. Plots each bin coloured by significance status: empty, non-significant, or significant hotspot (continuous gradient of -log10 p-value or 1 - p-value).
plotHotspots(x, ...) ## S3 method for class 'blisa' plotHotspots( x, index = 1, ligand = NULL, receptor = NULL, log_pval = TRUE, p_cutoff = NULL, ... )plotHotspots(x, ...) ## S3 method for class 'blisa' plotHotspots( x, index = 1, ligand = NULL, receptor = NULL, log_pval = TRUE, p_cutoff = NULL, ... )
x |
A |
... |
Additional arguments passed to the method. |
index |
Integer. Row index into |
ligand |
Character. Ligand gene symbol. When both |
receptor |
Character. Receptor gene symbol. Must be supplied together
with |
log_pval |
Logical. If |
p_cutoff |
Numeric or |
A ggplot object.
plotHotspots(blisa): Method for a blisa object.
Generic function for ranking LR pairs. Dispatches on the class of x:
plotLRrank.blisa accepts a blisa object and uses its
LR_results slot directly.
plotLRrank.data.frame accepts the LR_results data
frame directly.
plotLRrank(x, ...) ## S3 method for class 'blisa' plotLRrank(x, top = 30, pt_size = 4, flip = FALSE, ...) ## S3 method for class 'data.frame' plotLRrank(x, top = 30, pt_size = 4, flip = FALSE, ...)plotLRrank(x, ...) ## S3 method for class 'blisa' plotLRrank(x, top = 30, pt_size = 4, flip = FALSE, ...) ## S3 method for class 'data.frame' plotLRrank(x, top = 30, pt_size = 4, flip = FALSE, ...)
x |
A |
... |
Additional arguments passed to the relevant method. |
top |
Integer or |
pt_size |
Numeric. Point size passed to |
flip |
Logical. When |
A ggplot object.
plotLRrank(blisa): Method for a blisa object. Extracts
LR_results and delegates to plotLRrank.data.frame.
plotLRrank(data.frame): Method for a data frame of LR results (e.g. the
LR_results slot of a blisa object).
Generic function for scoring cell-cell interactions. Dispatches on the
class of x:
runCCI.blisa accepts a blisa object. If
CCI_scores are already present and overwrite = FALSE
(the default), the object is returned unchanged. Set
overwrite = TRUE with a counts_by_group to recompute and
replace existing scores. If no scores exist, counts_by_group
must be supplied and scores are computed and attached.
runCCI.default performs the raw computation given a
blisa object and a counts_by_group list, returning only
the scores data frame. Used internally by runCCI.blisa and
blisa.default.
runCCI(x, ...) ## S3 method for class 'blisa' runCCI(x, counts_by_group = NULL, overwrite = FALSE, ...) ## Default S3 method: runCCI(x, counts_by_group, ...)runCCI(x, ...) ## S3 method for class 'blisa' runCCI(x, counts_by_group = NULL, overwrite = FALSE, ...) ## Default S3 method: runCCI(x, counts_by_group, ...)
x |
A |
... |
Additional arguments passed to the relevant method. |
counts_by_group |
Named list of gene-by-bin sparse count matrices, one
per group level (e.g. cell type). Typically the |
overwrite |
Logical. If |
See individual method documentation.
runCCI.blisa: the input blisa object with
CCI_scores populated (a wide data frame – rows are
"Sender->Receiver" group pairs, columns are LR pairs).
runCCI.default: a data frame with "Sender->Receiver"
row names and one column per significant LR pair containing the
interaction score 0.5 * log2(receiver * sender + 1).
runCCI(blisa): Method for a blisa object. If CCI_scores
are already present and overwrite = FALSE (the default), the object
is returned unchanged. Set overwrite = TRUE with a
counts_by_group to recompute and replace existing scores. If no
scores exist, counts_by_group must be supplied and scores are
computed and attached to x$CCI_scores.
runCCI(default): Default method. Performs the raw CCI computation and
returns only the scores data frame. Typically called internally; use
runCCI.blisa to compute and attach scores to a blisa object
in one step.