1

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.

I would like to make a boxplot of these expression values in the following way and represent them as a boxplot ??

Boxplot

Paul
  • 1,077
  • 3
  • 14
  • 27
  • first prepare data in melted for with variables genotype, control_Treatment, L1L2, value...(hint `reshape2` package, `melt()` then we will go further – Ananta Oct 30 '13 at 18:00
  • @ Ananta: I know to reshape it when I have two conditions but am not sure how it works here. – Paul Oct 30 '13 at 18:12
  • Add a column to each data frame identifying control/treatment, then rbind – Señor O Oct 30 '13 at 18:35

1 Answers1

1
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()
Ananta
  • 3,671
  • 3
  • 22
  • 26