2016-08-01 39 views
0

我融化了我的數據框,它包含兩組:「高」和「低」,它們都具有組中每個門的相對丰度。我想創建一個堆疊條形圖,以便有兩列(高,低)和其充滿門類的比例超出100在R中製作一個堆積的細菌巴洛圖

Phylum   Group value 
1 Euryarchaeota High 0.0000000000 
2 Acidobacteria High 0.0000000000 
3 Actinobacteria High 0.0014929190 
4 Bacteroidetes High 0.6620724580 
5 Chloroflexi  High 0.0000000000 
6 Cyanobacteria High 0.0036403330 
7 Elusimicrobia High 0.0000000000 
8 Fibrobacteres High 0.0000000000 
9 Firmicutes  High 0.3299947690 
10 Fusobacteria High 0.0008169250 
11 GemmatimonadetesHigh 0.0000000000 
12 Lentisphaerae High 0.0000000000 
13 Nitrospirae  High 0.0000000000 
14 Planctomycetes High 0.0000000000 
15 Proteobacteria High 0.0010844560 
16 SR1    High 0.0000000000 
17 Spirochaetes High 0.0002579760 
18 Synergistetes High 0.0000000000 
19 TM7    High 0.0000000000 
20 Tenericutes  High 0.0000023900 
21 Verrucomicrobia High 0.0006377750 
22 [Thermi]  High 0.0000000000 
23 Euryarchaeota Low  0.0000018200 
24 Acidobacteria Low  0.0000015100 
25 Actinobacteria Low  0.0094485600 
26 Bacteroidetes Low  0.4611814500 
27 Chloroflexi  Low  0.0000009090 
28 Cyanobacteria Low  0.0005776960 
29 Elusimicrobia Low  0.0000272000 
30 Fibrobacteres Low  0.0000001330 
31 Firmicutes  Low  0.5217123900 
32 Fusobacteria Low  0.0005029220 
33 GemmatimonadetesLow  0.0000003990 
34 Lentisphaerae Low  0.0000044400 
35 Nitrospirae  Low  0.0000000444 
36 Planctomycetes Low  0.0000000222 
37 Proteobacteria Low  0.0027838720 
38 SR1    Low  0.0000002440 
39 Spirochaetes Low  0.0000716000 
40 Synergistetes Low  0.0000093400 
41 TM7    Low  0.0000555000 
42 Tenericutes  Low  0.0013692220 
43 Verrucomicrobia Low  0.0022507390 
44 [Thermi]  Low  0.0000000222 

我試圖繪製這樣的: ggplot(df_long, aes(x = "Group", y = value, fill = Phylum)) geom_bar(stat = "identity")但是情節是空的。

我在此之前融化我的數據框(如圖所示):df_long <- melt(data, id.vars = "Phylum", variable.name = "Group")

爲什麼我的陰謀沒有出現,因爲我想有什麼建議?

+0

這樣呢? ggplot(d,aes(x =門,y =值,fill =組))+ geom_bar(stat =「identity」,position =「dodge」)' – Jimbou

回答

0

你需要使用位置= 「堆」 在geom_bar功能,像這樣:

ggplot(df_long, aes(Group, value, fill=Phylum)) + geom_bar(stat="identity",   
position="stack")