loi_perm: Permutation Test for LoI

View source: R/loi.R

loi_permR Documentation

Permutation Test for LoI

Description

Performs a permutation test using row/column permutation to assess whether the E2Tree reconstruction is significantly better than expected by chance.

Usage

loi_perm(O, O_hat, n_perm = 999, conf.level = 0.95, seed = NULL)

Arguments

O

Proximity matrix from the ensemble model (n x n)

O_hat

Proximity matrix estimated by E2Tree (n x n)

n_perm

Number of permutations (default: 999)

conf.level

Confidence level for intervals (default: 0.95)

seed

Random seed for reproducibility. Default is NULL.

Details

The test uses simultaneous row/column permutation of \hat{O}: for each replicate, a random permutation \pi of \{1, \ldots, n\} is drawn and \hat{O}^\pi = \hat{O}[\pi, \pi] is computed. This preserves the block-diagonal structure of \hat{O} while breaking the correspondence with O.

The null hypothesis is: the E2Tree labeling is unrelated to the ensemble structure. Under H1 (good reconstruction), the observed nLoI should be significantly lower than the null distribution.

P-values include the +1 correction of Phipson & Smyth (2010).

Value

An object of class "loi_perm" containing:

observed

Observed nLoI value and decomposition (loi object)

statistic

Observed nLoI value (scalar)

p.value

Test p-value (one-sided, less)

ci

Permutation-based confidence interval for nLoI

null_dist

Null distribution of nLoI values

null_mean

Mean of the null distribution

null_sd

Standard deviation of the null distribution

z_stat

Standardized Z statistic

n_perm

Number of permutations

conf.level

Confidence level

Examples


n <- 50
O <- matrix(runif(n^2, 0.3, 1), n, n)
O <- (O + t(O)) / 2; diag(O) <- 1
O_hat <- O + matrix(rnorm(n^2, 0, 0.05), n, n)
O_hat <- pmin(pmax((O_hat + t(O_hat)) / 2, 0), 1); diag(O_hat) <- 1

result <- loi_perm(O, O_hat, n_perm = 199, seed = 42)
print(result)
summary(result)
plot(result)



e2tree documentation built on May 15, 2026, 5:06 p.m.