Loads ONE pharmacokinetic data file (XPT, XLSX, XLS, CSV, TXT, SAS7BDAT) - #635
PavanLomati wants to merge 2 commits into
Conversation
that may contain concentration data, dose data, or both (a "combined" file), and returns the matching PKNCA object: both conc + dose columns present -> a PKNCAdata object only conc columns present -> a PKNCAconc object only dose columns present -> a PKNCAdose object
| "\\b(ng|mg|ug)[^a-z0-9]{0,3}ml\\b" # ng/mL, mg/mL, ug/mL, or with _ . space as separator (e.g. "(ng/mL)" -> "..ng.mL.") | ||
| ), | ||
| dose = c( | ||
| "^dose$", "^amount$", "^exdose$", "^amt$", |
There was a problem hiding this comment.
Please also include "^ecdose$"
| ), | ||
| dose = c( | ||
| "^dose$", "^amount$", "^exdose$", "^amt$", | ||
| "^dose\\b", # starts with "dose" (e.g. R-mangled "Dose..mg.") |
There was a problem hiding this comment.
We should not guess on mangled column names. Cleaning up column names should be done before input.
| "^dose\\b", # starts with "dose" (e.g. R-mangled "Dose..mg.") | ||
| "^dose_", # dose_ prefix | ||
| "_dose$", # _dose suffix | ||
| "\\b(mg|ug)[^a-z0-9]*$" # mg or ug, optionally with trailing punctuation (e.g. "..mg.") |
There was a problem hiding this comment.
We should not guess that mg or ug is a dose as it could be something else. The column should must be clearly named with the correct name.
| subject = c( | ||
| "^usubjid$", "^id$", "^subject$", "^subjectid$", "^ptno$", | ||
| "^subj$", "^subj_id$", "^subject_id$", | ||
| "^subject\\b", # starts with "subject" (e.g. R-mangled "Subject.ID.") |
There was a problem hiding this comment.
We should not accept these starts with variants because it could be something else. We should be strict on the column naming so that we don't accidentally guess at something incorrect.
| time = c( | ||
| "^time$", "^pctptnum$", "^atptn$", "^tad$", "^tafd$", "^hr$", | ||
| "^hours$", "^time_h$", "^time_hr$", | ||
| "^time\\b", # starts with "time" (e.g. R-mangled "Time..hr.") |
There was a problem hiding this comment.
Same comment about starting with the values: please exclude those.
| #' present (intervals are auto-derived from dose times as usual). | ||
| #' @param conc_options Optional named list of extra arguments passed on to | ||
| #' \code{PKNCAconc()} (e.g. \code{list(exclude = "excl", sparse = TRUE)}). | ||
| #' @param dose_options Optional named list of extra arguments passed on to |
There was a problem hiding this comment.
Please rename to dose_args since "options" has specific meaning for a different argument.
| #' @param verbose Logical. Print progress messages? Default \code{TRUE}. | ||
| #' | ||
| #' @return A \code{PKNCAdata}, \code{PKNCAconc}, or \code{PKNCAdose} object, | ||
| #' depending on what was found in the file (and whether \code{intervals} |
There was a problem hiding this comment.
Drop the note about intervals here
| role <- detect_role(path, patterns = patterns, verbose = verbose) | ||
|
|
||
| if (role == "unknown") { | ||
| rlang::abort(sprintf( |
There was a problem hiding this comment.
Please move this error above (you will need to pass the path into detect_role())
| if (verbose) rlang::inform(sprintf(" \u2022 Auto-built conc_formula: %s", deparse(conc_formula))) | ||
| } | ||
|
|
||
| o_conc <- do.call(PKNCA::PKNCAconc, c(list(data = df, formula = conc_formula), conc_options)) |
There was a problem hiding this comment.
No need for the PKNCA:: since it's in the package. Please apply throughout.
| rlang, | ||
| stats, | ||
| rio, | ||
| janitor, |
There was a problem hiding this comment.
I don't think that we should need janitor after all edits are made.
that may contain concentration data, dose data, or both (a "combined"
file), and returns the matching PKNCA object:
both conc + dose columns present -> a PKNCAdata object
only conc columns present -> a PKNCAconc object
only dose columns present -> a PKNCAdose object