Controlling colours assigned to order in DeSeq2 plot in phyloseq
0
0
Entering edit mode
@sarahmacdonald86-12162
Last seen 7.7 years ago

Hello,

I am following the DeSeq2 tutorial in Phyloseq and I'm using the following code to plots OTUs by Genus, coloured by Order. I am doing multiple plots, which I want to then group together and the problem is that because some have different Orders included there is no colour consensus over the plots, for example so all Bacteroidales points are always red . Im struggling to find an answer to this? 

 

library("ggplot2")

theme_set(theme_bw())

scale_fill_discrete <- function(palname = "Set1", ...) {

scale_fill_brewer(palette = palname, ...)

}

# Order order

x = tapply(sigtab$log2FoldChange, sigtab$Order, function(x) max(x))

x = sort(x, TRUE)

sigtab$Order = factor(as.character(sigtab$Order), levels=names(x))

# Genus order

x = tapply(sigtab$log2FoldChange, sigtab$Genus, function(x) max(x))

x = sort(x, TRUE)

sigtab$Genus = factor(as.character(sigtab$Genus), levels=names(x))

ggplot(sigtab, aes(x=Genus, y=log2FoldChange, color=Order)) + geom_point(size=6) +

theme(axis.text.x = element_text(angle = -90, hjust = 0, vjust=0.5))

 

Dot_plot_UN_LS1 <- ggplot(sigtab, aes(x=Genus, y=log2FoldChange, color=Order)) + geom_point(size=6) + theme(axis.text.x = element_text(angle = -90, hjust = 0, vjust=0.5))

 

Dot_plot_UN_LS1 + ggtitle("Differentially abundant OTUs (uninfected vs LS 1)") + theme(plot.title = element_text(size = 10, face = "bold"))

 

Any help appreciated,

Cheers,

Sarah

phyloseq color ggplot2 • 2.1k views
ADD COMMENT
0
Entering edit mode

I'm not sure the answer, but it's more of a ggplot2 question than a DESeq2 one, so I'm removing the DESeq2 tag.

ADD REPLY
0
Entering edit mode

If I understand your question correctly, I believe the following link may provide a strategy.

http://stackoverflow.com/questions/6919025/how-to-assign-colors-to-categorical-variables-in-ggplot2-that-have-stable-mappin

ADD REPLY

Login before adding your answer.

Traffic: 573 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