| linf.cells | R Documentation |
Assigns each row to the column achieving its maximum.
For each sample (row) of a nonnegative matrix, identifies the dominant
feature as the column with the maximum value. Samples with the same dominant
feature form a depth-1 dominance sample set. Ties are broken by the first
maximum (as in max.col(..., ties.method = "first")). Rows that are
all zero are assigned NA.
Feature IDs default to colnames(S); if absent, synthetic IDs
"V1", "V2", ..., "Vp" are generated. Display labels default to the
feature IDs unless feature.labels is supplied. To guarantee a 1-1
mapping between columns and both IDs and labels, duplicates are
disambiguated via make.unique().
linf.cells(
S,
feature.ids = NULL,
feature.labels = NULL,
tie.method = c("first", "random", "error"),
return.value = FALSE,
backend = c("auto", "dense", "sparse")
)
S |
Numeric matrix (samples x features), typically L-infinity-normalized. |
feature.ids |
Optional character vector of stable feature identifiers,
length |
feature.labels |
Optional character vector of display labels, length
|
tie.method |
Character. How to resolve ties during dominant-feature assignment. |
return.value |
Logical. If |
backend |
Character. Matrix backend to use: |
A list with components:
index: integer index of the dominant column per sample (NA for all-zero rows)
id: dominant feature ID per sample (NA for all-zero rows)
label: dominant column label per sample (NA for all-zero rows)
id.levels: full feature ID set after make.unique(..., sep = "_")
levels: full column label set after make.unique(..., sep = "_")
observed.id.levels: subset of id.levels that appear in id
observed.levels: subset of levels that appear in label
value: row maxima (only when return.value = TRUE)
normalize.linf, linf.csts
# Basic example with named columns
S <- rbind(
a = c(A = 10, B = 5, C = 0), # -> A
b = c(A = 0, B = 0, C = 0), # -> NA
c = c(A = 1, B = 4, C = 4) # tie -> first max: B
)
out <- linf.cells(S)
out$index
out$label
out$levels
out$observed.levels
# Unnamed columns (synthetic labels V1..Vp), duplicate names disambiguated
T <- matrix(c(0,2, 3,1, 0,0), nrow = 3, byrow = TRUE)
colnames(T) <- c("X", "X") # duplicates -> X, X_1
linf.cells(T)$levels
# With L-infinity normalization in a pipeline
M <- normalize.linf(S)
linf.cells(M)$label
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.