Hey folks, In last week’s newsletter, I introduced a new approach that I plan on taking in these emails to help you develop your intuition with visualizing data in R (or any language). I asked you to consider a random figure that I found in the most recent issue of the journal mSphere. It’s Figure 1A from the paper, “Exploring novel microbial metabolites and drugs for inhibiting Clostridioides difficile” by Ahmed Abouelkhair and Mohamed Seleem. The figure shows the level of inhibition of bacterial growth by 527 compounds; 63 of the compounds were deemed “strong hits” because they inhibited growth by at least 90%. Without worrying about actual code, I encouraged you to think about the data and functions you’d need to generate this figure. Here were my random thoughts: This is a scatter plot with compounds giving more than 90% inhibition were a burgundy color and those with less were given a green color. There’s also a dashed line indicating the 90% threshold. It took me a minute or two to notice that the x-axis is meaningless. It’s likely the order of the compounds in their database (there seems to be a non-random pattern to the data about 3/4th the way across the axis). I also noticed that there’s no line on the x-axis, but there is a line at zero. Those are the parts of the figures, described in a way that you could probably use to make a similar looking figure with any tool. Now, how would we do this in R? Let’s start with the data. I assume that the data will be a data frame with two columns, one for the compound name ( I do everything in ggplot2 nowadays, so I start thinking about what geom I’ll use. Probably Next, I’d think about the colors. I’d use Let’s move on to the x-axis and the two lines. First, I’d use the Now let’s think about the y-axis. By default we might get the values on the y-axis that the figure already has. But to be safe, we can use I think that’s everything, right? I’d encourage you to go back through that narrative and assess what you do and don’t understand. Then look at online R resources, including my Riffomonas materials (MinimalR and generalR) and the R Graphics Cookbook for examples of how to use the new concepts. Finally, see if you can generate the figure yourself using some simulated data. The code below should be close enough to what you need:
Please let me know how this works out for you! Also, if you have a favorite figure that you'd love to see me break down, reply to this email and I'll see about using it in a future newsletter
|
Hey folks, I hope you have enjoyed the current series of newsletters and videos recreating “data portraits” from the WEB DuBois collection of visuals he showed at the 1900 Paris Exhibition. You can find the entire collection of “data portraits” in a book assembled by Whitney Battle-Baptiste and Britt Rusert (here) or as a collection of plates through the Library of Congress (here). I’ve really appreciated the positive feedback! These figures are pretty different from what we do in modern data...
Hey folks, I hope you enjoyed thinking last week about how you would recreate Plate 12 from the WEB DuBois collection of visuals he showed at the 1900 Paris Exhibition using ggplot2 and related R tools. You can find the entire collection of “data portraits” in a book assembled by Whitney Battle-Baptiste and Britt Rusert (here) or as a collection of plates through the Library of Congress (here). I won’t reshare all the resources describing the collection, but do encourage you to check out last...
Hey folks, I’m at the end of a day after I pulled an all-nighter trying to hit a grant proposal deadline. I don’t recall ever doing this in college. I seem to pull an all-nighter every five years or so. I’m too old for this! Anyway, the proposal is in and now I’m ready to move on to fun things… like talking to you about visualizing data! A few years back Whitney Battle-Baptiste and Britt Rusert put together an amazing collection of visualizations by WEB DuBois that he presented at the 1900...