Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relist plate scoring functions and only use the functions of the current plate in the loop #33

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions R/score_plates.R
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,8 @@ optimize_multi_plate_design <- function(batch_container, across_plates_variables

if (!is.null(within_plate_variables)) {
plate_levels <- unique(bc$get_locations()[[plate]])
scoring_funcs <- purrr::map(within_plate_variables, ~ mk_plate_scoring_functions(bc, plate = plate, row = row, column = column, group = .x)) %>%
unlist()
names(scoring_funcs) <- paste(rep(within_plate_variables, each = length(plate_levels)), names(scoring_funcs))

scoring_funcs <- purrr::map(within_plate_variables, ~ mk_plate_scoring_functions(bc, plate = plate, row = row, column = column, group = .x))
names(scoring_funcs) <- within_plate_variables

if (!quiet) {
message(
Expand All @@ -266,7 +264,7 @@ optimize_multi_plate_design <- function(batch_container, across_plates_variables
if (!quiet && length(plate_levels) > 1) cat(curr_plate, "... ")

bc <- optimize_design(bc,
scoring = scoring_funcs,
scoring = scoring_funcs %>% purrr::map(curr_plate) %>% rlang::set_names(paste(names(.), " Plate_", curr_plate)),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I understand this code.

scoring_funcs is a list of lists now, and curr_plate is a a plate id (character or numeric). right?

what does scoring_funcs %>% purrr::map(curr_plate) do?

maybe we need to transpose the scoring_funcs first with purrr::list_transpose, and then we:

  1. assert_that length of plate_levels is the same of scoring_funcs?
  2. for (plate_index in seq_len(length(plate_levels)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I understand this code.

scoring_funcs is a list of lists now, and curr_plate is a a plate id (character or numeric). right?

what does scoring_funcs %>% purrr::map(curr_plate) do?

First part is correct.
purrr::map(curr_plate) is equivalent to purrr::map(purrr::pluck, curr_plate)
Maybe it should be written like that for readability.

maybe we need to transpose the scoring_funcs first with purrr::list_transpose, and then we:

  1. assert_that length of plate_levels is the same of scoring_funcs?
  2. for (plate_index in seq_len(length(plate_levels)

I need to check this.

max_iter = max_iter,
quiet = TRUE,
shuffle_proposal_func = mk_subgroup_shuffling_function(
Expand Down
Loading