how to plot an abundance table with ssp from metagenominc data
1
0
Entering edit mode
4.8 years ago
Lila M ★ 1.2k

Hi all, I need to analyze some metagenomic data from microbiome in human in two conditions: antibiotics and non antibiotics. I have two data set, one abundance table and one ID table (with ID and treatment: antibiotic/non antibiotic).

 #abundance table: 
 df
        name     ssp1  ssp2   ssp3   ssp4 
        1         0    0.002    0   0.002
        2         0    0.0006   0   0   
        3         0    0.0007   0   0.005
        4         0    0.009    0   0.0002
        5         0    4E-05    0   2E-05   
        6         0    6E-05    0   0   0

I generated a shanon diversity table :

shannon=diversity(df,  "shannon")
df_shanon <- data.frame(sample=names(shannon),value=shannon,measure=rep("Shannon", length(shannon)))

and I added the group so it looks like:

name        group     value
1   antibiotic      1.2926065
2   non_antibiotic  1.1550706
3   non_antibiotic  0.9115583
4   non_antibiotic  1.4000118
5   antibiotic      1.2459668
6   antibiotic      1.3967217

I wold like to generate a kind of abundance plot considering the two groups. I found plot_richness() quite interesting but I do not have a phyloseq object. Can someone give me a hand on this? Thanks!

OTUs metagenomic microbiome • 1.4k views
ADD COMMENT
0
Entering edit mode
4.8 years ago

Hi @Lila M,

The first thing that you shouldn't do is to add your column named "name" with the species abundance data with the diversity() function. Otherwise, it will include this column as species abundance data. Therefore I suggest to use the following (to remove the first column):

shannon=diversity(df[,-1],  "shannon")

Then, you can do:

df_shanon <- data.frame(sample=df$name,group=c("antibiotic",rep("non-antibiotic",3),rep("antibiotic",2)),value=shannon)

This last command will produce a table like yours.

Since plot_richness() inside phyloseq actually makes use of ggplot2 package, you can use directly ggplot2 (link: https://ggplot2.tidyverse.org/reference/ ). You can install ggplot2 by using install.packages("ggplot2"). Then run the following:

library("ggplot2") #import ggplot2

#make a plot with ggplot2

ggplot(df_shanon, aes(x=sample,y=value,color=group)) + geom_point() + theme_bw() + facet_grid(~measure, labeller = as_labeller(c(Shannon="Shannon Diversity"))) + xlab("Samples") + ylab("Alpha Diversity Measure")

The previous code will produce the following plot (link to the image: https://ibb.co/WW4vjN4 ):

plot_richness

I hope that this helps! António

ADD COMMENT
0
Entering edit mode

Thank you very much for your advise, but as in my data frame df the name is the col.names I do not have to remove the first col (if I do that, I'll miss the information for the ssp1 . However, what is the measure variable?

ADD REPLY
0
Entering edit mode

That makes sense (that the name column in your df is the col.names). The measure variable is missing in the df. Sorry! You just need to add a column with a character variable saying Shannon for all the observations and you can give as column name measure.
Try that and please let me know if it worked.

Cheers, António

ADD REPLY

Login before adding your answer.

Traffic: 1959 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6