Skip to contents

Count inferred rate increases and decreases for a transition table, bifrost_search object, shift_magnitude_comparison object, or list of runs. This is the tabular input to plot() for shift-magnitude counts and reproduces the count/frequency summaries used by Berv et al. (2026) before plotting. Fitted bifrost_search inputs are accepted only for multi-regime BMM fits; generic mapped-tree inputs should use tree plus state_values.

Usage

shift_magnitude_counts(x = NULL, tree = NULL, state_values = NULL)

Arguments

x

A transition table, bifrost_search object, list of transition/search objects, shift_magnitude_comparison object, shift_magnitude_groups object, or NULL when using the tree argument.

tree

Optional SIMMAP-style phylo tree for generic input mode.

state_values

Named numeric state-value vector for generic input mode.

Value

A shift_magnitude_counts data frame with one row per input run. Columns include source, increase/decrease counts, total directional shifts, and increase/decrease frequencies. When x is a shift_magnitude_groups object, a named shift_magnitude_count_set is returned instead.

Examples

transitions <- data.frame(
  rate_change = c("root", "increase", "increase", "decrease", "decrease"),
  rate_delta = c(NA, 3, 4, -1, -2)
)
shift_magnitude_counts(list(run1 = transitions, run2 = transitions))
#>   source decrease increase total decrease_frequency increase_frequency
#> 1   run1        2        2     4                0.5                0.5
#> 2   run2        2        2     4                0.5                0.5
shift_magnitude_counts(shift_magnitude_groups(A = transitions, B = transitions))
#> $A
#>   source decrease increase total decrease_frequency increase_frequency
#> 1  input        2        2     4                0.5                0.5
#> 
#> $B
#>   source decrease increase total decrease_frequency increase_frequency
#> 1  input        2        2     4                0.5                0.5
#> 
#> attr(,"class")
#> [1] "shift_magnitude_count_set" "list"