Question: Controlling colours assigned to order in DeSeq2 plot in phyloseq
0
gravatar for sarahmacdonald86
2.8 years ago by
sarahmacdonald860 wrote:

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 ggplot2 color • 793 views
ADD COMMENTlink modified 2.8 years ago by Michael Love26k • written 2.8 years ago by sarahmacdonald860

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 REPLYlink written 2.8 years ago by Michael Love26k

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 REPLYlink written 2.8 years ago by rreck20
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 171 users visited in the last hour