Welcome to the Three Ring %CIRCOS: An Example of Creating a Circular Graph without a Polar Axis

Similar documents
R s s f. m y s. SPH3UW Unit 7.3 Spherical Concave Mirrors Page 1 of 12. Notes

USING GRAPHING SKILLS

Programming in Fortran 90 : 2017/2018

Computer models of motion: Iterative calculations

3D vector computer graphics

Complex Numbers. Now we also saw that if a and b were both positive then ab = a b. For a second let s forget that restriction and do the following.

Support Vector Machines

A Binarization Algorithm specialized on Document Images and Photos

Mathematics 256 a course in differential equations for engineering students

AP PHYSICS B 2008 SCORING GUIDELINES

Notes on Organizing Java Code: Packages, Visibility, and Scope

TN348: Openlab Module - Colocalization

Introduction to Geometrical Optics - a 2D ray tracing Excel model for spherical mirrors - Part 2

Accounting for the Use of Different Length Scale Factors in x, y and z Directions

Lecture 5: Multilayer Perceptrons

MATHEMATICS FORM ONE SCHEME OF WORK 2004

Circuit Analysis I (ENGR 2405) Chapter 3 Method of Analysis Nodal(KCL) and Mesh(KVL)

6.854 Advanced Algorithms Petar Maymounkov Problem Set 11 (November 23, 2005) With: Benjamin Rossman, Oren Weimann, and Pouya Kheradpour

Compiler Design. Spring Register Allocation. Sample Exercises and Solutions. Prof. Pedro C. Diniz

The Codesign Challenge

For instance, ; the five basic number-sets are increasingly more n A B & B A A = B (1)

TEST-05 TOPIC: OPTICS COMPLETE

Assignment # 2. Farrukh Jabeen Algorithms 510 Assignment #2 Due Date: June 15, 2009.

Life Tables (Times) Summary. Sample StatFolio: lifetable times.sgp

SLAM Summer School 2006 Practical 2: SLAM using Monocular Vision

Problem Set 3 Solutions

REFRACTION. a. To study the refraction of light from plane surfaces. b. To determine the index of refraction for Acrylic and Water.

Steps for Computing the Dissimilarity, Entropy, Herfindahl-Hirschman and. Accessibility (Gravity with Competition) Indices

S1 Note. Basis functions.

ROBOT KINEMATICS. ME Robotics ME Robotics

Computer Animation and Visualisation. Lecture 4. Rigging / Skinning

UNIT 2 : INEQUALITIES AND CONVEX SETS

A Fast Visual Tracking Algorithm Based on Circle Pixels Matching

2D Raster Graphics. Integer grid Sequential (left-right, top-down) scan. Computer Graphics

2x x l. Module 3: Element Properties Lecture 4: Lagrange and Serendipity Elements

9. BASIC programming: Control and Repetition

Kinematics of pantograph masts

y and the total sum of

Reading. 14. Subdivision curves. Recommended:

Some Advanced SPC Tools 1. Cumulative Sum Control (Cusum) Chart For the data shown in Table 9-1, the x chart can be generated.

X- Chart Using ANOM Approach

Solutions to Programming Assignment Five Interpolation and Numerical Differentiation

Modeling Concave Globoidal Cam with Swinging Roller Follower: A Case Study

Machine Learning 9. week

Brave New World Pseudocode Reference

Agenda & Reading. Simple If. Decision-Making Statements. COMPSCI 280 S1C Applications Programming. Programming Fundamentals

A high precision collaborative vision measurement of gear chamfering profile

Loop Permutation. Loop Transformations for Parallelism & Locality. Legality of Loop Interchange. Loop Interchange (cont)

Analysis of Continuous Beams in General

Analysis of 3D Cracks in an Arbitrary Geometry with Weld Residual Stress

CMPS 10 Introduction to Computer Science Lecture Notes

The Research of Ellipse Parameter Fitting Algorithm of Ultrasonic Imaging Logging in the Casing Hole

