简体   繁体   English

R中的多个箱形图

[英]Multiple boxplots in R

I have gene expression data as follows: 我的基因表达数据如下:

       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

where the rows represent the genes and there are two conditions "control" and "treatment" which is further subdivided into "L1", "L2" and "L1" and "L2" respectively. 其中各行代表基因,有两个条件“对照”和“治疗”,分别分为“ L1”,“ L2”和“ L1”和“ L2”。

I would like to make a boxplot of these expression values in the following way and represent them as a boxplot ?? 我想通过以下方式制作这些表达式值的箱线图,并将它们表示为箱线图?

箱形图

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()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM