Skip to content

Commit

Permalink
Add option to return all lrs
Browse files Browse the repository at this point in the history
  • Loading branch information
zenalapp committed Sep 7, 2023
1 parent 9a2d61d commit 10815bd
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
16 changes: 15 additions & 1 deletion R/bistro.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
#' @param time_limit Time limit in minutes to run the
#' [euroformix::contLikSearch()] function on 1 bloodmeal-human pair. Default:
#' 3
#' @param return_lrs A boolean indicating whether or not to return log10LRs for
#' all bloodmeal-human pairs. Default: FALSE
#'
#' @return Tibble with matches for bloodmeal-human pairs including the columns
#' listed below. Note that if multiple matches are found for a bloodmeal,
Expand All @@ -66,6 +68,12 @@
#' * `log10_lr`: If match, log10 likelihood ratio (NA otherwise)
#' * `notes`: Why the bloodmeal does or doesn't have a match
#'
#' If `return_lrs = TRUE`, then a named list of length 2 is returned:
#' * matches - the tibble described above
#' * lrs - log10LRs for each bloodmeal-human pair including some
#' of the columns described above and an additional column:
#' `efm_noc`, which is the number of contributors used as input
#' into euroformix, which is `min(est_noc, 3)`.
#'
#' @export
#'
Expand All @@ -90,7 +98,8 @@ bistro <-
difftol = 1,
threads = 4,
seed = 1,
time_limit = 3) {
time_limit = 3,
return_lrs = FALSE) {
check_bistro_inputs(
bloodmeal_profiles,
human_profiles,
Expand Down Expand Up @@ -152,5 +161,10 @@ bistro <-

matches <- identify_matches(log10_lrs, bloodmeal_ids)

if(return_lrs){
matches <- list(matches = matches,
lrs = log10_lrs)
}

return(matches)
}
13 changes: 12 additions & 1 deletion man/bistro.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions tests/testthat/_snaps/bistro.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,38 @@
<chr> <int> <dbl> <chr> <chr> <dbl> <chr> <dbl>
1 evid1 17 2 yes P1 7.05 passed al~ 6.5

---

Code
bistro(bm_evid1, human_profiles, pop_allele_freqs = pop_allele_freqs, kit = "ESX17",
peak_thresh = 200, return_lrs = TRUE)
Message <simpleMessage>
1/17 markers in kit but not in pop_allele_freqs: AMEL
Formatting bloodmeal profiles
Removing 4 peaks under the threshold of 200 RFU.
Formatting human profiles
Calculating log10LRs
# bloodmeal ids: 1
# human ids: 3
Bloodmeal id 1/1
Human id 1/3
Human id 2/3
Human id 3/3
Identifying matches
Output
$matches
# A tibble: 2 x 8
bloodmeal_id locus_count est_noc match human_id log10_lr notes thresh_low
<chr> <int> <dbl> <chr> <chr> <dbl> <chr> <dbl>
1 evid1 17 2 yes P1 21.8 passed al~ 9.5
2 evid1 17 2 yes P2 10.3 passed al~ 9.5
$lrs
# A tibble: 3 x 7
bloodmeal_id human_id locus_count est_noc efm_noc log10_lr notes
<chr> <chr> <int> <dbl> <dbl> <dbl> <lgl>
1 evid1 00-JP0001-14_20142342~ 17 2 2 -9.62 NA
2 evid1 P1 17 2 2 21.8 NA
3 evid1 P2 17 2 2 10.3 NA

10 changes: 10 additions & 0 deletions tests/testthat/test-bistro.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,14 @@ test_that("bistro works", {
),
"If `calc_allele_freqs = FALSE`, then `pop_allele_freqs` is required."
)

expect_snapshot(bistro(
bm_evid1,
human_profiles,
pop_allele_freqs = pop_allele_freqs,
kit = "ESX17",
peak_thresh = 200,
return_lrs = TRUE
))

})

0 comments on commit 10815bd

Please sign in to comment.