VRT012 User s guide V0.1. Address: Žirmūnų g. 27, Vilnius LT-09105, Phone: (370-5) , Fax: (370-5) ,

3-Wheel Swerve Drive - The Trouble with Tribots

Parallelism for Nested Loops with Non-uniform and Flow Dependences

LOOP ANALYSIS. The second systematic technique to determine all currents and voltages in a circuit

Reducing Frame Rate for Object Tracking

Hermite Splines in Lie Groups as Products of Geodesics

APPLICATION OF A COMPUTATIONALLY EFFICIENT GEOSTATISTICAL APPROACH TO CHARACTERIZING VARIABLY SPACED WATER-TABLE DATA

Biostatistics 615/815

Skew Angle Estimation and Correction of Hand Written, Textual and Large areas of Non-Textual Document Images: A Novel Approach

Wightman. Mobility. Quick Reference Guide THIS SPACE INTENTIONALLY LEFT BLANK

Parallel Numerics. 1 Preconditioning & Iterative Solvers (From 2016)

Synthesizer 1.0. User s Guide. A Varying Coefficient Meta. nalytic Tool. Z. Krizan Employing Microsoft Excel 2007

Parameter estimation for incomplete bivariate longitudinal data in clinical trials

with Optic65 and Optic25 Cameras FOR OUTDOOR TRACKING ONLY unless used in conjunction with the Indoor Tracking Accessory.

Multi-view 3D Position Estimation of Sports Players

Feature Reduction and Selection

Slide 1 SPH3UW: OPTICS I. Slide 2. Slide 3. Introduction to Mirrors. Light incident on an object

AMath 483/583 Lecture 21 May 13, Notes: Notes: Jacobi iteration. Notes: Jacobi with OpenMP coarse grain

VISUAL SELECTION OF SURFACE FEATURES DURING THEIR GEOMETRIC SIMULATION WITH THE HELP OF COMPUTER TECHNOLOGIES

FEATURE EXTRACTION. Dr. K.Vijayarekha. Associate Dean School of Electrical and Electronics Engineering SASTRA University, Thanjavur

A fault tree analysis strategy using binary decision diagrams

CS1100 Introduction to Programming

A DATA ANALYSIS CODE FOR MCNP MESH AND STANDARD TALLIES

Kiran Joy, International Journal of Advanced Engineering Technology E-ISSN

An Optimal Algorithm for Prufer Codes *

Monte Carlo Rendering

The Greedy Method. Outline and Reading. Change Money Problem. Greedy Algorithms. Applications of the Greedy Strategy. The Greedy Method Technique

ECONOMICS 452* -- Stata 11 Tutorial 6. Stata 11 Tutorial 6. TOPIC: Representing Multi-Category Categorical Variables with Dummy Variable Regressors

Content Based Image Retrieval Using 2-D Discrete Wavelet with Texture Feature with Different Classifiers

Sample Solution. Advanced Computer Networks P 1 P 2 P 3 P 4 P 5. Module: IN2097 Date: Examiner: Prof. Dr.-Ing. Georg Carle Exam: Final exam

Inverse Kinematics (part 2) CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Spring 2016

NAG Fortran Library Chapter Introduction. G10 Smoothing in Statistics

ON SOME ENTERTAINING APPLICATIONS OF THE CONCEPT OF SET IN COMPUTER SCIENCE COURSE

Loop Transformations for Parallelism & Locality. Review. Scalar Expansion. Scalar Expansion: Motivation

Sequential search. Building Java Programs Chapter 13. Sequential search. Sequential search

ELEC 377 Operating Systems. Week 6 Class 3

VFH*: Local Obstacle Avoidance with Look-Ahead Verification

On Some Entertaining Applications of the Concept of Set in Computer Science Course

News. Recap: While Loop Example. Reading. Recap: Do Loop Example. Recap: For Loop Example

Performance Evaluation of Information Retrieval Systems

CSE 326: Data Structures Quicksort Comparison Sorting Bound

Improvement of Spatial Resolution Using BlockMatching Based Motion Estimation and Frame. Integration

An Approach in Coloring Semi-Regular Tilings on the Hyperbolic Plane

5.0 Quality Assurance

Parallel matrix-vector multiplication

Why visualisation? IRDS: Visualization. Univariate data. Visualisations that we won t be interested in. Graphics provide little additional information

Improving Low Density Parity Check Codes Over the Erasure Channel. The Nelder Mead Downhill Simplex Method. Scott Stransky

A SYSTOLIC APPROACH TO LOOP PARTITIONING AND MAPPING INTO FIXED SIZE DISTRIBUTED MEMORY ARCHITECTURES

Transcription:

PharmaSUG 2018 - Paper DV14 Welcome to the Three Rng %CIRCOS: An Example of Creatng a Crcular Graph wthout a Polar Axs Jeffrey Meyers, Mayo Clnc ABSTRACT An nternal graphcs challenge between SAS and R programmers wthn Mayo Clnc led to the creaton of a CIRCOS plot wth the SAS 9.4M3 features. A CIRCOS plot s a crcular vsualzaton of the relatonshp between objects, postons and other tme-pont related data. The CIRCOS plot features a curved rectangle for each node or object around the permeter of the crcle, and a Bézer curve for each path between nodes that s pulled towards the center of the crcle. Each rectangle and curve s sze s determned by ther proporton of the total populaton. The prmary challenge of creatng ths plot wth the current SAS SG procedures s that these procedures do not nclude polar axes to smplfy plottng crcular or curved objects. The macro %CIRCOS s an example of overcomng these lmtatons creatvely usng trgonometry to prove that these types of graphs are stll possble wthout polar axes. INTRODUCTION The Mayo Clnc Bomedcal Statstcs and Informatcs dvson has programmers that use SAS, R and other statstcal software. Many programmers prmarly focus on one of the software packages, and perodcally the dvson hosts a challenge between the programmers n the Anythng You Can Do I Can Do Better theme. The most recent challenge was centered on utlzng and demonstratng the newest features avalable n both SAS and R graphcs. It was durng ths challenge that one of the short comngs of the newest SAS graphng software was made evdent: the absence of polar axes to create round or crcular plots. The task was to create a CIRCOS plot whch s almost entrely based upon curved rectangles rotated n a crcle around a center pont. Fgure 1 s an example of a CIRCOS plot. 06 05 07 04 08 03 09 02 01 10 1.92 paths per percent Fgure 1. The CIRCOS plot dsplays connectons between groups and s explaned n more detal later n the paper. 1

In addton to the lack of polar axes, SAS does not nclude nnate features for creatng curved rectangles or a curved axs. Ths paper focuses on overcomng these lmtatons to meet the challenge and create a hgh-qualty CIRCOS plot wthn a Cartesan axs envronment, to nspre other programmers to fnd creatve methods of producng graphs currently unavalable n the current envronment, and to encourage SAS to consder addng another axs type to ther repertore. THE CURRENT LIMITATIONS The most straghtforward method of plottng shapes around a crcle s to use a polar axs whch s not currently an opton wthn the SAS graphcs procedures. The followng s a comparson of creatng a curved rectangle n a polar axs versus lnear axes. DRAWING A CURVED RECTANGLE IN A POLAR AXIS Polar axes revolve from an orgn axs (P) and have two coordnates: a dstance (d) and an angle (θ). The dstance gves the radus of a crcle drawn, and the angle gves the arc drawn from the orgn axs. Fgure 2 s an example of a polar axs. (d,θ) d (0,0) P (d,0) Fgure 2. An arc s drawn by specfyng a dstance (d) and an angle (θ). The arc s drawn from the orgn axs (P) to the current poston. The followng llustrates the ease of drawng a curved rectangle on a polar axs: Fgure 3 s an example of drawng a curved rectangle on a polar axs. θ (d 1,θ 2 ) (d 1,θ 1 ) (d 2,θ 2 ) (d 2,θ 1 ) (0,0) P Fgure 3. A curved rectangle can be drawn wth two dstances and an arc between two angles. Drawng arcs from θ 1 to θ 2 at dstances d 1 and d 2 and then connectng (d 1, θ 1 ), (d 1, θ 2 ), (d 2, θ 2 ), (d 2, θ 1 ) wth reference to the orgn axs (P) would yeld a perfect curved rectangle for a CIRCOS plot. Ths would be an easy setup for a POLYGON plot statement f a polar axs was avalable. 2

