### R Boxplot Example

Boxplot usually refers to box-and-whisker plot, which is a popular method to show data by drawing a box around the 1st and 3rd quartile, and the whiskers for the smallest and largest data values, the median is represented by a bold line in the box.

Following is a csv file example "boxplot.csv", we will draw a boxplot of "Expression" based on Subtype "A", "B" and "C":

Let first read in the data from the file:

> x <- read.csv("boxplot.csv",header=T,sep="\t") > x <- t(x) > a <- as.numeric(x[2,1:143]) > b <- as.numeric(x[2,144:218]) > c <- as.numeric(x[2,219:ncol(x)])

Box plot based on subtype A, B and C:

> boxplot(a,b,c,col=c("red","blue","green"),names=c("A","B","C"), + xlab="Subtype",ylab="Expression")

The above plot shows that the Expression values for Subtype A, B and C are similar, however the two sub-boxes around the median of Subtype C is wider than B and A, the data are not symmetrically distributed around the median.

if the 'notch' parameter is 'TRUE', a notch is drawn in each side of the boxes. If the notches of two plots do not overlap this is 'strong evidence' that the two medians differ.

> boxplot(a,b,c,col=c("red","blue","green"),names=c("A","B","C"), + notch=TRUE, xlab="Subtype",ylab="Expression")

We can write the plot into a file:

> png("boxplot1.png",400,300) > boxplot(a,b,c,col=c("red","blue","green"),names=c("A","B","C"), + xlab="Subtype",ylab="Expression") > graphics.off()

Boxplot function parameters list: