nispace.stats.coloc.rank1d

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

Rank a 1D array using mid-ranks (average rank) for tied values.

Parameters:

arr (np.ndarray, shape (n,), dtype float) – Numba-jitted: must be a plain 1D np.ndarray, not a list/Series. Does not handle NaN – strip NaN entries before calling (see e.g. rank2d, which does this per-column). Constant arrays receive identical ranks, i.e. zero variance, which yields NaN when the ranks are subsequently correlated.

Returns:

ranked

Return type:

np.ndarray, shape (n,), dtype float64

Notes

Used internally by rank2d (per non-NaN column) and by corr (when rank=True). core/colocalize.py’s Spearman path ranks data via rank2d and then calls plain pearson on the ranks, rather than calling rank1d/corr directly.