DRAWING A CURVED RECTANGLE IN LINEAR AXES There are currently no functons or plot types n the SG graphcs set to create an arc, but due to the freedom of lnear axes the concept of an arc can be created by connectng enough ponts usng straght lne along the rght curve.(.e. usng straght lne to approxmate the curve). The more ponts that are drawn the smoother the arc becomes. Fgure 4 s an example of drawng an arc wthn lnear axes. 3 Ponts 5 Ponts 7 Ponts FIGURE 4. The more ponts that are used to draw the arc the smoother the arc becomes. Ths s an neffcent method to create a curve, but one of the only methods to create an exact curved polygon wth current avalable methods. Wth ths method n mnd and wth the rght equatons SAS can be forced nto drawng curved polygons wthn lnear axes. THE UNIT CIRCLE The unt crcle s a concept from trgonometry that bases a crcle of radus 1 around the 0, 0 coordnates of Cartesan (lnear) axes. Note that the notaton (a, b) n the followng fgure stands for the poston of the ponts. Fgure 5 s the unt crcle. (0,1) (-1,0) (0,0) (1,0) (0,-1) Fgure 5. The unt crcle s centered at the Cartesan coordnates 0, 0 and has a radus of 1. 3

Tracng around the crcle can be easly accomplshed usng the basc trgonometry equatons sne and cosne wth a specfed angle. The followng equaton dsplays how to calculate the x and y coordnates for each provded angle: x d cos( ) y d sn( ) The coordnates are smply the dstance (radus of crcle) multpled by the functon of the angle (Θ) where the angle s measured counter clockwse from the x-axs. The unt crcle smplfes these equatons by makng d equal to 1. Arcs can be easly plotted around ths crcle by creatng x and y coordnates from across an angle. A quarter crcle arc can be created by plottng ponts from Θ equal to 0 degrees up to Θ equal to 90 degrees. Note that the SIN and COS functons n SAS use angles measured n radans whch can be converted from degrees wth the followng equaton. 360 2 One complete crcle s 360 degrees whch s equvalent to two p radans. WHAT IS A CIRCOS PLOT? A CIRCOS plot s a condensed crcular vsualzaton of the relatonshp between objects, postons and other tme-pont related data. They are bult out of two prmary components: the outer crcle and the nner connectng curves. There are many optonal add-ons dependng on the software beng used such as havng multple layers of outer crcles and addng other dstrbuton graphs such as hstograms wthn the crcle. The program hghlghted wth ths paper creates CIRCOS plots wth three prmary peces: the outer crcle, an nner crcle, and the connectng curves. The followng s the code used to create the randomly generated dataset and correspondng macro call: data random; call streamnt(123); do = 1 to 100; u = rand("unform"); u2 = rand("unform"); before = 1 + floor(7*u); after = 4 + floor(7*u2); format before after z2.; drop u u2; run; %CIRCOS(DATA=random, BEFORE=before, AFTER=after, PLOTNAME=example1, PLOTTYPE=emf, BORDER=1); OUTER CIRCLE The outer crcle uses curved rectangles to vsually convey the proporton of the total number of paths enterng and leavng each group. The axs s prnted on the outer border of the rectangles wth each tck mark representng one percentage pont of the total sample sze. Each group s labeled wth the label rotated to be perpendcular to the crcle, and each group s colored dfferently. 4

