该图的简要概述:
我的问题:我无法弄清楚如何将箱子集合分成4个子图 - 一个对应于每个谱系 - 同时保持着色和组织(所有颜色在一起并且在每个谱系子图中以相同的顺序排列) )。
以下是我的数据的说明性子集:
Lineage Genes Category V3
EAS EAS1 cell wall and cell processes 0.1071428571
EAS EAS2 conserved hypotheticals 0.1071428571
EAS EAS3 PE/PPE 0.0357142857
EAS EAS4 lipid metabolism 0.0357142857
EAS EAS5 lipid metabolism 0.0357142857
EAS EAS6 conserved hypotheticals 0.0357142857
EAS EAS7 conserved hypotheticals 0.0357142857
EAS EAS8 conserved hypotheticals 0.0357142857
EAI EAI3 PE/PPE .111
EAI EAI4 PE/PPE .111
EAI EAI5 conserved hypotheticals .111
EAI EAI6 intermediary metabolism and respiration .111
EAI EAI7 cell wall and cell processes .222
EAI EAI8 intermediary metabolism and respiration .111
EAI EAI9 conserved hypotheticals .111
IO IO1 information pathways 0.1666666667
IO IO2 virulence, detoxification, adaptation 0.1666666667
IO IO3 conserved hypotheticals 0.1666666667
IO IO4 cell wall and cell processes 0.3333333333
IO IO5 PE/PPE 0.3333333333
IO IO6 intermediary metabolism and respiration 0.1666666667
IO IO7 PE/PPE 0.1666666667
IO IO8 PE/PPE 0.1666666667
IO IO9 insertion seqs and phages 0.3333333333
EAM EAM1 insertion seqs and phages 0.2727272727
EAM EAM2 cell wall and cell processes 0.0454545455
EAM EAM3 lipid metabolism 0.0454545455
EAM EAM4 conserved hypotheticals 0.0454545455
我运行的代码用于生成当前图表:
# Loading in my data
PanppData <- read.table("Allpp", header = TRUE, sep = "\t")
# Making ordering depend on category
PanppData$Genes <- factor(PanppData$Genes, levels=PanppData$Genes[order(PanppData$Category)]) # Making ordering depend on Category
# Generating the Graph
ggplot(PanppData, aes(x=Genes, V3)) +
geom_bar(aes(fill=Category),
stat="identity",
colour="white",
position= "dodge") +
ggtitle("EAS EAI IO EAM") +
labs(x="Genes",y="Decimal Fraction of Isolates")
我希望图表能够保持其顺序和着色,但是要分成四个子图 - 每个谱系一个子图 - 每个子图包含该谱系内所有基因的区域。
我尝试使用融化但没有成功。
我只用了几个星期的R,并且已经在这个图表上工作了两位数,为即将召开的会议做准备。非常感谢任何帮助或指导!!
我希望我的问题很明确。这是我第一次向Stackoverflow发帖提问,所以如果我能做任何事情让我的问题更加清晰,有用等,请告诉我。