Compute Normalized Correlation for Permutation Results
Source:R/D_spatial_CCA_permutation.R
computeNormalizedCorrelationPermu.RdCalculates the normalized correlation for each permutation, enabling p-value calculation by comparing observed values to the null distribution.
Arguments
- object
A
CoProobject with permutation results fromrunSkrCCAPermu()- tol
Tolerance for approximate SVD calculation (default: 1e-4)
Value
The CoPro object with permutation normalized correlations
stored in @normalizedCorrelationPermu
Details
The normalized correlation for each permutation is calculated using the same formula as the observed data:
$$NC = \frac{s_1^T K_{12} s_2}{||s_1|| \cdot ||s_2|| \cdot ||K_{12}||_2}$$
where \(s_1\) and \(s_2\) are cell scores, \(K_{12}\) is the kernel matrix, and \(||K_{12}||_2\) is the spectral norm.
Examples
if (FALSE) { # \dontrun{
# After running permutation testing
br <- computeNormalizedCorrelationPermu(br)
# Extract permutation values and calculate p-value
permu_values <- sapply(br@normalizedCorrelationPermu,
function(x) x$normalizedCorrelation[1])
observed <- max(getNormCorr(br)$normalizedCorrelation)
# One-sided p-value (testing if observed > permutation)
p_value <- mean(permu_values >= observed)
} # }