Truncated dominant community state types with configurable low-support handling
Source:R/linf.R
linf.csts.RdForms provisional depth-1 dominance sample sets from the dominant feature
of each sample and then applies the minimum support threshold n0.
Sets with fewer than n0 samples are handled according to
low.freq.policy:
"pure": retain only sets with support >=n0as named dCSTs and collapse all low-support sets intorare.label."absorb": reassign each low-support sample to the retained state with the largest value among the retained features (ties handled bytie.method).
Usage
linf.csts(
S,
feature.ids = NULL,
feature.labels = NULL,
n0 = 50,
low.freq.policy = c("pure", "absorb"),
rare.label = "RARE_DOMINANT",
tie.method = c("first", "random", "error"),
return.diagnostics = FALSE,
return.landmarks = FALSE,
landmark.types = c("endpoint.max", "endpoint.min"),
landmark.view = c("active", "pure", "absorb"),
backend = c("auto", "dense", "sparse")
)Arguments
- S
Numeric matrix (samples x features), typically L-infinity relatives.
- feature.ids
Optional character vector of stable feature identifiers, length
ncol(S).- feature.labels
Optional character vector of display labels, length
ncol(S).- n0
Integer >= 1. Minimum support required to retain a dominance sample set.
- low.freq.policy
Character. One of
"pure"or"absorb". Default:"pure".- rare.label
Character scalar used when
low.freq.policy = "pure". Default:"RARE_DOMINANT".- tie.method
Character. Tie handling passed to
linf.dominant.features()and used during absorb reassignment ("first", "random", "error"). Positive ties use original matrix column order for"first"on both backends. If all retained values are zero, absorption uses the retained state with greatest reference support (then lexical label order), regardless oftie.method.- return.diagnostics
Logical. If TRUE, return reassignment diagnostics.
- return.landmarks
Logical. If TRUE, attach a depth-1 landmark summary computed by
linf.landmarks.- landmark.types
Character vector of landmark types passed to
linf.landmarkswhenreturn.landmarks = TRUE.- landmark.view
Character. Landmark view passed to
linf.landmarkswhenreturn.landmarks = TRUE.- backend
Character. Matrix backend to use:
"auto","dense", or"sparse". The default"auto"preserves sparse input and otherwise uses the dense path.
Value
List with:
depth1.feature.index,depth1.feature.id,depth1.feature.label: active depth-1 assignmentlineage.id,lineage.label: active leaf-lineage assignmentpolicy-specific variants of the depth-1 and leaf-lineage fields, ending in
.pureor.absorblineage.ids,lineage.labels: active hierarchy, plus policy-specific.pureand.absorbhierarchiesdepth: current hierarchy depthretained.feature.indices,retained.feature.ids,retained.feature.labelsprovisional.feature.index,provisional.feature.id,provisional.feature.labelfeature.ids,feature.labelssize.table,size.table.idn0,low.freq.policy,rare.labeldiagnostics(ifreturn.diagnostics = TRUE)landmarks(ifreturn.landmarks = TRUE)
Examples
X <- rbind(
s1 = c(A = 10, B = 2, C = 1),
s2 = c(A = 9, B = 3, C = 1),
s3 = c(A = 1, B = 10, C = 2),
s4 = c(A = 1, B = 9, C = 3),
s5 = c(A = 1, B = 2, C = 10)
)
fit <- linf.csts(normalize.linf(X), n0 = 2, low.freq.policy = "pure")
table(fit$lineage.label)
#>
#> A B RARE_DOMINANT
#> 2 2 1
fit$retained.feature.ids
#> [1] "A" "B"