Eu tenho o seguinte gráfico em R, que é um gráfico de barras:
dat <- data.frame(
FunctionClass = factor(c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "Y", "Z"), levels=c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "Y", "Z")),
legend = c("A: RNA processing and modification", "B: Chromatin structure and dynamics", "C: Energy production and conversion", "D: Cell cycle control, cell division, chromosome partitioning", "E: Amino acid transport and metabolism", "F: Nucleotide transport and metabolism", "G: Carbohydrate transport and metabolism", "H: Coenzyme transport and metabolism", "I: Lipid transport and metabolism", "J: Translation, ribosomal structure and biogenesis", "K: Transcription", "L: Replication, recombination and repair", "M: Cell wall/membrane/envelope biogenesis", "N: Cell motility", "O: Posttranslational modification, protein turnover, chaperones", "P: Inorganic ion transport and metabolism", "Q: Secondary metabolites biosynthesis, transport and catabolism", "R: General function prediction only", "S: Function unknown", "T: Signal transduction mechanisms", "U: Intracellular trafficking, secretion, and vesicular transport", "V: Defense mechanisms", "W: Extracellular structures", "Y: Nuclear structure", "Z: Cytoskeleton"),
Frequency=c(360,391,897,1558,1168,448,1030,536,732,1292,2221,2098,789,117,1744,732,437,5162,1251,2191,603,216,2,14,739)
)
library(ggplot2)
p <- ggplot(data=dat, aes(x=FunctionClass, y=Frequency, fill=legend))+
geom_bar(stat="identity", position=position_dodge(), colour="seashell")
p + guides (fill = guide_legend(ncol = 1))+
xlab("COG Class")+
ggtitle("COG distribution")
O enredo é assim: Barplot
No entanto, percebi que preciso fazer um gráfico de abundância diferencial, que se parece com isso: Gráfico de abundância diferencial
Alguma sugestão de como posso converter meu enredo para isso, mantendo as cores etc?
Aqui está a abundância diferencial: Abundância = c (, 2.2,3.4,3.3,2,1.1,0.1,0.1, -0.3, -0.9,3,2.1, -0.3, -0.9, -2, -1.2, - 0,4, -0,5, -3, -2, -0,3, -2,1, -1,3, -2,2, -3)) Obrigado!
Algo assim? A chave é reordenar os rótulos de acordo com a abundância primeiro, veja o fator (..) abaixo e depois faça ggplot. O -ve e + ve, você especifica com fill=Abundance
> 0 ..
dat$Abundance=c(2,2.2,3.4,3.3,2,1.1,0.1,0.1,-0.3, -0.9,3,2.1,-0.3,-0.9,-2,-1.2,-0.4,-0.5,-3,-2,-0.3,-2.1,-1.3,-2.2,-3)
dat$legend = factor(dat$legend,levels=dat$legend[order(dat$Abundance)])
ggplot(dat,aes(x=legend,y=Abundance,fill=Abundance>0))+
geom_col() + coord_flip()+
scale_fill_manual(values=c("lightblue","red"),
labels=c("negative","positive"))
Este artigo é coletado da Internet.
Se houver alguma infração, entre em [email protected] Delete.
deixe-me dizer algumas palavras