
Count Inferred Rate Increases And Decreases
Source:R/shift-distributions.R
shift_magnitude_counts.RdCount 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.
Arguments
- x
A transition table,
bifrost_searchobject, list of transition/search objects,shift_magnitude_comparisonobject,shift_magnitude_groupsobject, orNULLwhen using thetreeargument.- tree
Optional SIMMAP-style
phylotree 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"