Graphically Speaking

Clinical graphs: Waterfall plot ++

Waterfall plots have gained in popularity as a means to visualize the change in tumor size for subjects in a study. The graph displays the reduction in tumor size in ascending order with the subjects with the most reduction on the right. Each subject is represented by a bar classified by the treatment. The type of response is often shown at the end of the bar, such as CR – Complete Response, PD – Progressive Disease etc.

Data Visualization

Recently, an example of a 3D Waterfall plot was sent to me by a SAS user. The user indicated that such graphs (shown below) are being requested due to the ability to display more information in the same graph.

Data Visualization

Reviewing the 3D graph provided by the user, certain aspects of the graph became evident. While the 3D visual is certainly an eye-catcher, there may be some significant drawbacks in this graph:

  • The data depicted is really not 3D in nature. There is only one independent variable in the data, that is the subject id. These are placed along the bottom sorted by the change in tumor size. I will call this the x-axis.
  • There are multiple measures being displayed by subject id. The tumor size is displayed on the vertical axis (z-axis). The duration of treatment is displayed along the axis going into the page (y-axis).
  • Some additional indicators are also plotted on the duration bars indicating subjects who discontinued. There are some other indicators that are not very clear.
  • Some bars can be (and are) occluded behind other bars.
  • The x-axis does not show the subject id, but instead some other classification (maybe type). It is better to move these indicators closer to the bar ends.
  • It is hard to line up the x-axis values with the tumor size bars and also the duration bars.
  • There is a lot of wasted “blue” space in this visual.
  • This visual uses perspective projection, so it is harder to visually compare the bar lengths.
  • I don’t know what the red dot in the middle is for, or what it is aligned with.

Since there is only one independent variable (SubjectId), it is possible to display all the necessary information in a 2D visual, as shown below. The visual is very clean and easy to understand, and shows all the information in the 3D graph. Let us keep in mind my data is purely simulated using random number functions.

Data Visualization

The subjects are again displayed along the horizontal x-axis in increasing order of reduction in tumor size. In this case, we have extended the original graph as follows:

  • Display the duration of treatment for each subject in the upper part of the graph, each bar is correctly aligned with the subject id, and very easy to see.
  • The actual duration in days can easily be displayed on top of the duration bar.
  • A red star is displayed in the upper bar to indicate subjects that discontinued.
  • Subdued blue alternate bands are displayed to help the eye line up the bars. These can be visible or not based on your screen settings and can be adjusted or removed.
  • Additional response data can easily be incorporated as additional plot elements above or below this visual.
  • Additional measures can be easily overlaid on either the tumor reduction, or duration bars.

In general, when there is only one independent variable in the data, displaying the multiple responses in a 2D graphs is very effective. Magnitude of the measures can be correctly compared, and additional indicators can be placed near the relevant item for easier decoding of the data.

In this graph, the tumor response bars are colored by treatment, but could also be colored by the dosage or other measures.

SGPLOT Program:

title ‘Change in Tumor Size’;
title2 ‘ITT Population’;
proc sgplot data=TumorSizeSort nowall noborder nocycleattrs;
styleattrs datacolors=(cxbf0000 cx4f4f4f) datacontrastcolors=(black) axisextent=data;
symbolchar name=mystar char=’002a’x / voffset=-0.5 scale=3;
vbarparm category=cid response=change / group=group datalabel=label dataskin=pressed
datalabelattrs=(size=5 weight=bold) groupdisplay=cluster clusterwidth=1;
vbarparm category=cid response=duration / datalabel=duration y2axis dataskin=pressed
datalabelattrs=(size=5 weight=bold) groupdisplay=cluster clusterwidth=1
fillattrs=(color=cxcfcf7f);
scatter x=cid y=drop / y2axis markerattrs=(symbol=mystar color=red size=10);
refline 20 -30 / lineattrs=(pattern=shortdash);
xaxis display=none colorbands=odd colorbandsattrs=(transparency=0.6);
yaxis values=(60 to -100 by -20) offsetmax=0.45 labelpos=datacenter offsetmin=0;
y2axis offsetmin=0.6 offsetmax=0.02 labelpos=datacenter;
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=” border;
run;

With SGPLOT, it is possible to create this graph with two data areas as shown here, using the y and Y2 axes. It would be better to created this graph using GTL. GTL provides us extended functionality to create multiple data areas with axis alignment. This will allows us to place both the y axes on the left (or right), and add more data displays to include additional relevant data.

Full code: Waterfull

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

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), ‘Treatment 1’, ‘Treatment 2′);
Duration=floor(50+100*ranuni(2));
Drop=ifn(ranuni(2) < 0.3, floor(duration-10), .);
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’;
output;
end;
run;

proc sort data=TumorSize out=TumorSizeSort;
by descending change;
run;

ods html;
proc print data=TumorSizeSort(obs=10);
run;
ods html close;

/*–Change in Tumor Size–*/
ods listing style=listing;
ods graphics / reset width=5in height=3in imagename=’TumorSize’;
title ‘Change in Tumor Size’;
title2 ‘ITT Population’;
proc sgplot data=TumorSizeSort nowall noborder;
styleattrs datacolors=(cxbf0000 cx4f4f4f) datacontrastcolors=(black);
vbarparm category=cid response=change / group=group 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;

/*–Change in Tumor Size with Duration–*/
ods listing style=listing;
ods graphics / reset width=5in height=3.5in imagename=’TumorSize_Duration_Extent’;
title ‘Change in Tumor Size’;
title2 ‘ITT Population’;
proc sgplot data=TumorSizeSort nowall noborder nocycleattrs;
styleattrs datacolors=(cxbf0000 cx4f4f4f) datacontrastcolors=(black) axisextent=data;
symbolchar name=mystar char=’002a’x / voffset=-0.5 scale=3;
vbarparm category=cid response=change / group=group datalabel=label dataskin=pressed
datalabelattrs=(size=5 weight=bold) groupdisplay=cluster clusterwidth=1;
vbarparm category=cid response=duration / datalabel=duration y2axis dataskin=pressed
datalabelattrs=(size=5 weight=bold) groupdisplay=cluster clusterwidth=1
fillattrs=(color=cxcfcf7f);
scatter x=cid y=drop / y2axis markerattrs=(symbol=mystar color=red size=10);
refline 20 -30 / lineattrs=(pattern=shortdash);
xaxis display=none colorbands=odd colorbandsattrs=(transparency=0.6);
yaxis values=(60 to -100 by -20) offsetmax=0.45 labelpos=datacenter offsetmin=0;
y2axis offsetmin=0.6 offsetmax=0.02 labelpos=datacenter;
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=” border;
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