Interactive Threshold Selection Based on Expected Number of Extrema
Source:R/gflow_cx.R
suggest.threshold.RdHelps determine appropriate hop_idx threshold by showing how many extrema would be retained at different threshold levels. Particularly useful when you have domain knowledge about the expected number of true extrema.
Usage
suggest.threshold(
extrema_df,
expected_n_extrema = NULL,
expected_range = NULL,
plot = TRUE,
exclude_global = TRUE
)Arguments
- extrema_df
Data frame from create.hop.nbhd.extrema.df with hop_idx column
- expected_n_extrema
Expected number of true extrema (NULL for no target)
- expected_range
Optional vector c(min, max) for expected range
- plot
Logical; create diagnostic plots (default TRUE)
- exclude_global
Logical; exclude global extrema (hop_idx = Inf) from counts
Examples
extrema_df <- data.frame(
vertex = 1:6,
hop_idx = c(1, 2, 3, 4, Inf, 6),
is_max = c(0, 1, 0, 1, 1, 0),
label = c("m1", "M1", "m2", "M2", "M3", "m3")
)
suggestions <- suggest.threshold(
extrema_df,
expected_range = c(2, 3),
plot = FALSE
)
suggestions$suggestions$recommended_threshold