Fgure 6 dsplays the Outer Crcle of the CIRCOS plot wth the unt crcle overlayed. (0,1) (-1,0) (0,0) (1,0) (0,-1) Fgure 6. Each group s colored dfferently wthn the Outer Crcle, and the lengths are determned by the groups proporton of the total populaton. A percentage of the total crcle (macro default of 5%) s used to provde a gap between the groups. INNER CIRCLE The nner crcle vsually represents what proporton of the group s leavng to another group (called path hereafter) versus what proporton of the group s arrvng from another group. The more complete the nner crcle bar s the more paths that are leavng to other groups. A blank bar means all paths are gong to that group. Fgure 7 adds n the Inner Crcle to Fgure 6. (0,1) (-1,0) (0,0) (1,0) (0,-1) Fgure 7. The Inner Crcle dsplays how many paths are leavng a group versus endng at a group. The absence of an Inner Crcle bar ndcates that all paths are endng at a group. 5

CONNECTING CURVES The curves showng the connectons from one group to another are known as Bézer curves. These are curves that revolve around three ponts: start, end, and a mdpont. The curve s pulled n the drecton of the mdpont as t bends from the start to the end. These curves wdths are dfferent at the start and end wth both beng proportonal to the number of paths leavng or enterng the group wth that curve. Suppose there are two groups A and B. Group A has 20 patents leavng and group B has 30 patents enterng. Specfcally, there are 10 patents gong from group A to group B. Ths Bézer curve wll be 50% of the wdth of group A s departng paths and 33.3% of the ncomng paths to group B potentally gvng dfferent wdths at the start and end of the curve. Fgure 8 adds n the Connectng Curves to Fgure 7. (0,1) (-1,0) (0,0) (1,0) (0,-1) Fgure 8. The Connectng Curves match the color of the group they are departng from. The wdths at the start and end of the curves depend on that path s proporton of the startng and endng groups. The curves are pulled closer to the center of the crcle dependng on how far apart the startng and endng groups are. AXIS AND LABELS Each group on the OUTER CIRCLE contans ts own axs that runs across the outer border. Each tckmark s equvalent to one percent of the crcle, and each ffth tck-mark s double the sze of the others. The label for each group s centered wthn the OUTER CIRCLE rectangle and faces towards the center of the crcle. 6

Fgure 9 adds n the labels and axes to Fgure 8. (0,1) 06 05 07 04 (-1,0) (0,0) (1,0) 08 03 09 02 01 (0,-1) 10 Fgure 9. Each groups axs s ndependent of the other groups. Each label s rotated to face the center of the crcle and s anchored to the mdpont of each OUTER CIRCLE rectangle. CREATING THE PLOT DATASET GENERAL METHODS The CIRCOS macro s based on calculatng coordnates around the unt crcle wthn Cartesan or lnear coordnates. These coordnates are computed wthn DATA steps makng use of DO loops and the array facltes. The unts used for all calculatons are based on percentages meanng the percentage of the crcumference of the crcle or a percentage of the radus of the crcle. POLYGON PLOT NOTE The SAS Graph Template Language plot statement POLYGONPLOT s used to create nearly all the objects wthn the graph. The way POLYGONPLOT works s that t s gven x and y coordnates that t connects n the order of the coordnates. At the last set of coordnates POLYGONPLOT wll connect the last coordnate to the frst coordnate and then fll nsde the shape to create the fnal object. OUTER CIRCLE The length of each group s rectangle s equal to that group s proporton of the total number of paths: L Paths _ out n 1 ( Paths _ out Paths _ n Paths _ n ) Ths proporton s then drectly appled to the crcumference of the outer crcle. If group A has twenty percent of the total paths, then group A wll encompass twenty percent of the outer crcle. The wdth of the outer crcle rectangles are determned by the user wth the parameter BARWIDTH. BARWIDTH can be between 5 and 50 percent, and determnes how much of the radus of the crcle the rectangle wll cover. A bar wdth of fve percent would mean the nsde arc of the rectangle would be drawn at radus 0.95 and the outer arc of the rectangle would be drawn at radus 1.00. 7

