ggPMXdevelopment / ggPMX

ggPMX R package
37 stars 11 forks source link

Observations Ignored in Individual Plots #371

Open YangZhang11 opened 1 year ago

YangZhang11 commented 1 year ago

Describe the bug Last observation of some subjects were shown as "ignored" in individual plots

To Reproduce A minimal example was created using nlmixr2 using the object saved in the attached file (untar first) as follows:

library(nlmixr2)
library(ggPMX)
nlmixrObj <- readRDS("nlmixrObj.RDS")
pmx_nlmixr(nlmixrObj) %>% pmx_plot_individual(which_pages = "all")

nlmixrObj.RDS.tar.gz

Expected behavior All observations should shown as "accepted" as no censoring is done -- all observations used in the model.

Screenshots Output of the scripts:

ind_plot1 ind_plot2

The last observations from subjects IDs 4, 14 and 23 are shown as ignored.

Package and platform:

sessionInfo()
## R version 4.0.4 (2021-02-15)
## Platform: x86_64-redhat-linux-gnu (64-bit)
## Running under: Red Hat Enterprise Linux 8.7 (Ootpa)
## 
## Matrix products: default
## BLAS:   /usr/lib64/libblas.so.3.8.0
## LAPACK: /opt/mango/R/4.0.4/lib/R/lib/libRlapack.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods  
## [7] base     
## 
## other attached packages:
## [1] ggPMX_1.2.10      nlmixr2_2.0.9     nlmixr2data_2.0.7
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_1.0.11         lattice_0.20-41     vpc_1.2.2          
##  [4] zoo_1.8-9           assertthat_0.2.1    digest_0.6.27      
##  [7] utf8_1.2.1          ggforce_0.4.1       rxode2random_2.0.11
## [10] R6_2.5.0            plyr_1.8.6          backports_1.2.1    
## [13] sys_3.4             evaluate_0.14       ggplot2_3.4.2      
## [16] pillar_1.6.0        rlang_1.1.1         rxode2ll_2.0.11    
## [19] rstudioapi_0.13     data.table_1.14.0   checkmate_2.0.0    
## [22] rmarkdown_2.7       labeling_0.4.2      qs_0.24.1          
## [25] dparser_1.3.1-10    stringr_1.4.0       PreciseSums_0.4    
## [28] polyclip_1.10-4     nlmixr2plot_2.0.7   munsell_0.5.0      
## [31] symengine_0.1.5     compiler_4.0.4      xfun_0.22          
## [34] pkgconfig_2.0.3     htmltools_0.5.1.1   tidyselect_1.1.0   
## [37] tibble_3.1.1        rxode2parse_2.0.16  reshape_0.8.8      
## [40] fansi_0.4.2         withr_2.5.0         crayon_1.4.1       
## [43] dplyr_1.0.5         MASS_7.3-53.1       grid_4.0.4         
## [46] nlme_3.1-152        GGally_2.1.1        gtable_0.3.0       
## [49] lifecycle_1.0.3     DBI_1.1.1           magrittr_2.0.1     
## [52] scales_1.2.1        RcppParallel_5.0.3  cli_3.6.1          
## [55] stringi_1.5.3       cachem_1.0.4        n1qn1_6.0.1-10     
## [58] farver_2.1.0        rxode2_2.0.13       ellipsis_0.3.1     
## [61] generics_0.1.0      vctrs_0.6.3         stringfish_0.15.1  
## [64] lotri_0.4.3         RApiSerialize_0.1.0 RColorBrewer_1.1-2 
## [67] tools_4.0.4         glue_1.4.2          tweenr_1.0.2       
## [70] purrr_0.3.4         rxode2et_2.0.10     fastmap_1.1.0      
## [73] yaml_2.2.1          colorspace_2.0-0    lbfgsb3c_2020-3.2  
## [76] nlmixr2est_2.1.6    memoise_2.0.0       knitr_1.32

Additional context The example was implemented in nlmixr2 but we have observed similar issues with NONMEM results.

tmss1 commented 11 months ago

I have the same issue as above with Monolix. Any advice on what we can do about this?

A2P2 commented 9 months ago

It's a rounding issue coming from Line 120 at plot-individual.R. https://github.com/ggPMXdevelopment/ggPMX/blob/bd679e25ffc50f22ae2773587a44bca50f24ede6/R/plot-individual.R#L120 As a workaround at the moment you could round last time points before plotting yourself using floor, e.g. nlmixrObj$TIME[nlmixrObj$TIME>160] <- floor(nlmixrObj$TIME[nlmixrObj$TIME>160]).