Skip to contents

Render a table gathering precision and recall rates before and after filtering on coefficient values

Usage

test_filter(df_before, df_after, prevs = NULL)

Arguments

df_before

Dataframe. The one of true neighbors

df_after

Dataframe. The one of detected neighbors

prevs

List of numeric. The prevalences to be studied. Required format is decimal: 0.20 for 20% of prevalence

Value

Dataframe. Returns the precision and recall rates before and after the modification

Examples

# Dataframe with true neighbors
list_true <- list(
  tibble::tibble(
    node1 = c("msp_1", "msp_1", "msp_2", "msp_3"), node2 = c("msp_55", "msp_20", "msp_3", "msp_18"),
    prev1 = c(0.28, 0.28, 0.96, 0.75), prev2 = c(0.76, 0.25, 0.75, 0.60)
  ),
  tibble::tibble(node1 = c("msp_2", "msp_3"), node2 = c("msp_3", "msp_18"), prev1 = c(0.96, 0.75), prev2 = c(0.75, 0.60))
) %>% rlang::set_names(c("0.20", "0.30"))

# Dataframes with detected neighbors
list_detected <- list(
  tibble::tibble(
    prev_level = c("0.20", "0.30", "0.30", "0.30"), node1 = c("msp_2", "msp_2", "msp_3", "msp_3"),
    node2 = c("msp_3", "msp_3", "msp_18", "msp_8"), coef = c(0.406, -0.025, 0.160, 0.005),
    filtering_top = c(100, 100, 100, 100)
  ),
  tibble::tibble()
) %>% rlang::set_names(c("0.20", "0.30"))
list_detected2 <- list(
  tibble::tibble(
    prev_level = c("0.20", "0.20"), node1 = c("msp_2", "msp_3"),
    node2 = c("msp_3", "msp_18"), coef = c(0.160, 0.005),
    filtering_top = c(100, 100)
  ),
  tibble::tibble()
) %>% rlang::set_names(c("0.20", "0.30"))
# Use final_step() to gather both
neighbors <- final_step(list_true, list_detected, robustness_step = FALSE)
neighbors2 <- final_step(list_true, list_detected2, robustness_step = FALSE) %>% dplyr::mutate(filtering_top = 10)
# Calculate scores
scores <- test_filter(neighbors, neighbors2)