Skip to contents

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)

Arguments

signature

A sigverse signature or catalogue data.frame.

value

Character string, either "fraction" or "count", indicating which column to compute the norm on.

scale

Logical. If TRUE, divides the norm by the number of elements to enable easier comparison across different signature sizes.

Value

A single numeric value representing the L2 norm.

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