R/check-dead-strains.R

#' Creates 'WARNING_mixed_array.csv' as an easy to read automated report of the problematic plates seemingly mixed or wrong or contaminated.
#' vsp33 is absent from the array and should always be a blank spot.
#'
#' @param dir A directory containing the screenmill data
#' @param death_tresh Death threshold for excluding potential pinning residues. default set to '10', stringent treshold.
#'
#'
#' @md
#' @export


check_dead_strains <- function(dir, death_thresh = 10) {

  assertthat::assert_that(assertthat::is.string(dir))
  assertthat::assert_that(assertthat::is.number(death_thresh))

  bio_replicate_file <- read_csv(file.path(dir, 'biological-replicate-annotation.csv'))


  sm_data <- screenmill::read_screenmill(dir) %>%
    left_join(bio_replicate_file) %>%
    mutate(
      # Make a numeric cisplatin variable by extracting the number between "-" and "uM"
      cisplatin = as.numeric(str_extract(treatment_id, '(?<=-).*(?=(uM))'))
    )

  sm_data %>%
    group_by(query_name, bio_replicate, strain_name) %>%
    summarise(
      mean_growth = mean(size[cisplatin == 0 & strain_name == 'vps33'])
    ) %>%
    filter(mean_growth > death_thresh )

}
matthieu-haudiquet/rothSGA documentation built on May 14, 2019, 11:28 a.m.