Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R中的多箱线图_R_Ggplot2_Data Visualization_Boxplot - Fatal编程技术网

R中的多箱线图

R中的多箱线图,r,ggplot2,data-visualization,boxplot,R,Ggplot2,Data Visualization,Boxplot,我有如下基因表达数据: Control Treatment L1 L2 L1 L2 g1 10.5 12 13 14 g2 11 13 10.5 12 g3 10 9 11 10 g4 9 8 6 5 g5 16 4

我有如下基因表达数据:

       Control            Treatment
        L1    L2          L1   L2      
 g1   10.5    12          13   14  
 g2    11     13          10.5 12  
 g3    10     9           11   10   
 g4    9      8           6     5 
 g5    16     4           4     6
 g6    11     12          5     4
 g7    10     6           13    12 
 g8    5      4           12    12  
 g9    11     12          10    11.5   
 g10   8.9    7.8         7.6   5.8
其中,行代表基因,有两个条件“控制”和“治疗”,这两个条件进一步细分为“L1”、“L2”和“L1”和“L2”

我想用以下方式制作这些表达式值的箱线图,并将它们表示为箱线图

x
    V1   V2   V3   V4   V5
1   g1 10.5 12.0 13.0 14.0
2   g2 11.0 13.0 10.5 12.0
3   g3 10.0  9.0 11.0 10.0
4   g4  9.0  8.0  6.0  5.0
5   g5 16.0  4.0  4.0  6.0
6   g6 11.0 12.0  5.0  4.0
7   g7 10.0  6.0 13.0 12.0
8   g8  5.0  4.0 12.0 12.0
9   g9 11.0 12.0 10.0 11.5
10 g10  8.9  7.8  7.6  5.8


x.m<-melt(x, id.var="V1")
x.m$control<-ifelse(x.m$variable %in% c("V2", "V3"), "Control","Treatment")
x.m$L<-ifelse(x.m$variable %in% c("V2", "V4"), "L1","L2")

ggplot(x.m, aes(x=L,y=value,  fill=control))+geom_boxplot()

x
V1 V2 V3 V4 V5
1 G110.5 12.0 13.0 14.0
2 g2 11.0 13.0 10.5 12.0
3 g3 10.0 9.0 11.0 10.0
4 g4 9.0 8.0 6.0 5.0
5G516.044.046.0
6 g6 11.0 12.0 5.0 4.0
7 g7 10.0 6.0 13.0 12.0
8G8 5.0 4.0 12.0 12.0
9 g9 11.0 12.0 10.0 11.5
10 g10 8.9 7.8 7.6 5.8
x、 m
x
V1 V2 V3 V4 V5
1 G110.5 12.0 13.0 14.0
2 g2 11.0 13.0 10.5 12.0
3 g3 10.0 9.0 11.0 10.0
4 g4 9.0 8.0 6.0 5.0
5G516.044.046.0
6 g6 11.0 12.0 5.0 4.0
7 g7 10.0 6.0 13.0 12.0
8G8 5.0 4.0 12.0 12.0
9 g9 11.0 12.0 10.0 11.5
10 g10 8.9 7.8 7.6 5.8

x、 首先准备melted中的变量数据,包括基因型、对照治疗、L1L2、值…(提示
restrape2
package,
melt()
然后我们将进一步@Ananta:当我有两个条件时,我知道要重塑它,但不确定它在这里是如何工作的。在每个数据框中添加一列,标识控制/治疗,然后RBIND首先准备MELD中的数据,变量为基因型、控制治疗、L1L2、值…(提示
重塑2
包,
melt()
然后我们将进一步@Ananta:我知道当我有两种情况时要对其进行重塑,但不确定它在这里是如何工作的。在每个数据框中添加一列,标识控制/治疗,然后rbind