Skip to contents

Permutation-Based Enrichment Test of Profiles Within Clusters

Usage

cluster_profile_enrich(cell_profile_prob, cluster_label, permute_n = 300)

Arguments

cell_profile_prob

A matrix of profile probabilities (cells × profiles).

cluster_label

A vector of cluster identities (length = number of rows in `cell_profile_prob`).

permute_n

Integer. Number of permutations to perform (default: 300).

Value

A list with two elements:

prob

Observed profile mass per cluster (same format as `cluster_profile_mass()`)

pval

Matrix of empirical p-values (1-sided) indicating profile enrichment

Details

Tests whether specific profiles are statistically enriched in transcriptional clusters using permutation testing. Compares the observed profile mass per cluster to a null distribution generated by random label permutations.

Examples

set.seed(42)
profile_probs <- matrix(runif(200), nrow = 50, ncol = 4)
profile_probs <- profile_probs / rowSums(profile_probs)
clusters <- sample(1:5, 50, replace = TRUE)
result <- cluster_profile_enrich(profile_probs, clusters, permute_n = 100)
head(result$pval)
#>     V1   V2   V3   V4
#> 1 0.39 0.22 0.95 0.26
#> 2 0.51 0.53 0.06 0.92
#> 3 0.47 0.08 0.60 0.69
#> 4 0.82 0.45 0.14 0.58
#> 5 0.23 0.98 0.72 0.04