I am trying to graph my phyloseq/deseq2 data output (Log2FoldChange on y and Species name on x) in ggplot and I would like to be able to order them by autotrophs and heterotrophs as well as max-min value. I have a column I added into the Taxa file named "Trophic".
The pipeline turns the phyloseq object into a deseq object, and that is where Log2FoldChange comes in.
Then they're combined, which is what I am working with. (Here is the tutorial if you need more)
I have this code, which I think orders the species by highest to lowest Log2FoldChange and comes out with a graph like this.
x = tapply(sigtab$log2FoldChange, sigtab$Species, function(x) max(x))
x = sort(x, TRUE)
sigtab$Species = factor(as.character(sigtab$Species), levels=names(x)
However, I am not exactly sure how to modify this in order to have them sorted first by trophic status and then by species and then plotted as such.
I would basically like to be able to have two "sides" of the same graph (auto then hetero), both ordered from max value to min value of Log2FoldChange.
Could anyone please help me figure this out?