Skip to content

Commit

Permalink
chore: minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
gladkia committed Dec 16, 2024
1 parent df6d275 commit 94501bb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
11 changes: 8 additions & 3 deletions R/fit_curves.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fit_curves <- function(df_,
if (length(setdiff(opt_fields, colnames(df_))) > 0L) {
df_[, setdiff(opt_fields, colnames(df_))] <- NA
}
df_metrics <- .apllyLogisticFit(df_, normalization_type, series_identifiers, e_0, GR_0, range_conc, force_fit,
df_metrics <- .applyLogisticFit(df_, normalization_type, series_identifiers, e_0, GR_0, range_conc, force_fit,
pcutoff, cap, n_point_cutoff)

is_unique_normalization_type_and_fit_source <-
Expand All @@ -94,7 +94,7 @@ fit_curves <- function(df_,
}

#' @keywords internal
.apllyLogisticFit <- function(df_, normalization_type, series_identifiers, e_0, GR_0, range_conc, force_fit,
.applyLogisticFit <- function(df_, normalization_type, series_identifiers, e_0, GR_0, range_conc, force_fit,
pcutoff, cap, n_point_cutoff) {

df_metrics <- NULL
Expand Down Expand Up @@ -487,7 +487,12 @@ logistic_metrics <- function(c, x_metrics) {
#' @keywords fit_curves
#' @export
.setup_metric_output <- function() {
resp_metric_cols <- c(get_header("response_metrics"), "maxlog10Concentration", "N_conc")
resp_metric_all_cols <- c(get_header("response_metrics"), "maxlog10Concentration", "N_conc")
# remove cols ending with "_sd"
# they are not present in the primary assays
# but only with the assays followed by averaging of biological replicates
resp_metric_cols <- grep("_sd$", resp_metric_all_cols, invert = TRUE, value = TRUE)

out <- as.list(rep(NA, length(resp_metric_cols)))
names(out) <- resp_metric_cols
out
Expand Down
9 changes: 8 additions & 1 deletion R/flatten.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ flatten <- function(tbl, groups, wide_cols, sep = "_") {
uniquifying <- unique(uniquifying)

out <- split(subset(tbl, select = -idx), subset(tbl, select = idx), sep = sep)
missing <- setdiff(wide_cols, colnames(tbl))

# in original assays there are no columns with SD-related data (with names ending with "_sd")
missing <- if (!any(grepl("_sd$", colnames(tbl)))) {
setdiff(wide_cols[!grepl("_sd$", wide_cols)], colnames(tbl))
# assays with averaged biological replicates might have columns with SD-related data (with names ending with "_sd")
} else {
setdiff(wide_cols, colnames(tbl))
}
if (length(missing) != 0L) {
warning(sprintf("missing listed wide_cols columns: '%s'", paste0(missing, collapse = ", ")))
}
Expand Down

0 comments on commit 94501bb

Please sign in to comment.