helena * jambor

scientist interested in RNA, genomics and science visualizations

Category: Miscellaneous

Pick’n’mix plots

Follow-up to: Showing distributions

 

When writing about the half-and-half plot, many of you replied with further discussion points, tips, and tutorials. I tried collected them here to make them available to everyone.

More mixed boxplots

Aaron Ellison @AMaxEll17 brought to our attention that he published a plot in 1993, where he overlaid the box plot with the data points (see fig 1A). Along with it he published the code, pre github et al. Aaron was inspired by the just published “Grammar of Graphics” by Wilkinson. He seems to be the first person to have published it in a paper?

Today, boxplot/data plots are common and easy to plot in R with ggplot2. Declan O’Regan @DrDeclanORegan shows us one example in figure 1B. An “exploded” version, where the boxplot and its metrics are barely visible and the focus is on the data points, is shown in figure 1C (provided by the cystic fibrosis Gene therapy group @CFGT_Edinburgh).

3 variations of boxplot mixed with data plots.

Figure 1: Boxplot mixed with data plots.

Box’n’Bee

There is also the overlay of boxplot with the bee-swarm plot. Here, individual data points are ordered and arranged in a U-shape instead of randomly placed. An example is shown by Darren Wisniewski @Dmwizzle, who made this in ggplot2 (fig 2A).

But, beware of the bee-swarm: the ordered arrangement of the data (U-/ or A-shape most common) may introduces visual artifacts. And, personally, I draw a mental line through the U-shaped branches and straighten it to understand the data. This is error-prone and of course a waste of time when the line could equally be straight. In figure 2B I have plotted the same data as bee plot and dot plot for a direct comparison. I feel it is easier to see how the data is distributed in the data/dot plot. (Data: gene expression of RNAs that are localized at the poles in the fruit fly oocyte. RNAs that localize at the posterior for days have higher expression than RNAs at the anterior pole that are localized just for a few hours).

Pick_fig2-01.png

Figure 2: A. Boxplot and bee swarm plot. B. Comparison of bee versus data/dot plot.

Histogram & boxplot

Robert Grant @robertstats pointed us to an interesting histogram overlaid with statistical summaries that was originally designed by @f2harrell (here is a link to a tutorial with R), see figure 3. The horizontal histogram shown below has particularly small bins and the median and quartiles indicated below – for my taste a bit too small.

Picture5

Figure 3: histogram with boxplot overlay.

Violin and data

Of course, there are also mixed plots with violin plots. Violin plot themselves most often already are overlaid with a boxplot. Another possibility by Wouter de Coster @wouter_decoster is to mix the violin plot with a bee swarm plot, which he implemented with python seaborn (fig 4A). As you know, I personally would have preferred the actual data instead of the bee swarm, see above.

Joey Burant @jbburant put forward the idea of mixing data points as a histogram with half of a violin plot in , see figure 4B. pick_3-01

Joey also nicely documented how in github:

When the histo-violin is flipped horizontal this looks like a raining cloud, Roger Kievit @rogierK  therefore named it the raincloud plot and just deposited a preprint article about this plot type and its implementation. For matplotlib users posted a guide in github.

In excel…

Jorge Camoes @wisevis shows us that such plot types are also possible to make in excel – he shows us a horizontal boxplot with data points above from his book (fig 5). I generally like horizontal boxplots, especially when comparing lots of categories! re-created the half-and-half plot it in excel. Both are phenomenal, I had no idea excel could do this much! 

Picture8

Figure 5: Boxplot with data in excel

… and matlab

And finally, matlab user rejoice, it is also possible to make mixed plots in your favorite environment, Matt Cooper @mattguycooper suggests to use the ‘notboxplot’ function on the file exchange that creates ‘box plots’ with dot plots overlaid, this gives you plots as shown in figure 6:

Picture9

Figure 6: boxplots with data in matlab

More: Tutorials and interactive plots

Bogdan Micu‏ @trizniak points us to a nice interactive violin plot: https://plot.ly/r/violin/.

