Skip to content

Commit

Permalink
Merge pull request #158 from gdrplatform/GDR-2646
Browse files Browse the repository at this point in the history
chore: bump version and update NEWS.md
  • Loading branch information
bczech authored Aug 8, 2024
2 parents 20eb5e7 + 5b8a87c commit 9ffc15a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 7 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Type: Package
Package: gDRcore
Title: Processing functions and interface to process and analyze drug
dose-response data
Version: 1.3.7
Date: 2024-08-05
Version: 1.3.8
Date: 2024-08-08
Authors@R: c(
person("Bartosz", "Czech", , "[email protected]", role = "aut",
comment = c(ORCID = "0000-0002-9908-3007")),
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## gDRcore 1.3.8 - 2024-08-08
* fix issue with mapping overrides untreated controls

## gDRcore 1.3.7 - 2024-08-05
* fix issue with non-avearaged concentration data

Expand Down
4 changes: 2 additions & 2 deletions R/map_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ map_df <- function(trt_md,

out <- lapply(seq_along(trt_rnames), function(i) {
treatment <- trt_rnames[i]
if (is.na(exact_out[[treatment]]) || !is.null(override_untrt_controls)) {
if (all(is.na(exact_out[[treatment]])) || !is.null(override_untrt_controls)) {

refs <- lapply(present_ref_cols, function(y) {
unname(unlist(ref_md[, y, with = FALSE]) == unlist(trt_md[which(trt_md$rn == treatment),
Expand All @@ -149,7 +149,7 @@ map_df <- function(trt_md,
# are found.
idx <- idx * match_mx[matchFactor, ]

if (any(idx > 0)) {
if (any(idx > 0, na.rm = TRUE)) {
match_idx <- which.max(idx)
msgs <- c(
msgs,
Expand Down
47 changes: 44 additions & 3 deletions tests/testthat/test-map_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,57 @@ test_that("map_df works as expected", {

expect_equal(mapping, out)
expect_equal(sort(unique(unname(unlist(mapping)))), sort(rownames(ref_df)))

# Test Day0 data with E2

trt_dt <- data.table::data.table(
clid = c("Cell123456", "Cell123456", "Cell654321", "Cell654321"),
CellLineName = c("CellLineA", "CellLineA", "CellLineB", "CellLineB"),
Tissue = c("Liver", "Liver", "Liver", "Liver"),
parental_identifier = c("ParentA", "ParentA", "ParentB", "ParentB"),
subtype = c("type1", "type1", "type2", "type2"),
ReferenceDivisionTime = c(45, 45, 30, 30),
Gnumber = c("Drug12345678", "Drug12345678", "Drug87654321", "Drug87654321"),
DrugName = c("DrugX", "DrugX", "DrugY", "DrugY"),
drug_moa = c("MOA1", "MOA1", "MOA2", "MOA2"),
Duration = c(120, 120, 120, 120),
E2 = c("0", "0.0023", "0", "0.0023"),
rn = c("1", "2", "6", "7")
)

ref_dt <- data.table::data.table(
clid = c("Cell123456", "Cell123456", "Cell123456", "Cell654321", "Cell654321", "Cell654321"),
CellLineName = c("CellLineA", "CellLineA", "CellLineA", "CellLineB", "CellLineB", "CellLineB"),
Tissue = c("Liver", "Liver", "Liver", "Liver", "Liver", "Liver"),
parental_identifier = c("ParentA", "ParentA", "ParentA", "ParentB", "ParentB", "ParentB"),
subtype = c("type1", "type1", "type1", "type2", "type2", "type2"),
ReferenceDivisionTime = c(NA, NA, NA, 60, 60, 60),
Gnumber = c("Drug12345678", "Drug12345678", "Drug12345678", "Drug87654321", "Drug87654321", "Drug87654321"),
DrugName = c("DrugX", "DrugX", "DrugX", "DrugY", "DrugY", "DrugY"),
drug_moa = c("MOA1", "MOA1", "MOA1", "MOA2", "MOA2", "MOA2"),
Duration = c(0, 168, 168, 0, 168, 168),
E2 = c("0", "0", "0.0023", "0", "0", "0.0023"),
rn = c("3", "4", "5", "8", "9", "10")
)

ref_cols <- c("CellLineName", "Tissue", "parental_identifier", "subtype",
"Barcode", "clid")

ref_type <- "Day0"
map_override_untrt_controls <- map_df(trt_dt,
ref_dt,
ref_cols = ref_cols,
ref_type = ref_type,
override_untrt_controls = c(E2 = 0.0023))
expect_list(map_override_untrt_controls)
expect_length(map_override_untrt_controls, 4)
})



# TODO: test_that("Best match is detected for missing controls", {}) # nolint


# TODO: test_that("NAs are returned for missing controls", {}) # nolint


mat_elem <- data.table::data.table(DrugName = rep(c("untreated", "drugA", "drugB", "untreated"), 2),
DrugName_2 = rep(c("untreated", "vehicle", "drugA", "drugB"), 2),
clid = rep(c("C1", "C2"), each = 4))
Expand Down

0 comments on commit 9ffc15a

Please sign in to comment.