Back to the Top
Hi
I am new to modelling and would like to know is there any script available to sort data for nonmen...
i.e., .csv file as I have the data set like
Pt no Wt age sex Conc(0min) 1hr 2hr 3hr 5hr.....
1 75 69 F 0 5.5 15.5 18.5 10.5
2 68 75 M 0 10.5 25.5
I thing for nonmem the .csv file should be
Pt no Time Wt age sex Conc.....
1 0
1 1
1 2
1 3
1 4
1 5
I have 50 Patients and looking for some thing to automate the whole thing ...vb script...or a something in R or in perl
Thank for your help ....
Cheers
Chandramouli Radhakrishnan
Back to the Top
The following message was posted to: PharmPK
You can use reshape package in R (please look at help file for reshape).
Here is step by step demo:
d <- read.csv("C.../test.csv")
>d
id wt age sex time0 time1 time2 time3 time5
1 1 75 69 F 0 5.5 15.5 18.5 10.5
2 2 68 75 M 0 10.5 25.5 20.0 15.0
#separate demographic and conc data
demog <- d[,1:4]
conc <- d[,c(1,5:9)]
> demog
id wt age sex
1 1 75 69 F
2 2 68 75 M
> conc
id time0 time1 time2 time3 time5
1 1 0 5.5 15.5 18.5 10.5
2 2 0 10.5 25.5 20.0 15.0
#use reshape to change the data structure to "long"
conc <- reshape(conc, varying=names(conc)[2:6], v.names="conc",
direction="long")
#sort data by ID and TIME
conc <- conc[order(conc$id, conc$time),]
> conc
id time conc
1.1 1 1 0.0
1.2 1 2 5.5
1.3 1 3 15.5
1.4 1 4 18.5
1.5 1 5 10.5
2.1 2 1 0.0
2.2 2 2 10.5
2.3 2 3 25.5
2.4 2 4 20.0
2.5 2 5 15.0
#merge with demog data
d <- merge(conc, demog, by="id", all=TRUE)
> d
id time conc wt age sex
1 1 1 0.0 75 69 F
2 1 2 5.5 75 69 F
3 1 3 15.5 75 69 F
4 1 4 18.5 75 69 F
5 1 5 10.5 75 69 F
6 2 1 0.0 68 75 M
7 2 2 10.5 68 75 M
8 2 3 25.5 68 75 M
9 2 4 20.0 68 75 M
10 2 5 15.0 68 75 M
#--end of R
Hope this helps.
Kaori
Kaori Ito Ph.D
Pfizer Inc., Pharmacometrics
50 Pequot Ave
New London, CT
USA
Back to the Top
Hi Radhakrishnan,
Following R code is useful for your data manipulation.
data <- read.csv('C:\\Users\\name\\Desktop\\sample.csv', header = T)
long <- reshape(data, v.names = "Conc", direction = "long", varying = 5:9, split = list(regexp = "l", include = TRUE))
names(long)[5] <- c("Conc")
long <- long[order(long$Pt.no),]
long <- long[,-c(5,7)]
long$Time <- rep(c(0,1,2,3,5))
long
Note: change the conc column headers to Conc0 Conc1 Conc2 Conc3 Conc5
input data:
Pt.no Wt age sex Conc0 Conc1 Conc2 Conc3 Conc5
1 75 69 F 0 5.5 15.5 18.5 7.5
2 68 75 M 0 5.0 10.0 20.0 8.0
output:
Pt.no Wt age sex Conc Time
1.1 1 75 69 F 0.0 0
1.2 1 75 69 F 5.5 1
1.3 1 75 69 F 15.5 2
1.4 1 75 69 F 18.5 3
1.5 1 75 69 F 7.5 5
2.1 2 68 75 M 0.0 0
2.2 2 68 75 M 5.0 1
2.3 2 68 75 M 10.0 2
2.4 2 68 75 M 20.0 3
2.5 2 68 75 M 8.0 5
Hope this helps you
Akshanth
Akshanth Polepally
Graduate Student
University of Minnesota
Back to the Top
The following message was posted to: PharmPK
Dear Chandramouli,
If you have access to Phoenix WinNonlin 6.1 (free upgrade from WinNonlin 5, 4, 3 etc.) then you already have access to a whole bank of simple, template-able data management tools for pivotting, splitting, merging, appending etc..
The basic data transformation you require can be done in a single step in using the "Stacker" object under the "Data" tools menu.
Furthermore if you have Connect licensed (free to WinNonlin Enterprise licensees, also available separately to WinNonlin), you can send the results of this data transformation directly to your NONMEM run and manage and compare different models within the built in NONMEM model comparer. Other tools currently integrated are R, SAS, S-plus and SigmaPlot, so if you prefer to use R for pre- and post-processing that can be managed within the Phoenix environment too.
I can't send attachments to the list but if you want to ask your question on www.pharsight.com/extranet I'd be happy to post the workflow template and some explanatory screen shots.
Lastly, if you're new to modelling you may benefit from looking at the Phoenix's own Population analysis tool, NLME
http://www.pharsight.com/products/prod_phoenix_nlme_home.php
For a basic overview of Phoenix check out one of the recorded webinars;
http://www.pharsight.com/events/eventsonline_archive.php#replay_032
Best regards,
Simon.
--
Simon.Davis.-at-.certara.com
Senior Scientific Consultant
Pharsight- A Certara(tm) Company
--
[Hmm, is there a suitable pivot function in a spreadsheet such as Excel? - db]
Want to post a follow-up message on this topic?
If this link does not work with your browser send a follow-up message to PharmPK@boomer.org with "NONMEM perl script" as the subject | Support PharmPK by using the |
Copyright 1995-2011 David W. A. Bourne (david@boomer.org)