UUPharmacometrics / xpose

Graphical diagnostics for pharmacometric models
https://uupharmacometrics.github.io/xpose
GNU Lesser General Public License v3.0
55 stars 29 forks source link

Cannot Load Files when ID Column is Aliased #97

Open billdenney opened 6 years ago

billdenney commented 6 years ago

In my $INPUT block, I specify that "ID=USUBJIDNUMERIC". With that, the ID in the tables is now titled "USUBJIDNUMERIC" rather than "ID".

I think that the fix would be to detect mapping and allow an argument that makes it to the index_table function (https://github.com/UUPharmacometrics/xpose/blob/942f8b10c3a9cebb211c9832307c31b0107a3ee1/R/read_nm_tables.R#L366-L377) where the different required column types are mapped. Ideally, this would be auto-detected from the $INPUT block and possible to override by the user.

Generally, this can apply for any column since they all could be mapped to different names.

billdenney commented 6 years ago

... And, something like the following could help with the feature request:

parse_nonmem_input_block <- function(code) {
  all_code <- paste(code, collapse=" ")
  var_blocks <- strsplit(x=all_code, split=" +")[[1]]
  name_blocks <- strsplit(x=var_blocks, split="=", fixed=TRUE)
  name_blocks %>%
    purrr::map(.f=function(x) {
      if (length(x) == 1) {
        setNames(x, nm=x)
      } else if (length(x) == 2) {
        setNames(object=x[2], nm=x[1])
      } else {
        stop("$INPUT elements must be mapped with either no equal sign or one equal sign.  Cannot parse '", paste(x, collapse="="), "'")
      }
    })
}

parse_nonmem_input_block(xpdb$code %>% filter(subroutine %in% "inp") %>% magrittr::extract2("code"))
bguiastr commented 4 years ago

@billdenney I have done some updates on read_nm_tables(), among other things I removed the dependency on the ID column and preserved the filenames in preparation to #140

Can you check can check d7686e9 and see if that solves this issue for you?

billdenney commented 4 years ago

I'll try to check this soon. (I'm about to be off to ACoP, but hopefully I can check when I get back.)

billdenney commented 4 years ago

I just tried the dev branch (not just the specific patch), but I was getting what appeared to be unrelated errors. Are you switching the class name away from xpose_data to xpdb? The errors appeared to be related to that.

bguiastr commented 4 years ago

The dev branch is under heavy development and is not currently functional, I am reworking the entire structure of the xpdb, adding S2, improve traceability, and bring new features. I got all the PR notifications but I need to get everything back on track before merging them.

On Nov 3, 2019, at 03:01, Bill Denney notifications@github.com wrote:

I just tried the dev branch (not just the specific patch), but I was getting what appeared to be unrelated errors. Are you switching the class name away from xpose_data to xpdb? The errors appeared to be related to that.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

billdenney commented 4 years ago

Thanks for that update. I need most of those PRs for some of my current projects that I’m updating. I’m going to add another couple of PRs that will make it functional for my projects, and hopefully they will be helpful to your efforts.