<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Wonderful Wednesdays on R Views</title>
    <link>https://rviews.rstudio.com/tags/wonderful-wednesdays/</link>
    <description>Recent content in Wonderful Wednesdays on R Views</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Fri, 15 Jan 2021 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://rviews.rstudio.com/tags/wonderful-wednesdays/" rel="self" type="application/rss+xml" />
    
    
    
    
    <item>
      <title>A Custom Forest Plot from Wonderful Wednesdays</title>
      <link>https://rviews.rstudio.com/2021/01/15/wonderful-wednesdays-forest-plot/</link>
      <pubDate>Fri, 15 Jan 2021 00:00:00 +0000</pubDate>
      
      <guid>https://rviews.rstudio.com/2021/01/15/wonderful-wednesdays-forest-plot/</guid>
      <description>
        

&lt;p&gt;&lt;em&gt;Waseem Medhat is a Statistical Programmer and Computational Experimentalist who resides in Alexandria, Egypt&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This post takes a closer look at the forest plot that was mentioned in a &lt;a href=&#34;https://rviews.rstudio.com/2021/01/11/wonderful-wednesdays/&#34;&gt;previous post&lt;/a&gt; introducing PSI&amp;rsquo;s Wonderful Wednesdays events. It describes a custom version of a forest plot with additional bands to visualize heterogeneity between studies in a meta-analysis that was part of a project submitted to the Wonderful Wednesdays challenge hosted by PSI and reviewed by statisticians in the organization. Find more information
&lt;a href=&#34;https://vis-sig.github.io/blog/posts/2020-12-03-wonderful-wednesdays-december-2020/&#34;&gt;here&lt;/a&gt;. The plot is built with JavaScript using the
&lt;a href=&#34;https://d3js.org/&#34;&gt;D3.js&lt;/a&gt; library and wrapped in a
&lt;a href=&#34;https://shiny.rstudio.com/&#34;&gt;Shiny&lt;/a&gt; app with the help of the
&lt;a href=&#34;https://rstudio.github.io/r2d3/&#34;&gt;R2D3&lt;/a&gt; package.&lt;/p&gt;

&lt;h2 id=&#34;background-problem&#34;&gt;Background problem&lt;/h2&gt;

&lt;p&gt;The problem around this visualization is specific to meta-analysis, which is the statistical pooling of the results of multiple studies (e.g. a multi-center clinical trial) to obtain a single, more powerful estimate. The choice of pooling model (fixed effect vs. random effects) depends on the heterogeneity of effect size between studies. So, the main question that I wanted to answer with this visualization is:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&amp;ldquo;What graphical tools can be used to assess heterogeneity?&amp;rdquo;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Like any statistical graphic, the purpose of the visualization is to complement the statistical measures of heterogeneity, like I^2^, to give a more complete picture.&lt;/p&gt;

&lt;h2 id=&#34;plot-description&#34;&gt;Plot description&lt;/h2&gt;

&lt;p&gt;&lt;img src=&#34;https://waseem-medhat.netlify.app/post/forest-plot-with-heterogeneity-bands_files/forest_plot_with_bands.png&#34; alt=&#34;&#34; /&gt;&lt;/p&gt;

&lt;p&gt;A lot of the plot components are directly comparable to the typical &lt;a href=&#34;https://en.wikipedia.org/wiki/Forest_plot&#34;&gt;forest
plot&lt;/a&gt;, which is very popular in the medical field as visualization tool in meta-analyses. Its main features are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A square for each point estimate for a study. The square size is proportional
to the sample size (i.e. weight) of that study.&lt;/li&gt;
&lt;li&gt;A line for each confidence interval of the effect size in a study.&lt;/li&gt;
&lt;li&gt;Diamonds that represent the pooled estimate using either fixed-effect or random-effects model. The diamond width represents the confidence interval around the pooled estimate.&lt;/li&gt;
&lt;li&gt;The plot is usually combined with a tabular display of the numbers represented by the plot.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My own additions are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Colored bands to give a better visualization of the heterogeneity between studies. There is a band for each study, with a width equal to its confidence interval. All the bands are semi-transparent and overlayed over each other so that more overlapping produces darker areas.&lt;/li&gt;
&lt;li&gt;More attention to annotations than the typical plots, providing a title and a subtitle with the interventions and the outcome, respectively. Another label is also added to show which direction represents the &amp;ldquo;positive&amp;rdquo; effect.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&#34;shiny-app-description&#34;&gt;Shiny app description&lt;/h2&gt;

