Creating a relative abundance bar plot in R with qiime2 data

Hi there,

I think maybe the best way to do this is using RESCRIPt before importing the taxonomy QZA to phyloseq. See this RESCRIPt tutorial section explaining how to do it. I think this fits your needs, as the tutorial section says:

If for any reason you still want to do this directly in R, without getting too much into it (because I am not very familiar with phyloseq), AFAIK the phylogeny slot of the Phyloseq object is a character matrix, so some rudimentary base R code like:

mat[mat[, "ID_column"] == "AB000000", "Genus_column"] <- "Wolbachia_1"

mat[mat[, "ID_column"] == "AB000001", "Genus_column"] <- "Wolbachia_2"

should do the trick (I'm not familiar with SILVA either, I assume that, like UNITE, it has an identifier somewhere you can use for searching).

Also, it's quite likely that phyloseq or any other microbiome R package already has a built-in function to do this. But, again, I don't have experience with phyloseq. So I would stick to the RESCRIPt approach.

Best wishes,

Sergio

--

Disclaimer: I'm only another forum user, just like you. Please don't take my answer as a ground truth. A Forum Moderator would probably provide you with a more accurate answer.

2 Likes