The code to generate the coordnates for the outer crcle rectangles s run wthn a DATA step. The code below reles on two macro varables and two varables calculated earler n the macro: 1. POINTS: macro varable that determnes how many x and y coordnates are computed for each arc. Default s 10. 2. BARWIDTH: macro varable that determnes the wdth of the rectangle. Default s 0.05 (5% of the unt crcle) 3. PERCENT: macro calculated varable for the current group s proporton of the outer crcle 4. _CUM: macro calculated varable that determnes how far around the outer crcle the graph has progressed The actual DATA step code s the followng: /*Draws the outer part of the rectangle*/ do =_cum*2 to (_cum+percent)*2 by percent/&ponts; x=cos(constant("p")*); y=sn(constant("p")*); /*Draws the nner part of the rectangle. Drawn at (1-&barwdth) of the dstance from the center*/ do =(_cum+percent)*2 to _cum *2 by -percent/&ponts; x=(1-&barwdth)*cos(constant("p")*); y=(1-&barwdth)*sn(constant("p")*); The frst DO loop draws the outer arc of the rectangle, and the second DO loop draws the same arc n the reverse drecton closer to the center of the crcle. The loop s multpled by two to account for a full crcle beng 2*p radans. The sdes of the rectangles beng separated and the change n drecton that the coordnates are drawn s due to the nature of the POLYGON plot that s used to make the graph. INNER CIRCLE The length of each group s nner rectangle s equal to that group s proporton of paths leavng to total paths: L Paths Paths _ out _ out Paths _ n Very smlar code s then used to create the coordnates for the nner rectangles. The only dfference s changng the dstance that the arcs are drawn at. Two new varables are added: 1. INNERGAP: macro varable determnes how much space s between outer crcle, nner crcle, and Bézer curves. 2. PCT_START: Pre-calculated varable for the proporton of paths leavng the current group The actual DATA step code s the followng: /*Draws the outer part of the rectangle*/ f pct_start>0 then do =_cum*2 to (_cum+pct_start)*2 by pct_start/&ponts; x=(1-&barwdth-&nnergap/2)*cos(constant("p")*); y=(1-&barwdth-&nnergap/2)*sn(constant("p")*); 8

/*Draws the nner part of the rectangle. Drawn at (1-&barwdth) of the dstance from the center*/ f pct_start>0 then do =(_cum+pct_start)*2 to _cum*2 by -pct_start/&ponts; x=(1-&barwdth-&nnergap/2-&barwdth/2)*cos(constant("p")*); y=(1-&barwdth-&nnergap/2-&barwdth/2)*sn(constant("p")*); BÉZIER CURVES The curves that connect one group to another wthn the crcle are known as quadratc Bézer curves whch connect three ponts and are created wth the followng equaton: 2 2 B ( t) (1 t) P0 2(1 t) tp1 t P2,0 t The defntons of the components are as follows: P 0 : startng pont P 1 : md-pont P 2 : end-pont t: represents the pont between the start and end of the curve as a proporton 1 A beneft of usng the unt crcle to make ths macro s that the md-pont s always the center of the crcle whch has coordnates of (0, 0). The result of ths smplfes the equaton to the followng: 2 2 B ( t) (1 t) P0 t P2,0 t 1 One Bézer curve s calculated for each sde of the shape, and these curves are then connected wth arcs usng the same prevous methods. Ths method gves the connectng curves the look of beng wder at the start and endng ponts than t s n the mddle and wll pull the curves more towards the center of the crcle the further away the startng pont s from the endng pont. The DATA step code that calculates the coordnates for the Bézer curves s as follows: /**Draw one sde of connectng Bézer curve**/ do = 0 to 1 by 1/&ponts; x=(1-)**2*bx1b + 2*(1-)**0 + **2*bx2a; y=(1-)**2*by1b + 2*(1-)**0 + **2*by2a; The varables bx1b and by1b are the x and y coordnates for the start of the curve (P 0 ), and the varables bx2a and by2a are the x and y coordnates for the end of the curve (P 2 ). The md-pont (P1) n ths case s 0 whch s why the second sum s multpled by 0. Calculatng the coordnates for all of the Bézer curves requres a number of pre-calculatons and organzaton. Each curve has the followng components: 9

