Builds and validates an [MsSignature]. Derive `catalog_summary` with [msuiter_catalog_summary()] from the [MsCatalog] the signatures were extracted from.
Usage
ms_signature(
signatures,
exposures,
catalog_summary,
engine,
seed,
stability = list(),
k_evidence = data.frame()
)Arguments
- signatures
numeric matrix (channels x signatures) with rownames = channel labels, colnames = signature labels.
- exposures
numeric matrix (signatures x samples) with rownames identical to `colnames(signatures)` and colnames = sample labels.
- catalog_summary
snapshot summary as built by [msuiter_catalog_summary()]: list with fields `n_channels`, `n_samples`, `channel_name`, `channel_hash`, `build`.
- engine
single non-empty string naming the engine used.
- seed
single finite number: the seed behind the result.
- stability
named list of stability evidence (default empty).
- k_evidence
data.frame of K-selection evidence with a `k` column when non-empty (default empty).
Examples
labels <- paste0("CH", 1:4)
counts <- matrix(1:8, 4, 2, dimnames = list(labels, c("S1", "S2")))
cat1 <- ms_catalog(counts, list(name = "SYN4", labels = labels),
c("S1", "S2"), provenance = list(genome = "GRCh38"))
sigs <- matrix(1:8, 4, 2, dimnames = list(labels, c("SIG1", "SIG2")))
exp1 <- matrix(1:4, 2, 2,
dimnames = list(c("SIG1", "SIG2"), c("S1", "S2")))
# The channel hash is always derived from the catalog's labels — never
# forged by hand (see MsCatalog docs).
summary1 <- list(
n_channels = 4L, n_samples = 2L, channel_name = cat1@channels$name,
channel_hash = cat1@channels$hash, build = "GRCh38"
)
ms_signature(sigs, exp1, summary1, engine = "synthetic", seed = 1)
#> <MsSignature> 2 signatures x 2 samples | engine: synthetic | seed: 1