A couple of tutorials: Frank Soboczenski‏ @h21k shows us the code for making half-and-half boxplots in R: https://github.com/h21k/R/blob/master/snippets/half_box.R, James Rooney @jpkrooney pointed us to a great tutorial for making violin plots with ggplot2 by Katherine Wood @kathmwood https://inattentionalcoffee.wordpress.com/2017/02/14/data-in-the-raw-violin-plots/ and @lisadebruine compares different plots compare with the same data: https://debruine.github.io/plot_comparison.html.

 

 

 

Advertisements

Axis breaks

I challenge you: it is almost never necessary to break an axis! I found this one in a recent scientific article. The axis break here is 100% unnecessary. All that was needed was a little re-scaling of the dot size and the y-axis.

(or in fact: not reporting the one number with a graph in the first place. Or: showing an almost complete pie- or bar chart).

Imported File (2)-01When you cannot avoid an axis break, for example for showing highly diverged values, do it well:  the break point must be clear in the axis AND in the data! Another solution is show the values along a logarithmic scale. However this works only for some data types and is almost always harder to read (make sure to then include grid lines to focus your audience right away on the unusual axis layout!).

Also, never use a design that accidentally gives the impression of a broken axis. In this example instead of a boxplot with a black bar for median, a white one was chosen, giving the impression of some interruption in the data.

IMG_0273

 

Showing distributions

When reading about co-evolution of prey and predators, I stumbled across a cute new plot type: a half boxplot, half dot plot. Wilson et al. created this plot to simultaneously visualize both the summaries of their data (center, spread) and the actual data points. This allows us, the audience, to learn a lot about their results: that cheetahs are maybe binomially distributed and have outliers, or that zebras show a curious clustering.

Wilson_redraw

Half boxplot- half data plot, re-drawn from Wilson et al. 2018

Your quick guide to distribution plots

The half-and-half, aka dox-plot (a friend), led me to explore which visuals are commonly used for showing distributions.

Raw data

To show how the raw data is distributed, we simply use dots or bars (as in barcode plots). When there are overlapping data points, we can use transparent fill colors or “jittering”, which distributes the data points in a given area, for increased clarity.

Summarizing the data: center and spread

Often, we are interested in summarizing statistics to judge and compare data. By convention the center (median) is indicated with a horizontal bar and the spread (variance, standard deviation) with vertical whiskers. Common plot types for this are the “star-wars rebel fighter”, the dot plot and boxplot. Bar plot used to be widely used, but are now banned by most journals for concealing most relevant information, so they are here only for completeness (see previous post). Very often these days I see boxplots that are overlaid with the data points – this works really well for up to 100 data points and is easy to implement with most software.

Part_2_FocusCenter

Show shape and unusual features

For normally distributed data, the center and the spread are highly informative. However, in life science we often have bimodal distributions, clusters, or gaps. Then boxplots become very insufficient and might even conceal interesting aspects (if not outright be misleading).

For faithfully showing distributions, histograms have a long history. Here, one has to be very careful with choosing bin sizes: too large or too small bins can greatly distort the histogram shape and result in a misleading chart. Choosing bin sizes is a science in itself, for details see wikipedia – but basically, it again depends on the data shape and sampling depth.

An alternative to histograms are density plots. They show only how the data are distributed, but in life science are not frequently used yet. They become very useful for large data sets that can’t be visualized as raw data points anymore, or where the eye would not be able comprehend the spread intuitively anymore. A rather recent but so far “happy marriage” is the violin plot. Violin plots are a fusion of the boxplot and its summary statistics, with the density/shape of the data (Hintze and Nelson, 1998 doi: 10.1080/00031305.1998.10480559).

Part_3_FocusShape

 

Pro and cons of different plot types:

Table_procon.png

All figures as one:

geneology of distribution charts_5-01

 

It’s playtime: Bad Poster Bingo!

Your next conference is coming up and you need a distraction for the poster session? Then consider playing “Bad Poster Bingo” and win a prize*! Better even, use this guide to avoid common pitfalls we experience when presenting scientific data on a poster! Tips are also in my previous guide to good poster design & references therein.

How to play Bad Poster Bingo