1. Two ponts at the start of the curve to form the arc around the crcle wthn the begnnng group 2. Two ponts at the end of the curve to form the arc around the crcle wthn the endng group 3. The proporton of paths leavng the begnnng group each curve contans 4. The proporton of paths enterng the endng group each curve contans 5. The order n whch the curves are plotted to avod overlappng curves from the same group The CIRCOS macro computes the proporton each path takes up from the total crcle, from the startng group, and from the endng group. These values are combned n a dataset that contans the startng ponts and total proportons for each group around the outer crcle. The paths are ordered by how close each startng and endng group are to each other wth condtonal logc to wegh the drecton curves wll be gong. Groups that are closer together clockwse wll favor havng a curve begnnng to the left sde of the startng group, and the reverse for groups that are closer together counter-clockwse. CIRCULAR AXES The crcular axes are drawn n two peces: the lnes and the tck-marks. The lnes are drawn wth the same methods as the outsde of the OUTER CIRCLE rectangles. The tck-marks are created by plottng one pont at the outer edge of the OUTER CIRCLE and another further out on a lne perpendcular to the crcle. Every ffth tck-mark s twce the sze of the others. The DATA step code to create the coordnates s the followng: /*Moves along OUTER CIRCLE border*/ do =(_cum*2+0.02) to (_cum+percent)*2 by 0.02; /*Each tck has ts own dentfer for plottng*/ tck+1; /*x,y coordnates for the base of the tck-mark*/ xtck=cos(constant("p")*); ytck=sn(constant("p")*); /*Every ffth tck-mark s longer*/ f mod(tck,5)=0 then do; xtck=(1.025)*cos(constant("p")*); ytck=(1.025)*sn(constant("p")*); /*Other tck-marks are shorter*/ else do; xtck=(1.0125)*cos(constant("p")*); ytck=(1.0125)*sn(constant("p")*); 10

LABELS Three varables are requred to be calculated n order to plot the labels: the x-coordnate, the y-coordnate and the rotaton requred to face the label towards the center of the crcle. The x and y coordnates are calculated at the center of each of the OUTER CIRCLE groups, and then the followng herarchcal equaton s used to calculate the rotaton (R): 270, x 1 90, x 1 0, y 1 R 180, y 1 360 arccos( y)*, x 0 2 360 90 arcsn( y)*, x 0 2 The value for rotaton s calculated from the formula usng the equaton that frst meets the coordnate s condtons workng from the top down. Ths s calculated wthn the macro usng the SQL procedure and the followng query: /*Creates the dataset used for the text plot. Plots the labels half a barwdth beyond crcle*/ create table _text (drop=x y) as select dstnct _levels_ as text,_cum,percent, cos(constant("p")*2*(_cum+percent/2)) as x, sn(constant("p")*2*(_cum+percent/2)) as y, (1+&barwdth/2)*calculated x as x_text, (1+&barwdth/2)*calculated y as y_text, case when calculated x=1 then 270 when calculated x=-1 then 90 when calculated y=1 then 0 when calculated y=-1 then 180 when calculated x >0 then 0-arcos(calculated y) *360/(2*constant("p")) when calculated x <0 then 90-arsn(calculated y) *360/(2*constant("p")) else. end as rotate from _crcle2; The CALCULATED opton n the SQL procedure allows a reference to a pre-calculated varable wthn the query. The X_TEXT and Y_TEXT coordnates add a buffer to push the label text outsde the crcle. The CASE statement acts as a seres of IF-ELSE logc takng the frst true condton. GENERATING THE PLOT Creatng the plot s straghtforward after all of the coordnates have been calculated. The macro uses the polygon plot along wth the graphcs SUBPIXEL opton to create all of the shapes, and then uses a seres plot to make the axes and tck-marks. The graph s desgned n the TEMPLATE procedure usng the Graph Template Language (GTL) and s rendered wth the SGRENDER procedure. 11

