Entering edit mode
6.2 years ago
WUSCHEL
▴
810
I'm interested in plotting faceted bar plots WT vs Mut gene. How can I improve my scripts to add colors? All attempts failed. WT -> Green bars and Mut -> orange bars. Also, I want to change the order of my faceting; Left WT, Right mut (3 raws * 2 col)
df <- structure(list(Genotype = c("mut", "mut", "mut", "mut", "mut", "mut", "mut", "mut", "mut", "mut", "mut", "mut", "mut", "mut", "mut", "WT", "WT", "WT", "WT", "WT", "WT", "WT", "WT", "WT", "WT", "WT", "WT", "WT", "WT", "WT"), Case = c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L), Time = c(1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L), Protein_Abundance = c(0.8, 0.8, 0.8, 0.8, 0.8, 1, 0.8, 0.6, 0.5, 0.3, 0.2, 0.4, 0.5, 0.6, 0.8, 1, 0.8, 0.7, 0.5, 0.4, 0.4, 0.6, 0.8, 0.9, 1, 0.9, 0.9, 0.9, 0.9, 0.9)), row.names = c(NA, -30L), class = c("tbl_df", "tbl", "data.frame"), spec = structure(list(cols = list(Genotype = structure(list(), class = c("collector_character", "collector")), Case = structure(list(), class = c("collector_integer", "collector")), Time = structure(list(), class = c("collector_integer", "collector")), Protein_Abundance = structure(list(), class = c("collector_double", "collector"))), default = structure(list(), class = c("collector_guess", "collector"))), class = "col_spec"))
Scripts
library(reshape2)
library(plotly)
library(readr)
library(ggplot2)
df$Genotype <- factor(df$Genotype, levels = c("WT","mut"))
colours <- c('#336600','#ff9900')
ggplot(df,aes(x=Time, y = Protein_Abundance, col=Genotype)) + geom_bar(stat='identity', position='dodge') +scale_fill_manual(values=colours)+ facet_wrap(Genotype ~ Case)
does it need to be factor? could you run this code without making genotype a factor?
yes I think it need to be a factor... I think BIOAWY wants to compare WT and mut in three different case. So to arrange each facet it need to be factor..
Thank you cpad012 :) Appreciate as always. I just needed to compare WT vs mut in 3 dif cases.
Thank you very much Prakash. I really do appreciate your kind help. Thanks again!