&lt;p&gt;&lt;img src=&#34;https://waseem-medhat.netlify.app/post/forest-plot-with-heterogeneity-bands_files/forest_plot_with_bands_shiny.png&#34; alt=&#34;&#34; /&gt;&lt;/p&gt;

&lt;p&gt;As a proof of concept for a viable product, I wrapped the plot in a Shiny app which provides additional interactive features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Selection of summary measure, which can be expanded to include more than the
odds ratio and risk ratio.&lt;/li&gt;
&lt;li&gt;Control over the plot dimensions. Giving this control to the user allows the  plot to be conveniently visible in different screen sizes and deliverable forms (e.g.  a report or a dashboard).&lt;/li&gt;
&lt;li&gt;Help button that shows a guide for interpretation. This makes the information available on-demand instead having it a separate tab.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&#34;technologies-and-packages&#34;&gt;Technologies and packages&lt;/h2&gt;

&lt;h3 id=&#34;d3-js-javascript&#34;&gt;D3.js (JavaScript)&lt;/h3&gt;

&lt;p&gt;The plot itself (and associated tabular display) was built using D3.  Being a JavaScript library, D3 works with web technologies: HTML, CSS, and especially SVG. It has a lot of low-level tools that bind data to SVG shapes and change the shape properties accordingly. One particular advantage of using web technologies in this visualization is that CSS allows semi-transparent elements to &amp;ldquo;blend&amp;rdquo; colors in multiple ways, which allowed me to choose a blend mode that emphasizes the overlap.&lt;/p&gt;

&lt;h3 id=&#34;r2d3&#34;&gt;R2D3&lt;/h3&gt;

&lt;p&gt;R2D3 was the main wrapper around the D3 visualization. Beside the obvious
advantage of introducing an interface between R and D3 and allowing its
rendering in Shiny, it makes some steps easier like giving the data to the plot and making the plot take as much space as possible inside its container. Because of this, initial variables like &lt;code&gt;data&lt;/code&gt;, &lt;code&gt;width&lt;/code&gt;, &lt;code&gt;height&lt;/code&gt;, and (the container) &lt;code&gt;svg&lt;/code&gt; are provided by R2D3 and are not declared in the JavaScript code.&lt;/p&gt;

&lt;h3 id=&#34;shiny&#34;&gt;Shiny&lt;/h3&gt;

&lt;p&gt;It does not need an introduction at this point: Shiny is the de facto standard for R-based web applications. With the R2D3 package, I have available &lt;code&gt;d3Output()&lt;/code&gt; and &lt;code&gt;renderD3()&lt;/code&gt; to render the D3 plot just like any typical output in Shiny. Other Shiny packages I used are
&lt;a href=&#34;https://github.com/cwthom/shinyhelper&#34;&gt;shinyhelper&lt;/a&gt;, which provides a help button and rich modal dialogs for help content, and &lt;a href=&#34;http://rstudio.github.io/shinythemes/&#34;&gt;shinythemes&lt;/a&gt; to change the appearance of the app.&lt;/p&gt;

&lt;p&gt;By wrapping the visualization in a Shiny app, this project became a prototype that can be taken in a lot of different directions to include more effect sizes and other meta-analysis techniques, or maybe even add another module that imports the data, performs the meta-analysis, and send the results to this module to be visualized.&lt;/p&gt;

