Generic function for running BLISA (Bivariate Local Indicator of Spatial
Association). Dispatches on the class of x:
blisa.defaultaccepts a pre-binned gene-by-bin count matrix and a matchingbinspolygon object.blisa.SpatialExperimentaccepts a cell-levelSpatialExperimentobject and bins cells into hexagonal tiles internally viahexBinCellsbefore running the analysis.
Usage
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,
fast = TRUE,
cpu_threads = 4L,
verbose = FALSE,
...
)
# S3 method for class 'SpatialExperiment'
blisa(
x,
bin_size = 50,
LR_df = NULL,
group = "cell_type",
genes = NULL,
min_cells = 1,
min_total_counts = 10,
verbose = FALSE,
...
)Arguments
- x
A gene-by-bin count matrix (for
blisa.default) or a cell-levelSpatialExperimentobject (forblisa.SpatialExperiment).- ...
Additional arguments passed to the relevant method.
- bins
An
sfobject of bin polygons. Row order must match the column order ofx.- LR_df
Data frame of ligand-receptor pairs with columns
ligand.symbolandreceptor.symbol. WhenNULL, CellChatDB for the chosenspeciesis downloaded automatically.- bin_size
Numeric. Width of each hexagonal bin in coordinate units (e.g. microns). Passed to
hexBinCellsandcomputeSpatialWeights. Default50.- dmax
Numeric. Maximum distance for diffuse-mode neighbours. Default
250.- nsim
Integer. Number of permutations for Moran's I significance. Default
999.- p_cutoff
Numeric. P-value threshold for High-High hotspots. Default
0.05.- min_ligand
Numeric. Minimum ligand count threshold. Default
10.- min_receptor
Numeric. Minimum receptor count threshold. Default
10.- min_cells
Integer. Bins with fewer cells are dropped during binning by
hexBinCells. Default1.- n_cells_col
Character or
NA. Column inbinsholding per-bin cell counts used formin_cellsfiltering. Set toNAto skip (default).- annotation_col
Character. Column in
LR_dfspecifying interaction category used for communication-mode assignment. Default"annotation".- default_mode
Character. CCC mode assigned to LR pairs whose annotation does not match
diffuse_category. Default"diffuse".- diffuse_category
Character vector of annotation categories treated as diffuse signalling.
- species
Character. Which CellChatDB to download when
LR_df = NULL. One of"human"(default) or"mouse".- genes
Character vector of gene names to consider when matching ligand-receptor pairs. Defaults to
rownames(x)(all genes in theSpatialExperimentobject).- counts_by_group
Named list of gene-by-bin count matrices, one per group level (e.g. cell type), as returned by
hexBinCellswhengroupis supplied. When provided,runCCIis called automatically after the BLISA loop and its output is included in the result asCCI_scores. DefaultNULL.- fast
Logical. When
TRUE(default), usesfastLISA::local_moran_bv(a fast C/OpenMP backend) for the bivariate local Moran's I computation. WhenFALSE, uses the originalspdep::localmoran_bv+spdep::hotspotpipeline.- cpu_threads
Integer. Number of OpenMP threads used by
fastLISA::local_moran_bv. Only used whenfast = TRUE. Ignored on platforms without OpenMP. Default4L.- verbose
Logical. If
TRUE, print progress messages. DefaultFALSE(silent).- group
Character. Column name in
colData(x)to use as the grouping variable (e.g. cell type) for per-group bin aggregation and downstream CCI analysis viarunCCI. If the column is not found incolData(x), a message is issued and CCI is skipped. Default"cell_type".- min_total_counts
Numeric. Bins whose total counts (summed over all genes) fall below this threshold are dropped during binning by
hexBinCells. Set to0to disable. Default10.
Value
A list; see individual method documentation for details.
An object of class blisa with four components:
- LR_results
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 fromLR_df.all_quadrantis a character vector of hotspot quadrant labels ("High-High","Low-Low", etc.) for every bin; non-tested bins areNA.- bins
Bin-level
sfobject of hexagonal polygons.- spatial_weights
Spatial weights list from
computeSpatialWeights.- CCI_scores
NULLunlesscounts_by_groupis supplied, in which case a wide data frame of interaction scores fromrunCCI: rows are"Sender->Receiver"group pairs, columns are LR pairs.
Methods (by class)
blisa(default): Method for a gene-by-bin count matrix.blisa(SpatialExperiment): Method for a cell-level SpatialExperiment object. Bins cells into hexagonal tiles viahexBinCellsthen delegates toblisa.default.
Examples
if (FALSE) { # \dontrun{
# Download and cache the example Xenium breast cancer dataset (~21 MB)
data_url <- paste0(
"https://github.com/ChenLaboratory/example_data/releases/",
"download/v1.0.0/spe_xenium_bc_s1rep1.rds"
)
cache_dir <- tools::R_user_dir("blisa", "cache")
data_file <- file.path(cache_dir, "spe_xenium_bc_s1rep1.rds")
if (!file.exists(data_file)) {
dir.create(cache_dir, recursive = TRUE, showWarnings = FALSE)
download.file(data_url, data_file, mode = "wb")
}
spe <- readRDS(data_file)
# blisa.SpatialExperiment method: bins cells, runs LISA, scores CCI
result <- blisa(spe, bin_size = 50, group = "cell_type")
result
} # }