
Resolve final cell labels via majority vote
Source:R/method-L4_cellvoter_assemble.R
resolve_consensus_labels.RdCombines multiple annotation inputs and two tie-breakers to determine a single consensus label for each cell.
Usage
resolve_consensus_labels(
label_list,
method_names,
tie_breaker_names,
unassigned_label = "Unknown",
ordered_tiebreak = TRUE,
allow_even_split = FALSE
)Arguments
- label_list
Named list of factors or character vectors, one entry per cell. Must contain all names in
method_namesandtie_breaker_names, and all elements must be the same length.- method_names
Character vector. Names within
label_listrepresenting the primary voting methods.- tie_breaker_names
Character vector of length 2. Names within
label_listto use as ordered fallbacks.- unassigned_label
Character scalar. Label assigned when no consensus is reached. Defaults to
"Unknown".- ordered_tiebreak
Logical scalar. When
TRUE(default), tie-breakers are consulted in order: tie-breaker 1 is tried before tie-breaker 2. WhenFALSE, either tie-breaker agreeing with the leading candidate is sufficient, with no priority between them.- allow_even_split
Logical scalar. When
FALSE(default), a majority requires strictly more than 50\ 4). WhenTRUE, a label with more votes than any other is accepted as a majority even if it does not exceed 50\ others have 1).
Value
A named list with two equal-length factors:
labelThe resolved cell type label.
methodThe decision rule used to reach that label.
Details
Decision hierarchy (evaluated per cell):
Strong majority: If any label receives strictly more votes than all others, and that count exceeds the majority threshold, it is selected immediately. The threshold behaviour is controlled by
allow_even_split.Split — tie-breaker agreement: If there is a genuine leading candidate (at least one label has more votes than the others), and both tie-breakers agree with each other and match that candidate, the label is assigned.
Split — priority order (when
ordered_tiebreak = TRUE, the default): Tie-breaker 1 is tried first against the leading candidate. If it does not match, tie-breaker 2 is tried.Split — either agrees (when
ordered_tiebreak = FALSE): Either tie-breaker agreeing with the leading candidate is sufficient, with no priority between them.Unresolved: If every method disagrees (no leading candidate), or no tie-breaker can resolve the split,
unassigned_labelis assigned.