Skip to content

Commit

Permalink
Return no match if log10LR is infinite
Browse files Browse the repository at this point in the history
  • Loading branch information
zenalapp committed Sep 8, 2023
1 parent 0ea1c4b commit 89d4d28
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 9 additions & 2 deletions R/match_static_thresh.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ match_static_thresh <- function(log10_lrs, thresh) {
dplyr::distinct()

matches <- log10_lrs |>
dplyr::filter(log10_lr >= thresh) |>
dplyr::filter(log10_lr >= thresh &
!is.infinite(log10_lr)) |>
dplyr::mutate(match = "yes") |>
dplyr::select(
bloodmeal_id,
Expand All @@ -35,7 +36,13 @@ match_static_thresh <- function(log10_lrs, thresh) {

# add in bloodmeals that were dropped
matches <- bm_info |>
dplyr::left_join(matches) |>
dplyr::left_join(matches,
by = dplyr::join_by(
bloodmeal_id,
locus_count,
est_noc
)
) |>
dplyr::mutate(match = ifelse(is.na(match), "no", match))

return(matches)
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-match_static_thresh.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ test_that("match_static_thresh works", {
) |>
suppressMessages()
expect_snapshot(match_static_thresh(bistro_output$lrs, 10))

expect_true(bistro_output$lrs |>
dplyr::mutate(log10_lr = Inf) |>
match_static_thresh(10) |>
dplyr::pull(match) == "no")
})

0 comments on commit 89d4d28

Please sign in to comment.