smftools.analysis.compute.pearson

smftools.analysis.compute.pearson#

NaN-aware position × position Pearson correlation matrices.

Key functions: nan_pearson_matrix(), make_ticks().

Functions

make_ticks(coords[, n_ticks])

Return evenly spaced tick indices and formatted labels for a coordinate array.

nan_pearson_matrix(X)

NaN-aware position × position Pearson correlation.

smftools.analysis.compute.pearson.nan_pearson_matrix(X)#

NaN-aware position × position Pearson correlation.

Return type:

ndarray

Parameters#

Xnp.ndarray

Shape (n_reads × n_positions); values typically in {0, 1, NaN}. NaN positions are excluded from column means, then zero-filled before the matrix multiply (consistent with the reference EMseq implementation).

Returns#

np.ndarray

Shape (n_positions × n_positions); NaN where denominator is zero.

smftools.analysis.compute.pearson.make_ticks(coords, n_ticks=10)#

Return evenly spaced tick indices and formatted labels for a coordinate array.

Return type:

tuple[ndarray, list[str]]

Parameters#

coords : 1-D array of TSS-centred integer coordinates. n_ticks : number of ticks to generate.

Returns#

indices : integer indices into coords labels : formatted coordinate strings