Graphically Speaking

Clinical Graphs

This week I had the opportunity to present a 1/2 day seminar on creating clinical graphs using the SG procedures during an In-House SAS Users’ group meeting. I have presented this seminar quite a few times now, and I always learn something.

The audience was very receptive, with some people familiar with SAS/GRAPH, and others having some knowledge of SG procedures and GTL. The seminar focused on SG procedures. Often for such seminars, I like to get an idea in advance on the type of graphs the users need to make on a regular basis. The list of graphs that were of interest included Kaplan-Meier curves and Forest Plots.

TumorSizeA couple of specific plots mentioned were the Waterfall graph for “Change in Tumor Size by Treatment” and a graph for “Incidence of Injection Site Reaction”.

Data Visualization

The Waterfall graph displays the range of change in tumor size in the study by treatment. The (simulated) data consists of the change in tumor size for subjects in a study, displayed in order of increasing reduction grouped by treatment. Reference lines are drawn at RECIST threshold of -30% and at 20%.

Data Visualization

Alternative appearances can be seen on the Web, including grouping by other criteria. SGPLOT supports skins to alter the visual appearance of the graphs as shown on the right. Click on the graph for a higher resolution image.

SGPLOT code:

title ‘Change in Tumor Size’;
title2 ‘ITT Population’;
proc sgplot data=TumorSize nowall noborder;
styleattrs datacolors=(cxbf0000 cx4f4f4f) datacontrastcolors=(black);
vbar cid / response=change group=group categoryorder=respdesc datalabel=label
datalabelattrs=(size=5 weight=bold) groupdisplay=cluster clusterwidth=1;
refline 20 -30 / lineattrs=(pattern=shortdash);
xaxis display=none;
yaxis values=(60 to -100 by -20);
inset (“C=”=”CR” “R=”=”PR” “S=”=”SD” “P=”=”PD” “N=”=”NE”) / title=’BCR’
position=bottomleft border textattrs=(size=6 weight=bold);
keylegend / title=” location=inside position=topright across=1 border;
run;

Note: GroupDisplay=Cluster is used to be able to display the bar label on top of each bar. So the ClusterWidth option is used to modify the width of the single bar in the cluster.

I have used style colors in the code to set group colors. However, one can also use the Discrete Attributes Map to ensure the consistent assignment of colors by groups as shown in the paper mentioned above.

Incidence2The other graph of interest was the “Incidence of Injection-Site Reaction by Time and Cohort”, as shown in the graph on the right. The (simulated) data shows the incidence of reaction by time and cohort using a cluster grouped bar chart.

Data Visualization

In this case, user wanted bar fill colors and fill patterns. Fill patterns can be useful when displaying the graph in a gray scale medium. SGPLOT supports usage of fill patterns for bars, which is enabled by setting the display option. The easiest way to do this is to set this option in the style. The Journal3 style shipped with SAS is designed to display both fill colors and fill patterns. So, I just used that style, and changed the colors to the ones I wanted using the StyleAttrs statement. You can also do this by deriving a custom style.

SGPLOT Code:

ods listing style=journal3;
proc sgplot data=Incidence nowall noborder;
styleattrs datacolors=(gray pink lightgreen lightblue) datacontrastcolors=(black);
vbar time / response=incidence group=group groupdisplay=cluster;
xaxis discreteorder=data;
yaxis offsetmax=0.2;
keylegend / title=” location=inside position=top across=2 border;
run;

Full SAS code: Clinical_Graphs

%let gpath=’C:\’;
%let dpi=200;
ods html close;
ods listing gpath=&gpath image_dpi=&dpi;

/*–Generate Tumor Size data–*/
data TumorSize;
length cid $ 3;
label change=’Change from Baseline (%)’;
do id=1 to 25;
cid=put(id, 2.0);
change=30-120*ranuni(2);
group=ifc(int(ranuni(2)+0.5), ‘Trt1’, ‘Trt2′);

if mod(id, 5) = 1 then label=’C’;
if mod(id, 5) = 2 then label=’R’;
if mod(id, 5) = 3 then label=’S’;
if mod(id, 5) = 4 then label=’P’;
if mod(id, 5) = 0 then label=’N’;

if change > 0 then do; low=0; high=change; lowlabel=”; highlabel=label; end;
else do; high=0; low=change; lowlabel=label; highlabel=”; end;
output;
end;
run;

/*–Change in Tumor Size Graph–*/
ods listing style=listing;
ods graphics / reset width=5in height=3in imagename=’TumorSize’;
title ‘Change in Tumor Size’;
title2 ‘ITT Population’;
proc sgplot data=TumorSize nowall noborder;
styleattrs datacolors=(cxbf0000 cx4f4f4f) datacontrastcolors=(black);
vbar cid / response=change group=group categoryorder=respdesc datalabel=label
datalabelattrs=(size=5 weight=bold) groupdisplay=cluster clusterwidth=1;
refline 20 -30 / lineattrs=(pattern=shortdash);
xaxis display=none;
yaxis values=(60 to -100 by -20);
inset (“C=”=”CR” “R=”=”PR” “S=”=”SD” “P=”=”PD” “N=”=”NE”) / title=’BCR’
position=bottomleft border textattrs=(size=6 weight=bold) titleattrs=(size=7);
keylegend / title=” location=inside position=topright across=1 border;
run;
title;

/*–Generate Injection Site Reaction data–*/
data Incidence;
drop fac;
label Incidence=’Incidence of Erythema’;

fac=0.6;
do Time= ‘0 Min’, ’10 Min’, ’20 Min’, ’30 Min’, ’60 Min’, ‘2 Hr’, ‘4 Hr’, ‘8 hr’, ’24 Hr’, ’72 Hr’;
do Group=’Cohort 1′, ‘Cohort 2’, ‘Cohort 3’, ‘Cohort 4′;
Incidence=fac/2+ ranuni(3)*fac;
output;
end;
fac = 0.6*fac;
end;
run;

/*–Incidence Graph–*/
ods graphics / reset width=5in height=3in imagename=’Incidence’;
title ‘Incidence of Injection-site Reaction by Time and Cohort – Erythema’;
title2 ‘ATT Population’;
ods listing style=journal3;
proc sgplot data=Incidence nowall noborder;
styleattrs datacolors=(gray pink lightgreen lightblue ) datacontrastcolors=(black);
vbar time / response=incidence group=group groupdisplay=cluster baselineattrs=(thickness=0);
xaxis discreteorder=data;
yaxis offsetmax=0.2;
keylegend / title=” location=inside position=top across=2 border autoitemsize valueattrs=(size=8);
run;
title;

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s