Skip to contents

Computes Moran's I statistic for multiple genes (rows) against a precomputed spatial weights matrix.

Usage

moranI_cpp(expr_matrix, W)

Arguments

expr_matrix

Numeric matrix (genes x spots)

W

Spatial weights matrix (spots x spots)

Value

Numeric vector of Moran's I values for each gene

Details

This function is optimized using Armadillo linear algebra library. It computes: I = (n/W_sum) * (z' * W * z) / (z' * z) where z = x - mean(x) for each gene.