Skip to contents

Computes cosine similarity between each pair of signatures in a sigverse signature collection

Usage

sig_cosine_similarity(signature1, signature2, assume_sensible_input = FALSE)

Arguments

signature1, signature2

sigverse signature data.frames. See sigshared::example_signature().

assume_sensible_input

A logical flag indicating whether to skip validation checks for the input signatures. Enabling this option can significantly speed up the cosine similarity calculation by assuming that both inputs are valid signature objects and that their channels are already sorted. This option should only be used when performance is critical and these assumptions can be verified upstream.

Value

a number between 0 and 1 representing cosine similarity

Examples

library(sigstash)

# Load a signature collection
signatures <- sig_load("COSMIC_v3.3.1_SBS_GRCh38")

# Compute cosine similarity between two signatures
sig_cosine_similarity(signatures[["SBS1"]], signatures[["SBS2"]])
#> [1] 0.02031489