Computes Moran's I statistic for multiple genes (rows) against a precomputed spatial weights matrix.
moranI_cpp(expr_matrix, W)Numeric vector of Moran's I values for each gene
Numeric matrix (genes x spots)
Spatial weights matrix (spots x spots)
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.