Learn R Programming

SVG (version 1.0.0)

moranI_full_cpp: Fast Moran's I with Full Statistics

Description

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)

Value

List containing observed I, expected I, and standard deviation

Arguments

expr_matrix

Numeric matrix (genes x spots)

W

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

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.