Jump to content


Photo

Covariate Model R Scripts


  • Please log in to reply
3 replies to this topic

#1 SonyaTangGirdwood

SonyaTangGirdwood

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 06 November 2020 - 01:09 AM

I am trying to use the R scripts under Xpose4-Covariate_model to plot etas vs. covariates. I noted that the R script will give an error if too many covariates are listed in the COTAB table and won't run. However, even when I reduce the list of covariates to just a few, it will only plot AGE, CrCL and WT. It ignores all the other covariates - even if I put another covariate at the beginning of the list, it won't plot it. I don't know R well enough to figure out what's going on. Any thoughts on how to make the R script recognize the other covariates and plot them?

 

Thanks!



#2 kniefort

kniefort

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 06 November 2020 - 05:34 PM

Hi Sonya,

 

I created a test example to look at this and indeed the plot does not appear to pick up all of the covariates in the dataset. 

 

This plot as you know relies on the Xpose4 package.  There are 2 key functions within that package that are used, xpose.data() which creates an "xpose data object" that is formatted to work with xpose functions, and ranpar.vs.cov() which is the function that generates the plot.  

 

From the Xpose4 help files (e.g., https://rdrr.io/cran...ar.vs.cov.html)we see that ranpar.vs.cov() does the following: 

 

"Each of the random parameters (ETAs) in the Xpose data object, as specified in object@Prefs@Xvardef$ranpar, is plotted against each covariate present, as specified in object@Prefs@Xvardef$covariates, creating a stack of plots."

 

The problem I found in my mocked up example, is that the xpose data object created,  object@Prefs@Xvardef$covariates does not have the full list of covariates in my model.  This appears to be an issue with the xpose.data() function.

 

The workaround:  In pirana, you can do the following:

 

  • Right click on the Etas_vs_Covariates.R script and select "open script in RStudio".
  • At about line 46 you will see the call to xpose.data():  xpdb<-xpose.data(new.runno)
  • Insert a line below this and insert the following command:
  • xpdb@Prefs@Xvardef$covariates<-c("CLCR","WT","AGE","RACE","SEX","FOOD"), where the covariates listed are all of the covariates in your model
  • Run the full script in RStudio, and this should produce all of your outputs

I hope this is helpful, and please let me know if you need additional help.  For example, if you send me your NONMEM control file and a snippet of the dataset (e.g., 2 subjects), I can test and send you the modified code.

 

Keith


Edited by kniefort, 06 November 2020 - 05:36 PM.


#3 SonyaTangGirdwood

SonyaTangGirdwood

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 06 November 2020 - 07:27 PM

It worked great. Thank you so much for your help!

~Sonya



#4 kniefort

kniefort

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 10 November 2020 - 01:18 PM

That's great.  I forgot to mention that for convenience, you can store your modified script at either a User-Specific, or Project-Specific level within Pirana and access it through the scripts menu as seen below.

 

 

The "Projects" location to save to is the Pirana scripts subfolder in the current project folder, and the "My_scripts" location is at c:\users\<yourusername>\pirana\scripts.  

 

Attached Files


  • SonyaTangGirdwood likes this




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users