Skip to contents

Computes Moran's I along with expected value and standard deviation under the null hypothesis. Optimized with Armadillo vectorization.

Usage

moranI_full_cpp(expr_matrix, W)

Arguments

expr_matrix

Numeric matrix (genes x spots)

W

Spatial weights matrix (spots x spots), row-standardized

Value

List containing observed I, expected I, and standard deviation

Details

This function pre-computes all weight matrix statistics once, then loops over genes efficiently. The main bottleneck is the z * W * z' computation which is O(n^2) per gene.