Skip to content
Pierre Lindenbaum edited this page Apr 15, 2015 · 2 revisions

#Plotting Tycho Data

"Project Tycho ( https://www.tycho.pitt.edu/ ) is a project at the University of Pittsburgh to advance the availability and use of public health data for science and policy making. Currently, the Project Tycho database includes data from all weekly notifiable disease reports for the United States dating back to 1888."

Download data

register Tycho , and download the data level 2. It's a CSV file looking like this

"Weekly Measles Cases, 1909-2001"
"Data provided by Project Tycho, Data Version 1.0.0, released 28 November 2013."
"YEAR","WEEK","ALABAMA","ALASKA","AMERICAN SAMOA","ARIZONA","ARKANSAS","CALIFORNIA","COLORADO","CONNECTICUT","DELAWARE","DISTRICT OF COLUMBIA","FLORIDA","GEORGIA","GUAM","HAWAII","IDAHO","ILLINOIS","INDIANA","IOWA","KANSAS","KENTUCKY","LOUISIANA","MAINE","MARYLAND","MASSACHUSETTS","MICHIGAN","MINNESOTA","MISSISSIPPI","MISSOURI","MONTANA","NEBRASKA","NEVADA","NEW HAMPSHIRE","NEW JERSEY","NEW MEXICO","NEW YORK","NEW YORK CITY","NORTH CAROLINA","NORTH DAKOTA","NORTHERN MARIANA ISLANDS","OHIO","OKLAHOMA","OREGON","PAC TRUST TERR","PENNSYLVANIA","PUERTO RICO","RHODE ISLAND","SOUTH CAROLINA","SOUTH DAKOTA","TENNESSEE","TEXAS","UPSTATE NEW YORK","UTAH","VERMONT","VIRGIN ISLANDS","VIRGINIA","WASHINGTON","WEST VIRGINIA","WISCONSIN","WYOMING",""
1954,1,87,14,-,50,52,621,20,21,1,7,139,115,-,2,156,413,410,80,9,334,26,130,174,27,523,15,39,2,224,7,2,3,55,37,692,-,120,41,-,204,5,44,-,534,46,1,94,34,208,579,-,251,2,-,108,266,167,55,80
1954,2,94,30,-,93,13,685,37,17,1,12,119,79,-,2,142,315,425,201,18,188,42,78,124,31,815,3,30,20,104,1,2,4,39,56,819,-,32,71,-,444,10,67,-,438,12,2,84,15,43,606,-,199,10,-,90,351,169,101,32
1954,3,188,40,-,88,37,715,17,11,7,33,186,93,-,1,125,417,471,162,37,381,95,119,185,16,648,12,55,23,97,6,1,7,61,33,997,-,144,54,-,449,13,42,-,554,29,-,176,11,247,677,-,241,4,-,325,301,123,99,58
1954,4,152,16,-,69,91,841,29,35,15,22,164,210,-,5,217,377,685,432,21,556,88,139,208,23,728,19,78,35,56,37,1,4,52,24,1105,-,425,66,-,168,14,66,-,590,54,11,164,3,121,872,-,250,10,-,404,297,121,155,24
1954,6,166,25,-,131,132,888,55,12,2,29,149,212,-,4,129,457,417,152,21,589,49,207,322,28,719,10,193,56,99,80,2,4,79,49,1560,-,356,85,-,281,12,96,-,659,66,2,290,21,206,1412,-,251,19,-,368,757,109,194,49
1954,8,510,19,-,109,124,1569,96,21,13,75,309,220,-,10,184,750,959,118,101,10402,272,230,485,83,995,17,81,87,129,187,4,1,72,115,2242,-,395,38,-,1120,116,79,-,877,131,-,595,11,814,2084,-,264,36,-,592,675,129,292,37
1954,9,351,7,-,127,90,1593,44,20,30,135,450,164,-,10,362,936,1099,114,31,1226,145,206,631,95,1097,70,146,40,84,166,-,10,183,82,2727,-,730,102,-,1066,32,109,-,892,133,2,483,7,754,2886,-,388,41,-,725,713,114,208,36

Convert the data to RDF and then to SVG

<?xml version="1.0"?>
<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:t="https://www.tycho.pitt.edu/">
  <rdf:Description rdf:about="">
    <dc:title>"Weekly Measles Cases, 1909-2001"</dc:title>
    <dc:description>"Data provided by Project Tycho, Data Version 1.0.0, released 28 November 2013."</dc:description>
  </rdf:Description>
  <t:State rdf:about="https://www.tycho.pitt.edu/state/ALABAMA">
    <dc:title>ALABAMA</dc:title>
  </t:State>
  <t:State rdf:about="https://www.tycho.pitt.edu/state/ALASKA">
    <dc:title>ALASKA</dc:title>
  </t:State>
  (...)
  <t:Data>
    <t:state rdf:resource="https://www.tycho.pitt.edu/state/DISTRICT_OF_COLUMBIA"/>
    <t:year rdf:resource="https://www.tycho.pitt.edu/year/1909"/>
    <t:week>13</t:week>
    <t:count>12</t:count>
  </t:Data>
  <t:Data>
    <t:state rdf:resource="https://www.tycho.pitt.edu/state/VIRGINIA"/>
    <t:year rdf:resource="https://www.tycho.pitt.edu/year/1921"/>
    <t:week>20</t:week>
    <t:count>1</t:count>
  </t:Data>
  <t:Data>
    <t:state rdf:resource="https://www.tycho.pitt.edu/state/VIRGINIA"/>
    <t:year rdf:resource="https://www.tycho.pitt.edu/year/1922"/>
    <t:week>42</t:week>
    <t:count>2</t:count>
  </t:Data>
  (...)
(...)
      <g title="1923" transform="translate(60,0)">
        <text y="0" x="0" transform="translate(15,-2) rotate(-90) ">1923</text>
        <rect x="0" title="VIRGINIA (1923) N=2" y="1080" width="20" height="20" style="fill:rgb(15,0,240);stroke:gray;"/>
      </g>
      <g title="1927" transform="translate(80,0)">
        <text y="0" x="0" transform="translate(15,-2) rotate(-90) ">1927</text>
        <rect x="0" title="ALABAMA (1927) N=323" y="0" width="20" height="20" style="fill:rgb(128,0,127);stroke:gray;"/>
        <rect x="0" title="ARIZONA (1927) N=32" y="60" width="20" height="20" style="fill:rgb(77,0,178);stroke:gray;"/>
        <rect x="0" title="ARKANSAS (1927) N=134" y="80" width="20" height="20" style="fill:rgb(108,0,147);stroke:gray;"/>
        <rect x="0" title="CALIFORNIA (1927) N=174" y="100" width="20" height="20" style="fill:rgb(114,0,141);stroke:gray;"/>
        <rect x="0" title="COLORADO (1927) N=50" y="120" width="20" height="20" style="fill:rgb(87,0,168);stroke:gray;"/>
(...)

the command line:

awk -f tycho-csv2rdf.awk MEASLES_Cases_1909-2001.csv  |\
   xsltproc tycho-rdf2svg.xsl - > output.svg

tycho

See also

Clone this wiki locally