{"id":16879,"date":"2020-06-30T05:19:03","date_gmt":"2020-06-30T05:19:03","guid":{"rendered":"http:\/\/www.wjst.de\/blog\/?p=16879"},"modified":"2020-07-03T19:58:23","modified_gmt":"2020-07-03T19:58:23","slug":"graphical-display-of-outbreaks-transmission-trees","status":"publish","type":"post","link":"https:\/\/www.wjst.de\/blog\/sciencesurf\/2020\/06\/graphical-display-of-outbreaks-transmission-trees\/","title":{"rendered":"Graphical display of outbreaks: Transmission trees"},"content":{"rendered":"<p>Let&#8217;s start with some examples from the literature, find out necessary elements, compare different versions and develop a R template for general use.<\/p>\n<p>&#8220;Exploding Stars&#8221;<\/p>\n<figure id=\"attachment_16880\" aria-describedby=\"caption-attachment-16880\" style=\"width: 370px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16880 \" src=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/Bildschirmfoto-2020-06-30-um-06.37.55.jpg\" alt=\"\" width=\"370\" height=\"150\" srcset=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/Bildschirmfoto-2020-06-30-um-06.37.55.jpg 773w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/Bildschirmfoto-2020-06-30-um-06.37.55-620x251.jpg 620w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/Bildschirmfoto-2020-06-30-um-06.37.55-768x311.jpg 768w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><figcaption id=\"caption-attachment-16880\" class=\"wp-caption-text\">CDC Field Epidemiology Handbook, 2019, ISBN 9780190933692 p115<\/figcaption><\/figure>\n<p>&#8220;Tetris&#8221;<\/p>\n<figure id=\"attachment_16903\" aria-describedby=\"caption-attachment-16903\" style=\"width: 339px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16903 \" src=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/Bildschirmfoto-2020-07-01-um-17.03.41-628x500.jpg\" alt=\"\" width=\"339\" height=\"270\" srcset=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/Bildschirmfoto-2020-07-01-um-17.03.41-628x500.jpg 628w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/Bildschirmfoto-2020-07-01-um-17.03.41-620x494.jpg 620w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/Bildschirmfoto-2020-07-01-um-17.03.41.jpg 727w\" sizes=\"auto, (max-width: 339px) 100vw, 339px\" \/><figcaption id=\"caption-attachment-16903\" class=\"wp-caption-text\">https:\/\/doi.org\/10.1016\/S0140-6736(20)30154-9 (2020)<\/figcaption><\/figure>\n<p>&#8220;Clean Undeterministic&#8221;<br \/>\n&#8220;Clean Tree&#8221;<\/p>\n<figure id=\"attachment_16881\" aria-describedby=\"caption-attachment-16881\" style=\"width: 332px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16881 size-large\" src=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/Bildschirmfoto-2020-06-30-um-06.42.14-332x500.jpg\" alt=\"\" width=\"332\" height=\"500\" srcset=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/Bildschirmfoto-2020-06-30-um-06.42.14-332x500.jpg 332w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/Bildschirmfoto-2020-06-30-um-06.42.14-620x933.jpg 620w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/Bildschirmfoto-2020-06-30-um-06.42.14.jpg 629w\" sizes=\"auto, (max-width: 332px) 100vw, 332px\" \/><figcaption id=\"caption-attachment-16881\" class=\"wp-caption-text\">https:\/\/academic.oup.com\/mbe\/article\/34\/4\/997\/2919386<\/figcaption><\/figure>\n<p>&#8220;Tree Addons&#8221;<\/p>\n<figure id=\"attachment_16883\" aria-describedby=\"caption-attachment-16883\" style=\"width: 344px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16883 \" src=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/Bildschirmfoto-2020-06-30-um-06.51.38-472x500.jpg\" alt=\"\" width=\"344\" height=\"364\" srcset=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/Bildschirmfoto-2020-06-30-um-06.51.38-472x500.jpg 472w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/Bildschirmfoto-2020-06-30-um-06.51.38.jpg 591w\" sizes=\"auto, (max-width: 344px) 100vw, 344px\" \/><figcaption id=\"caption-attachment-16883\" class=\"wp-caption-text\">https:\/\/openres.ersjournals.com\/content\/4\/2\/00162-2017<\/figcaption><\/figure>\n<p>&#8220;Railways&#8221;<\/p>\n<figure id=\"attachment_16885\" aria-describedby=\"caption-attachment-16885\" style=\"width: 379px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16885 \" src=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/csm_cluster_A_2020-04-16_b1f70401c1-706x500.png\" alt=\"\" width=\"379\" height=\"269\" srcset=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/csm_cluster_A_2020-04-16_b1f70401c1-706x500.png 706w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/csm_cluster_A_2020-04-16_b1f70401c1-620x439.png 620w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/csm_cluster_A_2020-04-16_b1f70401c1.png 726w\" sizes=\"auto, (max-width: 379px) 100vw, 379px\" \/><figcaption id=\"caption-attachment-16885\" class=\"wp-caption-text\">https:\/\/www.ages.at\/service\/service-presse\/pressemeldungen\/epidemiologische-abklaerung-am-beispiel-covid-19\/<\/figcaption><\/figure>\n<p>&#8220;Simple &#8221;<\/p>\n<figure id=\"attachment_16886\" aria-describedby=\"caption-attachment-16886\" style=\"width: 370px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16886 \" src=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/1-1-768x500.jpg\" alt=\"\" width=\"370\" height=\"241\" srcset=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/1-1-768x500.jpg 768w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/1-1-620x404.jpg 620w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/1-1.jpg 857w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><figcaption id=\"caption-attachment-16886\" class=\"wp-caption-text\">https:\/\/www.ncbi.nlm.nih.gov\/pubmed\/32003551<\/figcaption><\/figure>\n<p>&#8220;Vertical&#8221;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-16887 alignnone\" src=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/2-1-495x500.jpg\" alt=\"\" width=\"386\" height=\"390\" srcset=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/2-1-495x500.jpg 495w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/2-1-620x626.jpg 620w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/2-1-768x775.jpg 768w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/2-1.jpg 1057w\" sizes=\"auto, (max-width: 386px) 100vw, 386px\" \/><\/p>\n<p>&#8220;star bus&#8221;<\/p>\n<figure id=\"attachment_16889\" aria-describedby=\"caption-attachment-16889\" style=\"width: 361px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16889 \" src=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/AIDS_index_case_graph.svg_-731x500.png\" alt=\"\" width=\"361\" height=\"247\" srcset=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/AIDS_index_case_graph.svg_-731x500.png 731w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/AIDS_index_case_graph.svg_-620x424.png 620w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/AIDS_index_case_graph.svg_-768x525.png 768w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/AIDS_index_case_graph.svg_.png 800w\" sizes=\"auto, (max-width: 361px) 100vw, 361px\" \/><figcaption id=\"caption-attachment-16889\" class=\"wp-caption-text\">https:\/\/en.wikipedia.org\/wiki\/Index_case<\/figcaption><\/figure>\n<p>&#8220;Mathematical&#8221;<\/p>\n<figure id=\"attachment_16890\" aria-describedby=\"caption-attachment-16890\" style=\"width: 365px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16890 \" src=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/F1.large_-513x500.jpg\" alt=\"\" width=\"365\" height=\"356\" srcset=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/F1.large_-513x500.jpg 513w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/F1.large_-620x604.jpg 620w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/F1.large_-768x748.jpg 768w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/F1.large_.jpg 1280w\" sizes=\"auto, (max-width: 365px) 100vw, 365px\" \/><figcaption id=\"caption-attachment-16890\" class=\"wp-caption-text\">https:\/\/www.biorxiv.org\/content\/10.1101\/142570v3.full<\/figcaption><\/figure>\n<p>&#8220;Genetics&#8221;<\/p>\n<figure id=\"attachment_16930\" aria-describedby=\"caption-attachment-16930\" style=\"width: 347px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16930 \" src=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/EcAgoTBU4AYWN_B-400x500.jpeg\" alt=\"\" width=\"347\" height=\"434\" srcset=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/EcAgoTBU4AYWN_B-400x500.jpeg 400w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/EcAgoTBU4AYWN_B-620x774.jpeg 620w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/EcAgoTBU4AYWN_B-768x959.jpeg 768w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/06\/EcAgoTBU4AYWN_B.jpeg 820w\" sizes=\"auto, (max-width: 347px) 100vw, 347px\" \/><figcaption id=\"caption-attachment-16930\" class=\"wp-caption-text\">https:\/\/wwwnc.cdc.gov\/eid\/article\/26\/9\/20-1798_article<\/figcaption><\/figure>\n<p><!--nextpage-->Infectious trees have common elements with pedigree plots in genetics.<br \/>\nExcept of the &#8220;star bus&#8221; plot, all have a time frame. Maybe the main differences is the time frame, which was always horizontal except of the &#8220;vertical&#8221; Lancet plot (although ut wasted a lot of space by unused lines).<\/p>\n<p>&#8220;Railways&#8221; is more abstract art and too much condensed to be useful, &#8220;exploding stars&#8221; gets immediately busy making changes dfficult. &#8220;Tree Addons&#8221; is nice and should be possible when plotted in landscape format.<\/p>\n<p>We could juts use some <a href=\"https:\/\/4va.github.io\/biodatasci\/r-ggtree.html\">phylogenetic tree package<\/a> which may be hard to configure for this special purpose. So lets try some new version of the <a href=\"https:\/\/www.thelancet.com\/journals\/laninf\/article\/PIIS1473-3099(20)30314-5\/fulltext\">recent Lancet figure<\/a>.<\/p>\n<ol>\n<li>each individual gets an increasing id which is a unique x-axis value<\/li>\n<li>time points are on a revere y-axis<\/li>\n<li>crossing lines indicate interaction<\/li>\n<li>different symbols indicate actions<\/li>\n<\/ol>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nevents &lt;- read.xlsx(&quot;test.xls&quot;, startRow = 1, colNames = TRUE, rowNames = FALSE, detectDates = TRUE, skipEmptyRows = TRUE, skipEmptyCols = TRUE, rows = NULL, cols = NULL, check.names = FALSE) %&gt;%\r\n  mutate( dt = yday(dt) ) %&gt;%\r\n  arrange( dt,id,id2 ) %&gt;%\r\n  group_by( dt ) %&gt;%\r\n  mutate( nr = (row_number()) \/6 )\r\nids &lt;- events&#x5B;,c(&quot;id&quot;,&quot;dt&quot;,&quot;nr&quot;,&quot;event&quot;)]\r\ncnd &lt;- !is.na(events$id2)\r\nids&#x5B;dim(ids)&#x5B;1]+1:sum(cnd),] &lt;- events&#x5B;cnd, c(&quot;id2&quot;,&quot;dt&quot;,&quot;nr&quot;,&quot;event&quot;)] \r\nids &lt;- ids %&gt;%\r\n  group_by( id ) %&gt;%\r\n  mutate( mindt=min(dt), maxdt=max(dt) )\r\nevents %&gt;% \r\n  ggplot() + \r\n  geom_segment( data=ids %&gt;% filter(row_number()==1), aes(x = id, y = mindt, xend = id, yend = maxdt), size=3, colour=&quot;grey&quot;) +\r\n  geom_segment( aes(y = dt+nr, x = id, yend = dt+nr, xend = id2), colour=&quot;black&quot; ) +\r\n  geom_point( data=ids %&gt;% filter(event!=&quot;S&quot;), aes(y=dt+nr, x=id), size=2, colour=&quot;black&quot;) +\r\n  geom_point( data=. %&gt;% filter(event==&quot;S&quot;), aes(y=dt, x=id, group=id ), shape=21, fill=&quot;red&quot;, size=3, colour=&quot;red&quot;) +\r\n  geom_label_repel( data=ids %&gt;% filter(row_number()==1 &amp; !id %in% c(5,6,9,11)), aes(y=maxdt, x=id, group=id, label=paste0(&quot;Pat&quot;,id) ), nudge_y=-.8, nudge_x =.001, segment.color = NA, force=10) +\r\n  geom_label_repel( data=ids %&gt;% filter(row_number()==1 &amp; id %in% c(5,6,9,11)), aes(y=maxdt, x=id, group=id, label=paste0(&quot;Pat&quot;,id) ), fill=&quot;cyan&quot;, nudge_y=-.8, nudge_x =.001, segment.color = NA) +\r\n  scale_y_reverse ( limits=c(35, 19), breaks=seq(35,19,-1), labels=format( as.Date( c(34:18), format = &quot;%j&quot;, origin=&quot;1.1.20&quot;), &quot;%a %e.%m.&quot; ), name=&quot;&quot;) +\r\n  scale_x_continuous( position = &quot;top&quot;, name=&quot;&quot; )\r\n<\/pre>\n<p>All <a href=\"https:\/\/github.com\/under-score\/Covid-19-in-Munich\">Code is at Github<\/a>.<\/p>\n<p>And here is my plot, trying to increase &#8220;data ink&#8221;. I think it is most suitable for up to 20 individuals and detailed contact history.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-16934\" src=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/07\/Rplot-655x500.png\" alt=\"\" width=\"655\" height=\"500\" srcset=\"https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/07\/Rplot-655x500.png 655w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/07\/Rplot-620x473.png 620w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/07\/Rplot-768x586.png 768w, https:\/\/www.wjst.de\/blog\/wp-content\/uploads\/2020\/07\/Rplot.png 1031w\" sizes=\"auto, (max-width: 655px) 100vw, 655px\" \/><\/p>\n\n<p>&nbsp;<\/p>\n<div class=\"bottom-note\">\n  <span class=\"mod1\">CC-BY-NC Science Surf , accessed 20.04.2026<\/span>\n <\/div>","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s start with some examples from the literature, find out necessary elements, compare different versions and develop a R template for general use. &#8220;Exploding Stars&#8221; &#8220;Tetris&#8221; &#8220;Clean Undeterministic&#8221; &#8220;Clean Tree&#8221; &#8220;Tree Addons&#8221; &#8220;Railways&#8221; &#8220;Simple &#8221; &#8220;Vertical&#8221; &#8220;star bus&#8221; &#8220;Mathematical&#8221; &#8220;Genetics&#8221; &nbsp; CC-BY-NC Science Surf , accessed 20.04.2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[2893,3462,1778,276,3460,3459,2776,3461],"class_list":["post-16879","post","type-post","status-publish","format-standard","hentry","category-computer-software","tag-r","tag-tufte","tag-disease","tag-epidemiology","tag-infectious","tag-plot","tag-template","tag-tree"],"_links":{"self":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/16879","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/comments?post=16879"}],"version-history":[{"count":23,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/16879\/revisions"}],"predecessor-version":[{"id":16938,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/16879\/revisions\/16938"}],"wp:attachment":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/media?parent=16879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/categories?post=16879"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/tags?post=16879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}