Calculates the L2 norm (Euclidean norm) of a sigverse
signature or catalogue.
This provides a quantitative measure of how concentrated or dispersed the distribution is.
Usage
sig_l2_norm(signature, value = c("fraction", "count"), scale = FALSE)
Details
For a vector \( x \), the L2 norm is defined as: $$\|x\|_2 = \sqrt{\sum_i x_i^2}$$
Interpretation:
A signature with a uniform distribution has a lower L2 norm.
A peaked signature (one dominant context) has a higher L2 norm.
This is an alternative to entropy-based metrics (like Shannon index), and useful for quickly identifying signatures with strong focal points.
Examples
library(sigstash)
signatures <- sig_load("COSMIC_v3.3.1_SBS_GRCh38")
# Compute L2 norm on fractional signature
sig_l2_norm(signatures[["SBS1"]])
#> [1] 0.4844887
# Compare with a flatter signature
sig_l2_norm(signatures[["SBS3"]])
#> [1] 0.1174484
# Compute on raw counts (requires a catalogue)
cat1 <- sig_reconstruct(signatures[["SBS3"]], n = 100)
sig_l2_norm(cat1, value = "count")
#> [1] 11.74484