Complete 5 in a row, horizontally/vertically/diagonally, send me an example & win!

> Download Bad_Poster_Bingo_bunt or Bad Poster Bingo (plain) <

Bad_Poster_Bingo_bunt-01.png
* your choice for a win: a Helena-drawn portrait, a Helena-made badge of honor, or an honorary mention on twitter 🙂

How big is an ribonucleic acid*?

I am often surprised about the real dimensions of biological entities versus how they are shown in textbooks and scientific illustrations and this is very striking for ribonucleic acid (RNA). Ribonucleic acids themselves are not photogenic as they move and wiggle, and in textbooks are shown as short strands bound by 1-2 proteins. Not really – ribonucleic acids are bundled up, associate with hundreds of proteins, cations, and other small molecules, and have a higher spherical dimension than proteins.

Quizz time! What is your guess for the physical length of a “typical human ribonucleic acid*” (let’s say 2-5kilobases)? Don’t look it up! Draw it on the image below in relation to a human egg, a skin cell, a yeast, bacterium, or viral capsid & send to [hjambor – at – gmail.com], I’ll include it in the collection below. Or just post your guess in micro-, nano, or picometers in the comments!

 

Answer:

……

 

……

 

……

A single nucleotide, which is the smallest building block, spans 3.4 Angstrom, or 340 picometers, or 0.3 nanometers. Three nucleotides encode one amino acid in a protein, therefore ribonucleic acids* three times longer than the respective protein. In addition, ribonucleic acids have many nucleotides that only serve regulatory purposes, they help with or block protein translation, or they influence  stability and degradation.

Screen Shot 2018-03-04 at 21.45.50

The average yeast ribonucleic acid is ~1500 nucleotides (Miura, BMC Genomics, 2008), which adds up to a whopping 510 nanometers, or 0.5 micrometers, spanning a good portion of the length of the entire budding yeast itself!

The average human ribonucleic acid molecule is 2000 to 6000 nucleotides, resulting in a physical length of 0.7 to 2 micrometers (Strachan and Read, 1999, Human molecular genetics). This is after a process called splicing, which removes about 60-80% of the nucleotides before a protein is even made from it. Before splicing, right when they are transcribed from the DNA template, human ribonucleic acids are 3-5 micrometers long – that is longer than a virus capsid, a bacterial cell, a yeast cell, and even larger than the diameter of the nucleus it is transcribed in! These are just averages, the longest human ribonucleic acids measure 100 (Titin) and even 600 micrometers (caspr2). To fit inside a cells, and the nucleus of a cell, ribonucleic acids curl up and are compacted. And even in the cytoplasm, where they are shorter, ribonucleic acids take up a lot of space – on average about half of the genes are transcribed at any given time point, and typically each ribonucleic acid is present in multiple copies.

Now compare your guess to the answers I got from molecular biologists – their replies varied from 10 nanometers to 100 micrometers! Mind you, my own guess was far off as well, and that after having worked with localized ribonucleic acids for over 10 years!

1_

What do we learn? Biological entities cover 10 magnitudes of scales, therefore faithful representations of size is neither possible nor expected in illustrations that merely symbolize information. On the other hand, our visual memory is pretty good – once we saw information as a picture, we tend to believe it. By memorizing false relative scales, we may thus loose an important information that may help us interpret research data.

* For the enthusiast: I mean messenger ribonucleic acids (mRNAs), the class that encodes proteins. These are generally longer than other categories of RNAs that do not encode proteins, such as rRNAs and tRNAs, miRNAs, and piRNAs.

 

Conformation of the insulin receptor

A few days back, my fellow CNV grantee Theresia Gutmann from the Coskun lab casually told me over dinner about her PhD work. In collaboration with the Rockefeller University NYC, Theresia had visualized the changing conformation of the human insulin receptor upon insulin binding (paper). Having just started at the Center for Regenerative Therapies Dresden with its focus on Diabetes, I could not believe that this had not been done before! To honor her achievement, I made a #sketchnote of the discovery and a GIF explaining insulin in our body (below).

theresia_new.pngInsulin:insulin_6