POLYGON PLOT The POLYGONPLOT statement n GTL was made avalable n SAS 9.4M1 and draws a polygon per nputted x and y coordnates. The polygon s drawn n the order of the x and y coordnates, and upon reachng the last set of coordnates wll connect the end and the start of the polygon together. A fully connected polygon has the opton to have a fll color wthn the fnal shape. Multple shapes can be drawn from the same x and y varables due to a thrd requred varable: ID. The ID varable determnes dfferent shapes. An example data set for a POLYGONPLOT would look lke the followng table: Table 1 s a sample data set to nput nto a POLYGONPLOT statement. X Y ID 0 0 1 1 0 1 0 1 1 0 0 2-1 0 2 0 1 2 Table 1. The X and Y varables contan the x and y coordnates, respectvely. The ID varable separates the coordnates nto two dfferent shapes. The above set of coordnates and ID varables would create two trangles back to back on the y-axs. Fgure 10 s the graph created by table 1. 1 0-1 0 1 d 1 2 Fgure 10. The two separate trangles are drawn usng the coordnates n the data set descrbed by table 1. The ID varable dstngushes where one shape ends and another begns. 12

Fgure 11 dsplays the OUTER CIRCLE wth and wthout the plotted ponts used n the POLYGONPLOT statement (0,1) (0,1) (-1,0) (0,0) (1,0) (-1,0) (0,0) (1,0) (0,-1) (0,-1) Fgure 11. Each of the nner and outer arcs of the rectangles contans the same number of ponts (determned by the macro call). The other two sdes of the rectangles that connect these arcs do not requre any ponts as the polygon plot wll connect them automatcally. Another ID can be used to color the rectangles and Bézer curves ndvdually usng the GROUP opton. SUBPIXEL OPTION The SUBPIXEL opton s new wth SAS 9.4M3 and allows for the creaton of smoother curves. Ths opton makes the CIRCOS plot shapes take less ponts to create smooth curves and thus less processng tme. Fgure 12 s fgure 1 wthout the SUBPIXEL opton Fgure 12. Wthout the subpxel opton enabled the edges are much waver and jagged. 13

PLOTTING THE AXES The axes are created usng two SERIESPLOT statements. The frst seres plot draws the axs lne around the OUTER CIRCLE and the second draws the tck-marks: /**Uses the same coordnates that draw the outer border of the OUTER CIRCLE rectangles to plot the axs lne**/ /*The EVAL functon subsets the coordnates usng a varable prevously calculated n the data*/ seresplot x=eval(fn(outlne=1,x,.)) y=y / lneattrs=(color=black pattern=1 thckness=2) group=bfr_d; /**Uses the coordnates for the tck-marks calculated earler. Each tckmark s gven a unque dentfer to separate them usng the GROUP opton**/ seresplot x=xtck y=ytck / lneattrs=(color=black pattern=1 thckness=2) group=tckmark; PLOTTING THE LABELS The labels are created usng the TEXTPLOT statement. Ths statement requres an x-coordnate, a y- coordnate, and a varable contanng the label. A prevously calculated rotate varable s used to rotate the text to face the center of the crcle. The text s centered and justfed on the bottom of the text box. The GTL code s shown below: /*Plots the labels around the crcle*/ textplot x=x_text y=y_text text=text / rotate=rotate textattrs=(color=black sze=12pt weght=bold) poston=top vcenter=bbox; CONCLUSION The need to meet new challenges wthn current lmtatons drves the nnovaton of creatve technques, and nspres SAS to keep addng addtonal graph features. The CIRCOS macro s such an example that wll hopefully add to the potental of a new axs type to be developed for the already mpressve Statstcal Graphcs (SG) engne. CONTACT INFORMATION Your comments and questons are valued and encouraged. Contact the author at: Jeffrey Meyers Mayo Clnc 507-266-2711 Meyers.jeffrey@mayo.edu / jpmeyers.spa@gmal.com 14