Image | Click on top image to enlarge r image and bottom one to enlarge SAS image. |
Title | Profile Plot: Mean QTc by Time and Treatment |
Graph_Subgroup | ECGVitals |
ECG_Vitals_Clinical_Question | 5. What is the relationship to drug concentration? |
Contributor/Email |
Rich Anziano (richard.j.anziano@pfizer.com) Max Cherny (Max.2.Cherny@gsk.com) |
Background | The figure presented here presents the mean profile over time from a tQt trial. This figure is intended to explore the effect of all four treatments. Since these are the same subjects in each of four treatment periods the data lend to creating a placebo adjusted change from baseline plot (often referred to as delta-delta plot). |
Keywords | tqt, profile plot, qtc, change from baseline |
References | |
Datasets | Other |
CDISC_Data | |
Other_Data | Anziano QTc Profiles ASCII File |
CLASSIFICATIONS | |
Graph_Type | Line Plot |
Variable_Relationship | |
Data_Types | |
Special_Considerations | |
Code_Available | Yes |
Software Program | R, SAS |
Software | R, SAS 9.2 |
R-Code - Attachment | |
R-Code |
#code courtesy of Max Cherny rm(list = ls()) # clear objects graphics.off() # close graphics windows library(car) #initialize libraries library(ggplot2) #initialize libraries require(gridExtra) #Need gridExtra for gridtext function #read in the data bm <- read.table("ecg_vitals_G01.dat", header=TRUE, sep=",", na.strings="NA", dec=".", strip.white=TRUE) #initialize file name and path somePDFPath = "ecg_vitals_G01.pdf" pdf(file=somePDFPath, paper='A4r', width=15, height=8) # format treatment code bm$grouptxt <- factor(bm$group, labels = c('Exp lo','Exp hi','Pbo','Moxi') ) #jitter x timepoints bm$x<-bm$tpd bm[bm$group==2,]$x <- bm[bm$group==2,]$x +0.02 #increase jittering distance as needed bm[bm$group==3,]$x <- bm[bm$group==3,]$x +0.04 #increase jittering distance as needed bm[bm$group==4,]$x <- bm[bm$group==4,]$x +0.06 #increase jittering distance as needed #determine number of groups number_of_trt<- as.numeric(max(unique(bm$group))) ##symbol of points plotchar <- seq(c("1", "2", "3","4","5")) #set up colors for each group colors<-c("cyan", "blue","red", "black") #set up margins par(new=F, par(mar=c(14,5,8,1))) #sort by group bm <- bm[order(bm$group, bm$tpd ),] #create dataset with unique groups unique_trt<-subset(bm, duplicated(group)) #maximum Y ymax=30 #Create one plot per each group in this loop for (ii in 1:number_of_trt) { #create a temporary dataset for each group bm_temp <- subset(bm, group==ii ) par(new=T) #make sure all plots are added together in a loop #create empty plot. The points will be added later plot( bm_temp$estimate~bm_temp$x, ylim = c(-10, ymax) , type="n", #supress plot xlab="", yaxt = "n", xaxt="n", ylab="QTc Change (ms) - Fridericia Correction ", xlim = c(0, 12) ) #plot lines for each group lines(bm_temp$x, bm_temp$estimate, lwd=2, ljoin=1, lend=3, lmitre=3, lty=1, col=colors[ii], pch=plotchar[ii] ) ##plot points for each group points(bm_temp$x, bm_temp$estimate, cex=0.6, #size of points col=colors[ii], #color of points pch=plotchar[ii]) #symbol of points temp <- subset(bm, group==ii ) temp_trt <- subset(unique_trt, group==ii ) #produce table of number of subjects text(x=temp$tpd, y=(-ii*3)-25, temp$n, cex=0.8, xpd=T, col=colors[ii]) text(x=-1, y=(-ii*3)-25, temp_trt$grouptxt, cex=0.8, xpd=T, pos=4) #plot whiskers segments (x0=temp$x, x1=temp$x, y0=temp$lower, y1=temp$upper, col=colors[ii]) segments (x0=temp$x-0.1, x1=temp$x+0.1, y0=temp$upper, y1=temp$upper, col=colors[ii]) segments (x0=temp$x-0.1, x1=temp$x+0.1, y0=temp$lower, y1=temp$lower, col=colors[ii]) } #end of for (ii in 1:number_of_trt) #display x axis axis(1, tick=T, at=c(0, 0.5, 1, 2, 3, 4, 6, 9, 12), labels = c('8:00', '8:30', '9:00', '10:00', '11:00', '12:00', '14:00', '17:00','20:00')) #display y axis yaxis_marks <- seq(-10,ymax,by=5) axis(2, tick=T, at=yaxis_marks, las=2 ) #use las to display horizontal label on Y axis #add reference line abline (h=0, lty=2) # add a legend legend("bottom" , inset=-0.3, xpd=T, as.character( unique_trt$grouptxt), #text for legend cex=1, col=colors, pch=plotchar, ncol=number_of_trt, title="Treatments:") #x and y xaxis labels text(x=mean(bm$tpd), y=-51, "Time of Day", cex=0.9, xpd=T) text(x=-5, y=mean(bm$estimate)+20, "Placebo Adjusted QTc Change (milliseconds) - Fridericia Correction", cex=0.9, xpd=T, srt=90, pos=1) # Add minor tick marks library(Hmisc) #nx number of intervals in which to divide the area between major tick marks on the X-axis. Set to 1 to suppress minor tick marks. #ny same as nx but for the Y-axis #tick.ratio ratio of lengths of minor tick marks to major tick marks. The length of major tick marks is retrieved from par("tck"). minor.tick(nx=1, ny=10) #add text at fixed positions grid.text(paste("user_id: ",toupper(format(Sys.time(), "%d%B%Y %H:%M"))), x=0.01, y=0.06,just="left") grid.text("Protocol: text", x=0.01, y=0.93,just="left") grid.text("Population: Text", x=0.01, y=0.9,just="left") grid.text( paste("Page 1 of 1"), x=0.9, y=0.9,just="left") grid.text(paste("ECG/VITALS G1"), x=0.5, y=0.88) grid.text("Figure Number", x=0.5, y=0.85) grid.text("Title2 (Base R)", x=0.5, y=0.82) dev.off() |
SAS-Code - Attachment | Link to Matange QTc Profile SAS Code |
SAS-Code | |
Stata-Code - Attachment | |
Stata-Code | |
Other Code - Attachment | |
Other Code | |
Disclaimer | The views expressed within CTSpedia are those of the author and must not be taken to represent policy or guidance on the behalf of any organization or institution with which the author is affiliated. |
Permission |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT OLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Reference Image |
![]() |