Creating a stacked barchart in R with ggplot2 (CC102)

preview_player
Показать описание
A stacked barchart is a common approach to depicting relative abundance data in microbiome studies. How do you create stacked barplots in R with ggplot2? Shouild you even be creating stacked bar plots? Check out this episode of Code Club to learn how to create those iconic stacked bar charts and Pat will also tell you why they're problematic.

Do you have a figure that you would like to receive a critique or help improving? Let me know and I'd be happy to arrange a guest appearance!

You can also find complete tutorials for learning R with the tidyverse using...

0:00 Introduction
2:44 Aggregating relative abundances
7:58 Building stacked barchart
9:21 Improving appearance of labels
12:48 Improving appearance of legend
16:56 Critique of figure
21:00 Recap
Рекомендации по теме
Комментарии
Автор

What is your favorite way to represent relative abundance data?

Riffomonas
Автор

Looking forward to learning other ways of presenting this type of data. Thank you for these videos, I have learned a lot!

coralpardo
Автор

Can you tell me what the name of the tutorial is that comes before this one that explains the setting up of the initial code that is shown in the first few minutes of the video. Or provide the link. Thanks Mark Hodson

markhodson
Автор

I am trying to create a stacked bar chart for soil carbon inventories with two stacked bars (organic and inorganic C) for each site. Any guidance there? I can get one stacked chart but can't seem to get the second one to show up

kendallwojcik
Автор

Hi, thank you, professor. I have a problem I think I miss something. the y axis is scaled from 0-0.5 I have no clue how to fix it

alaakhalil
Автор

Thank you so much that I am trying to visualize. I learned a lot.

TruongNguyen-nmby
Автор

Thank you for the wonderful tutorials, please i have an issue with joining columns at data entering stage I don’t know how you arranged the OTU table, metadata and taxa tables. Need your help

saubanmusazango
Автор

I love your channels. A questions to you and fellow fans, is there a tutorial that walks us throw basic vegan package functions in R to calculate basic relative abundance for each taxonomic levels to start with?

zainabalradi
Автор

Thank you professor for this video. I have one question. In this figure, there is a legend "Cyanobacteria/chloroplast". As far as I understand chloroplast and cyanobacteria are two different things in microbiome data. Could you tell me why it's written "Cyanobacteria/chloroplast"?

monzurmorshed.
Автор

Hello, a question do you know how can fix this error in `geom_text()`: Can't find stat called "prop"?

mgsports
Автор

I order the groups by frequencies, so you kinda know if a group is more frequent in a bar or another. But yeah, I think this is the worst way to represent relative frequencies except for all the other ways that I know of.

faustovrz
Автор

Hi Pat. Great videos, helping massively with my PhD here in the UK.

Is it possible to create two different stacked bar chart charts from the same ‘cleaned data’ (generated in CC101)? For example, in relation to your videos, I have two time points. So for your data I would have NonDC1, DC1, C1 (as in timepoint 1) as well as NonDC2, DC2, C2 (as in timepoint 2).

I am interested in seeing only timepoint 1 variables in one chart, and timepoint 2 variables in another chart (ie 3 variables only on one chart, but I want to generate both using one string of commands).

I have tried editing your code to do this but I’m a newbie so still learning. For now, I will create two ‘clean up data’ codes to account for both timepoint and create both sets of charts separately, but I’m sure what I have described can be done from one ‘clean up data’ (otu_rel_abund collation)

Thanks in advance
James

jamesstanley
Автор

i have two legends and i want to show them in the top right of the graph, but in legend.position only top, left, right and bottom is available

rishikeshdash
Автор

Hi Pat,

Great tutorial. Thank you for making it available!

How did you group the OTUs that could not be assigned into phylum level into "Bacteria_unclassified"?

I have OTUs that could not be assigned at phylum level and are therefore "blank" at phylum level. This appears in my figure with "blank" instead of "Bacteria_unclassified".


Kind regards,
Martin

Rydaholic