-
Notifications
You must be signed in to change notification settings - Fork 14
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
62 bidirectional summary stats #126
Changes from all commits
43f93e5
0d659dc
b0757af
a1f1861
2f0df99
f22edda
40b671a
2386209
46cbcd1
21d9f32
0d0bc23
ad32db7
31525a5
9c30b65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,37 +3,45 @@ | |
#' @param dat output from level 3 processing | ||
#' @param fitmodels list of the models that should be fit with the data | ||
#' @param bmed baseline value, typically should be 0 | ||
#' @param bidirectional boolean, default is TRUE (bidirectional fitting) | ||
#' | ||
#' @return Data.table with an additional column fitparams that includes all of the fitting parameters | ||
#' @importFrom tcplfit2 tcplfit2_core | ||
tcplFit2 <- function(dat, | ||
fitmodels = c("cnst", "hill", "gnls", "poly1", "poly2", "pow", "exp2", "exp3", "exp4", "exp5"), | ||
bmed = NULL, | ||
bidirectional = TRUE) { | ||
bmed = NULL) { | ||
#variable binding | ||
resp <-bmad <-aeid <-osd <-m3id <- concentration_unlogged <-response <- NULL | ||
# do all the regular fitting things that still need to be done | ||
res <- dat[, `:=`(c("rmns", "rmds", "nconcs", "med_rmds"), { | ||
res <- dat[, `:=`(c("rmns", "rmds", "nconcs", "med_rmds_pos", "med_rmds_neg"), { | ||
rmns <- mean(resp) | ||
rmds <- median(resp) | ||
nconcs <- .N | ||
med_rmds <- rmds >= (3 * bmad) | ||
.(rmns, rmds, nconcs, med_rmds) | ||
med_rmds_pos <- rmds >= (3 * bmad) | ||
med_rmds_neg <- rmds <= (-3 * bmad) | ||
.(rmns, rmds, nconcs, med_rmds_pos, med_rmds_neg) | ||
}), keyby = .(aeid, spid, logc)][, .( | ||
bmad = min(bmad), resp_max = max(resp), osd = min(osd), bmed = ifelse(is.null(bmed), 0, max(bmed)), | ||
resp_min = min(resp), max_mean = max(rmns), max_mean_conc = logc[which.max(rmns)], | ||
bmad = min(bmad), osd = min(osd), bmed = ifelse(is.null(bmed), 0, max(bmed)), | ||
resp_max = max(resp), resp_min = min(resp), | ||
max_mean = max(rmns), max_mean_conc = logc[which.max(rmns)], | ||
max_med = max(rmds), max_med_conc = logc[which.max(rmds)], | ||
min_mean = min(rmns), min_mean_conc = logc[which.min(rmns)], | ||
min_med = min(rmds), min_med_conc = logc[which.min(rmds)], | ||
logc_max = max(logc), logc_min = min(logc), nconc = length(unique(logc)), | ||
npts = .N, nrep = median(as.numeric(nconcs)), nmed_gtbl = sum(med_rmds) / first(nconcs), | ||
npts = .N, nrep = median(as.numeric(nconcs)), | ||
nmed_gtbl_pos = sum(med_rmds_pos) / first(nconcs), | ||
nmed_gtbl_neg = sum(med_rmds_neg) / first(nconcs), | ||
concentration_unlogged = list(10^(logc)), response = list(resp), m3ids = list(m3id) | ||
), | ||
keyby = .(aeid, spid) | ||
][, `:=`(tmpi = seq_len(.N)), keyby = .(aeid)][, | ||
][, `:=`(c("max_med_diff", "max_med_diff_conc"), { | ||
max_med_diff <- ifelse(abs(max_med) > abs(min_med), max_med, min_med) | ||
max_med_diff_conc <- ifelse(abs(max_med) > abs(min_med), max_med_conc, min_med_conc) | ||
.(max_med_diff, max_med_diff_conc) | ||
})][, `:=`(tmpi = seq_len(.N)), keyby = .(aeid)][, | ||
`:=`(fitparams = list(tcplfit2::tcplfit2_core(unlist(concentration_unlogged), | ||
unlist(response), | ||
cutoff = bmad, | ||
bidirectional = bidirectional, | ||
bidirectional = TRUE, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cthunes, was this changed from 'bidirectional' passed argument to TRUE since this the max_med_diff and max_med_diff_conc are only apply to the bidirectional = TRUE cases for right now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nevermind.... This is because we are only fitting in the bi-directional direction now within tcpl. |
||
verbose = FALSE, force.fit = TRUE, | ||
fitmodels = fitmodels | ||
))), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like nmed_gtbl might be dropped in code, but column is kept in the database
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Column has been dropped in invitrodb