Skip to content
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

Lines showing the percentiles for both the observations and the predictions #206

Open
pmpharm opened this issue Oct 10, 2022 · 3 comments
Open

Comments

@pmpharm
Copy link

pmpharm commented Oct 10, 2022

According to the recommendations of the Model Evaluation Group of the International Society of Pharmacometrics (ISoP) Best Practice Committee (https://pubmed.ncbi.nlm.nih.gov/27884052/ ), it is suggested that a VPC should have lines showing the percentiles of both observations and predictions. This is important so the percentiles can be compared visually in order to compare the distribution of observed and predicted values. There is an illustration in the Figure S8 of the supplemental material.

If I checked correctly this is not possible yet in the package. My guess so far is that this functionality is available only in Monolix. Would it be possible to implement such functionality?

@andrewhooker
Copy link
Collaborator

Hi,

I believe that all of the plots in Figure S8 of the paper you reference can be created by xpose, which uses the VPC package. Please see:
https://uupharmacometrics.github.io/xpose/articles/vpc.html
http://vpc.ronkeizer.com/appearance.html

Best regards,
Andy

@smouksassi
Copy link

I was a co-author on the MOEV paper and at the time the code of the paper was in the supplemental materials available online
(pure from the ground up ggplot2 nothing special, I take good care of informative legends)

later on I co-wrote tidyvpc https://github.com/certara/tidyvpc (where all computation are efficiently done using data.table)
I support observation level LLOQ (e.g. different loq by study) and flexible by strata binning method etc.
the package has a plot method for automatic plotting but you can write any ggplot2 code that you would like to use.

tidyvpc is software agnostic just need an obstable and a simulation table

@bguiastr
Copy link
Collaborator

bguiastr commented Oct 21, 2022

Hi,

Appologies for the delay in my response. The representation of the medians for the percentiles of the simulations is not yet implemented in xpose but given the flexibility of offered by the package it is quite easy to add this layer yourself. I have generated a small example for you. I hope it helps.

library(xpose)
#> Loading required package: ggplot2
#> 
#> Attaching package: 'xpose'
#> The following object is masked from 'package:stats':
#> 
#>     filter
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

## Compute the vpc data
xpdb_vpc <- vpc_data(xpdb_ex_pk, stratify = 'SEX', opt = vpc_opt(n_bins = 7, lloq = 0.1))
#> 
#> VPC continuous --------------------
#> 1. Gathering data & settings
#> Using xpdb simulation problem 2 and observation problem 1.
#> Setting stratifying variable to SEX
#> Setting lloq to 0.1.
#> 
#> 2. Computing VPC data
#> Configuring and initializing...
#> Stratifying oberved data...
#> Parsing observed data...
#> Filtering rows where EVID not 0
#> Parsing simulated data...
#> Filtering rows where EVID not 0
#> Binning: 0 0.66667 1.25 1.8 3 5 7 9
#> Calculating statistics for simulated data...
#> Calculating statistics for observed data...
#> 
#> VPC done

## Extract the vpc data for use outside of the "conventional way"
special_df <- get_special(xpdb_vpc)
#> Returning vpc continuous data from $prob no.3

## Call the VPC function
vpc(xpdb_vpc) + 
  
  ## Add your layer
  geom_line(
  data = special_df$vpc_dat, 
  aes(x = bin_mid, y = med, color = Simulations)) + 
  
  ## Ensure consistent color scale
  scale_color_manual(values = c('steelblue3', 'grey60', 'steelblue3'))
#> Warning: Removed 4 rows containing missing values (`geom_line()`).
#> Warning: Removed 25 rows containing missing values (`geom_point()`).

Created on 2022-10-21 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants