Signal correlation and similarity¶
Compare matching profiles or scalar features from different channels after merging the feature tables. The implementation compares the supplied numerical values; it does not establish molecular interaction or correct misregistration.
ic.batch_calculate_signal_correlation_features(
ic.merged_features, ["C2", "C3"],
[(["normalized_axial_intensity"],
["pearson", "spearman", "manders"])],
)
The dataframe must contain both C2_<feature> and C3_<feature>.
The helper considers channel combinations and writes columns using the
underlying function name, for example
C2_C3_normalized_axial_intensity_pearson_correlation_coefficient.
Selector |
Output suffix |
Calculation / interpretation |
|---|---|---|
|
|
Uncentered sum(a*b) / sqrt(sum(a²)*sum(b²)); equal-length profiles; zero energy is undefined. |
|
|
Linear correlation via scipy.stats.pearsonr; constant profiles are undefined. |
|
|
2 × (fraction of positive products of mean-centered signals - 0.5). |
|
|
Finite scalar a/b; zero denominator gives NaN. |
|
|
Rank correlation via scipy.stats.spearmanr. |
|
|
Rank association via scipy.stats.kendalltau. |
|
|
Biased sample distance correlation using separately centered pairwise distances; 0–1; constant profiles give NaN. |
|
|
Sample covariance np.cov(a,b)[0,1]; retains product intensity units. |
|
|
Zero-lag mean-centered dot product divided by n*std(a)*std(b). Supply NumPy arrays for subtraction. |
|
|
Absolute difference of scipy.stats.entropy values; meaningful for nonnegative distributions. |
|
|
Absolute kurtosis(a)/kurtosis(b); zero denominator gives NaN. |
|
|
Product of the two profile skewness statistics. |
|
|
Absolute difference in adjacent sign-change counts; raw profiles are not mean-centered. |
|
|
Largest FFT magnitude ratio, excluding the DC component; zero denominator gives NaN. |
|
|
Ratio of summed squared FFT magnitudes, including DC; zero denominator gives NaN. |
|
|
Shared-bin, separately probability-normalized histogram overlap; 0–1; unequal lengths allowed. |
|
|
dot(a,b)/(norm(a)*norm(b)); zero norm is undefined. |
Interpretation and input checks¶
Most methods require lists or arrays with more than one sample. ratio
expects finite scalars and returns NaN for a zero denominator. Invalid, empty,
nonfinite, or unconvertible inputs are initially marked missing. Most paired
profile metrics require aligned arrays of equal length; their checks are not
uniform, so supply compatible one-dimensional profiles.
Constant profiles can make correlation undefined. Pearson and rank methods may return NaN with a numerical-library warning; zero norms invalidate cosine or overlap denominators. Distance correlation explicitly returns NaN for constant profiles. Histogram intersection uses common bins and separately normalized sample counts, and can compare unequal-length profiles.
The Li ICQ implementation multiplies the conventional centered fraction by 2,
giving its own -1 to 1 scale. The manders selector calculates an uncentered
overlap coefficient; it is not a pair of thresholded Manders M1/M2 fractions.
Covariance retains units of the input product. Entropy requires meaningful
nonnegative distributions; negative background-subtracted profiles need careful
interpretation. See bactoscoop.signalcorrelation.SignalCorrelation.