Skip to content

Commit

Permalink
Merge pull request #137 from gdrplatform/GDR-2736
Browse files Browse the repository at this point in the history
Gdr 2736
  • Loading branch information
darsoo authored Oct 29, 2024
2 parents a45d014 + f624d67 commit 418c87f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: gDRutils
Type: Package
Title: A package with helper functions for processing drug response data
Version: 1.3.16
Date: 2024-10-11
Version: 1.3.17
Date: 2024-10-24
Authors@R: c(person("Bartosz", "Czech", role=c("aut"),
comment = c(ORCID = "0000-0002-9908-3007")),
person("Arkadiusz", "Gladki", role=c("cre", "aut"), email="[email protected]",
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## gDRutils 1.3.17 - 2024-10-24
* make average_biological_replicates_dt more restrictive - fewer columns to check for duplicates

## gDRutils 1.3.16 - 2024-10-11
* make duplicates' helpers supporting combo assays as well

Expand Down
11 changes: 11 additions & 0 deletions R/headers_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,17 @@
"Fit Type GR",
"RV_fit_type",
"GR_fit_type"
),
# due to the fact that there is some freedom in what values are in individual fields,
# in order to avoid duplicates in the application we have to exclude some fields from
# recognizing duplicates in averaging
blacklisted = c(
"Tissue", # sometimes this field is missing
"cellline_tissue",
"Reference Division Time", # sometimes this field has `NA`s
"cellline_ref_div_time",
"Parental Identifier", # sometimes suffixes incorrectly differentiate this field
"cellline_parental_identifier"
)
)
}
Expand Down
6 changes: 5 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ geometric_mean <- function(x, fixed = TRUE, maxlog10Concentration = 1) {
#' to take the geometric average of.
#' @param fit_type_average_fields Character vector of column names in \code{dt}
#' that should be treated as a column with fit type data
#' @param blacklisted_fields Character vector of column names in \code{dt}
#' that should be skipped in averaging
#' @param add_sd Flag indicating whether to add standard deviation and count columns.
#'
#' @examples
Expand All @@ -452,6 +454,7 @@ average_biological_replicates_dt <- function(
fixed = TRUE,
geometric_average_fields = get_header("metric_average_fields")$geometric_mean,
fit_type_average_fields = get_header("metric_average_fields")$fit_type,
blacklisted_fields = get_header("metric_average_fields")$blacklisted,
add_sd = FALSE) {

checkmate::assert_data_table(dt)
Expand All @@ -476,7 +479,8 @@ average_biological_replicates_dt <- function(
average_fields <- setdiff(names(Filter(is.numeric, data)), c(unlist(pidfs), var, iso_cols))
geometric_average_fields <- intersect(geometric_average_fields, names(dt))
fit_type_average_fields <- intersect(fit_type_average_fields, names(dt))
group_by <- setdiff(names(data), c(average_fields, var, id_cols, fit_type_average_fields))
blacklisted_fields <- intersect(blacklisted_fields, names(dt))
group_by <- setdiff(names(data), c(average_fields, var, id_cols, fit_type_average_fields, blacklisted_fields))

if (add_sd) {
# Calculate standard deviation for both average_fields and geometric_average_fields
Expand Down
4 changes: 4 additions & 0 deletions man/average_biological_replicates_dt.Rd

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

1 change: 0 additions & 1 deletion tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ test_that("average_biological_replicates_dt works as expected", {
av1i <- average_biological_replicates_dt(tdata, var = "source_id", fit_type_average_fields = "bad_value")
expect_true(nrow(av1i) == 8)


})

test_that("has_single_codrug_data works as expected", {
Expand Down

0 comments on commit 418c87f

Please sign in to comment.