Paper: Gutmann, Kim et al. (2018): Visualization of ligand-induced transmembrane signaling in the full-length human insulin receptor. Journal of Cell Biology, DOI: 10.1083/jcb.201711047

 

 

Real viz coming soon, today status: tired!

I have a couple of thing I want to prepare and show, but we, as many in Germany, are submitting a DFG-excellence strategy grant next week. It’s a giant project, for seven years, with many many player’s and a lot of coordination, politics and details… To relax in the evening, i do what I always did to calm myself, drawing!

More information design soon!

Mom, can you draw a unicorn for me…

img_7807.jpg

Stop drawing me mom!

img_7804.jpg

Visualize calendar data in R

Last week, I visualized the days I did sports in 2017 by hand with illustrator. Most of the time, we want however re-tell similar data (I am not giving up sports anytime soon!), so I always look for ways to create visualizations computationally, for example in R. Therefore, today, I show you how to make a viz of data on days of a year in R.

First step: googling (or: duckduck-ing) to find a package other people use for this type of visualization. To my surprise, this took a very long time! Apparently, there is no default package in R that can visualize calendar data!? I found a very laborious solution that someone made with ggplot (referenced here: https://www.r-bloggers.com/ggplot2-time-series-heatmaps/), but it was > 10 lines of code. I then stumbled upon another package, made specifically for visualizing pollutants in air (!), but it works also for other data and is straightforward to use. openair” takes any dataframe with a “date”-column in the standard format (YYYY-MM-DD) and plots whatever you define as the “pollutant”. In my case, the days I did sports were the “pollutant”.

3 easy steps:

  1. Open your data in R, I called my dataframe “sports”.
  2. Then load library(openair)
  3. Plot: calendarPlot(sports, pollutant = “Sports”, year = 2017)

Voila!

Red: days I did sports, yellow: lazy days, white: sick days.

Screen Shot 2018-01-14 at 10.35.29

CalendarPlot() takes a lot more arguments, so you can adjust the colorscheme, labelling of the days and so forth.

Documentation:

http://www.openair-project.org/Downloads/Default.aspx

https://cran.r-project.org/web/packages/openair/index.html

 

 

A New Year’s resolution

*** UPDATE: below! *******

At some point in life, one has to start with sports to stay healthy. On my new job at the CRTD I learned that the brain cells increase with sports and that bones stay strong when close to strong muscles (they actually get signaling molecules telling them to stay young!). In the past years I also had my share of mental challenges, for which the positive influence of sports is widely known. My 2017 New year’s resolution was therefore to do sports as often as possible.

As I love data and data visualizations, I tracked my progress daily. You can see that I steadily increased the number of days with sports to a whopping 90% in July! In January and February, before I started the diary, it was well below half of the days! It is easier to run, swim etc. in summer, and I could not keep this up in fall. But I am very pleased to see that I am still doing sports 2/3 of days a month now. It was difficult keeping it up while traveling and when I had evening appointments (November, our visit of the President of Germany), but even in hotel rooms doing planks for 10 minutes is feasible. Most of the days without sports were when I had visitors!

myYear3

I also tracked exercise time, the kind of sports I did, and other aspects of my life such as my mood (hint: boring dataset, mainly correlates with female cycle!), my food and my alcohol intake. I chose to visualize the alcohol intake alongside here. Interestingly, there is no correlation between sports and alcohol. I do not drink on those days that I feel too miserable for sports. Some days I drank a sip (light grey, a small sherry or so) after my sports, some days I neither drank nor did sports.

My resolution for 2018: visualize data every day, and as often as possible blog about it. To start, here is the making off of this chart. Since I use my diary regularly, I recorded this data on paper:

IMG_0173

I thought about how to present it best. I wanted to show my daily grind and therefore kept it in the calendar format.

I started out making a dot for each day in a simple table format (Step 1) and then adjusted the number of days and numbered them to have a week-like format (Step 2). Sticking to standard practice: labeling 1, 8, 15 is of course counter-intuitive to a 7-day week format, I therefore changed the day labels to 7/14/21 (Step 3).

I then added the actual data: empty space for days without sports, a circle for days I did sports, and a cross for sick days (Step 4). Next, I started the graphic design part: decluttering wherever possible, playing with color and adjusting layout If necessary. For example, the table like grey boxes are not necessary (Step 5), and the lines separating the weeks are ugly, even in grey (Step 6)! Some guide is however needed to wade through the days. Gestalt principles show that white space is more effective in grouping than lines and boxes (Step 7). Using white space to separate the weeks made it necessary to then adjust the “no sports” data points from white to light grey.

Last was to add some more information, a summarizing bar chart showing percentage of days I did sports (not counting sick days), titles, axis labels, tick marks, and I the data of my alcohol consumption (for those months I tracked).

At last – and always at last only!  – I added color, and my favorite is blue. Voila!

 

************* UPDATE ****************

  • Holger commented that bars summarizing each month should be shown in same hue – they actually are, but with different opacity. I tried it without opacity.
  • Someone else wanted to see the months keyed to the weekdays, to check if I hate sports on Monday, and love it on Sundays. Sadly, no pattern emerges:

myYear4

Scales in scientific images

I recently saw drawings by Maria Sybilla Merian at Kupferstichkabinett Berlin and the University Library Dresden. Merian, who lived from 1647 to 1717, is renowned for her exceptional illustrations of biological specimens and gained recognition as a scientist for her nature observations, for example, of insect metamorphosis.

Maria Sibylla Merian (1647-1717) – “Das kleine Buch der Tropenwunder”, Insel Verlag, Leipzig Wiesbaden 1954, Public Domain, https://commons.wikimedia.org/w/index.php?curid=3319993

Merian evidently was genius in choosing frame and magnification in her drawings, but her pictures lack indications of scale*, which are essential in today’s science images. Scales give the reader the key for aligning the image content with reality. To my knowledge, neither Merian nor her predecessors from Antiquity, Byzantium, or Renaissance included scales in their medical and natural science images*. Even in the beginning of the 20th century, images were often considered a waste of space and scales unnecessary as scientists were familiar with each other’s apparatuses and objects. Today however we study invisible processes and structures that are unfamiliar to most of our colleagues and therefore have to include scales in our images.

Comment from Benjamin Moore in nature (1910) when reviewing a biochemistry handbook.

We often include in images a familiar object of a standard size for scale: a penny placed on a rock, a person standing beside a large animal or in a landscape, a measuring tape next to a fossil (or an Earth worm!).

Bar = 1cm (Earth worm lovingly raised by Jeff Woodruff).

Using familiar objects for scale isn’t possible for tiny things. We don’t have a clear mental image of the size of a salt grain or sesames seed to reliably use them to scale for instance cells**. We therefore include scale bars in microscopy images. With ImageJ/FIJI files from any microscope system can be read in along with their scaling information (shout-out to Curtis and Melissa and the Bio-Formats project!). By using Analyze > Tools > Scale Bar we can add the scale bar with a user-defined length, width, color, position, and label. Now the audience can calculate the actual size of objects and relate image with reality.

Four tips for superb scale bars

  • Length: Be kind to your audience and use simple units, such as 100um, 50um, 10 or 2um.
  • Color: Scale bars should have a high contrast with the background. Avoid red, green, or blue bars, as these colors might be considered part of the image.
  • Position: Lower left corner is a safe place. The upper space should be kept for important information like species, cell type, or gene name.
  • Add scale bar last: In the process of writing your manuscript you may re-think the figure size. Also images are re-sized for posters and slides. It is therefore easierst to add only a very fine scale bar with FIJI and then re-draw it in Adobe Illustrator (or PowerPoint, as I I know that about half of you out there use PowerPoint for making figures and posters!).

 

And finally, do not miss this article by Monica Zoppe with an interesting idea on how to communicate subcellular sclales better!

 

* I’d be delighted to stand corrected, and if you find old scientific images with scale bars, or interesting scales, send them my way for my collection!

** a great tool to update yourself in comparable scales in biology is here: http://learn.genetics.utah.edu/content/cells/scale/.

I never cease to be amazed at the relative size differences of cells and how they vary over so many magnitudes!