&lt;h2 id=&#34;links&#34;&gt;Links&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Live version of the Shiny app: &lt;a href=&#34;https://waseem-medhat.shinyapps.io/forest_plot_with_bands/&#34;&gt;https://waseem-medhat.shinyapps.io/forest_plot_with_bands/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;GitHub: &lt;a href=&#34;https://github.com/waseem-medhat/forest_plot_with_bands&#34;&gt;https://github.com/waseem-medhat/forest_plot_with_bands&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Wonderful Wednesdays December submissions: &lt;a href=&#34;https://vis-sig.github.io/blog/posts/2020-12-03-wonderful-wednesdays-december-2020/&#34;&gt;https://vis-sig.github.io/blog/posts/2020-12-03-wonderful-wednesdays-december-2020/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

        &lt;script&gt;window.location.href=&#39;https://rviews.rstudio.com/2021/01/15/wonderful-wednesdays-forest-plot/&#39;;&lt;/script&gt;
      </description>
    </item>
    
    <item>
      <title>Wonderful Wednesdays</title>
      <link>https://rviews.rstudio.com/2021/01/11/wonderful-wednesdays/</link>
      <pubDate>Mon, 11 Jan 2021 00:00:00 +0000</pubDate>
      
      <guid>https://rviews.rstudio.com/2021/01/11/wonderful-wednesdays/</guid>
      <description>
        &lt;p&gt;For almost a year now, the PSI Visualization Special Interest Group &lt;a href=&#34;https://www.psiweb.org/sigs-special-interest-groups/visualisation&#34;&gt;(VIS SIG)&lt;/a&gt; has been conducting a monthly graduate-level seminar on creating effective statistical visualizations that is open to everyone. &lt;a href=&#34;https://www.psiweb.org/sigs-special-interest-groups/visualisation/welcome-to-wonderful-wednesdays&#34;&gt;Wonderful Wednesdays&lt;/a&gt; is a unique collegial event. Every month the SIG publishes a link to a new data set and issues a challenge to produce visualizations that effectively illustrate some specific aspects of the data. Anyone can submit an entry coded in the language of their choice. Submissions that are received by the deadline are then critiqued in free webinar that takes place roughly thirty days later. You don&amp;rsquo;t have to make a submission to attend the webinar.&lt;/p&gt;

&lt;p&gt;The process is well organized and straightforward. The figure below illustrates the process and time liness for the for the webinar that will happen this week on Wednesday, January 13th.&lt;/p&gt;

&lt;p&gt;&lt;img src=&#34;ww1.png&#34; height = &#34;300&#34; width=&#34;500&#34;&gt;&lt;/p&gt;

&lt;p&gt;Click &lt;a href=&#34;https://attendee.gotowebinar.com/register/3242063276946783247&#34;&gt;here&lt;/a&gt; to register for the webinar.&lt;/p&gt;

&lt;p&gt;Here is the &lt;a href=&#34;https://www.psiweb.org/vod/item/psi-vissig-wonderful-wednesday-10-meta-analysis#video_490750250&#34;&gt;link&lt;/a&gt; to the December webinar where the challenge was to visualize the heterogeneity among the data used for a meta-analysis of seven studies undertaken to show a reduction in hypertension.&lt;/p&gt;

&lt;p&gt;The following image is a traditional forest plot showing a comparison of the odds ratios for the seven studies. (If you are not familiar with this plot type look &lt;a href=&#34;https://s4be.cochrane.org/blog/2016/07/11/tutorial-read-forest-plot/&#34;&gt;here&lt;/a&gt; for some tips on how to interpret it.)&lt;/p&gt;

&lt;p&gt;&lt;img src=&#34;forest.png&#34; height = &#34;300&#34; width=&#34;500&#34;&gt;&lt;/p&gt;

&lt;p&gt;This image comes from a shiny app that is critiqued at the by the VIS-SIG statisticians towards the beginning of the webinar. The experts liked the clean look and labeling on the plot, but had mixed feelings about the colored bands which are meant to show regions where the studies overlap. (Darker color indicates more overlap.) Here are the links to the &lt;a href=&#34;https://waseem-medhat.shinyapps.io/forest_plot_with_bands/&#34;&gt;Shiny App&lt;/a&gt; and the &lt;a href=&#34;https://vis-sig.github.io/blog/posts/2020-12-03-wonderful-wednesdays-december-2020/#example1%20code&#34;&gt;code&lt;/a&gt; and also to the &lt;a href=&#34;https://vis-sig.github.io/blog/posts/2020-12-03-wonderful-wednesdays-december-2020/&#34;&gt;blog post&lt;/a&gt; that reviews all of the submissions for the December challenge.&lt;/p&gt;

&lt;p&gt;Visit the &lt;a href=&#34;https://vis-sig.github.io/blog/&#34;&gt;VIS-SIG Blog&lt;/a&gt; to finds posts and code for the submissions for all of Wonderful Wednesday events so far.&lt;/p&gt;

        &lt;script&gt;window.location.href=&#39;https://rviews.rstudio.com/2021/01/11/wonderful-wednesdays/&#39;;&lt;/script&gt;
      </description>
    </item>
    
  </channel>
</rss>
