nispace.stats.coloc.rank2d

nispace.stats.coloc.rank2d(arr)[source]

Rank a 2D array column-wise using mid-ranks, skipping NaN per column.

Parameters:

arr (np.ndarray, shape (n_obs, n_features) or (n_obs,), dtype float) – Numba-jitted: must be a plain np.ndarray. 1D input is dispatched to rank1d directly.

Returns:

ranked – Each column’s non-NaN values are ranked independently (mid-ranks for ties); NaN positions are left as NaN. This is the one NaN-tolerant function in this module – unlike rank1d, pearson, mlr, etc., which all require pre-masked input.

Return type:

np.ndarray, same shape as arr, dtype float64

Notes

Used by core/colocalize.py’s _rank_regress to rank X/Y/null arrays for Spearman-style correlation, where different columns may have different NaN patterns.