This is a test version of Biostars. For the public version, visit https://www.biostars.org.
plotting boxplots in R

Hi,

I have a file consisting 3 columns (patient ID, subtype, rpkm - all of this for one gene), sorted by the second -

sample     subtype     rpkm

patient1     LumA     0.1253201

patient2     LumB     3.00531

I want to plot a box plot for this gene to check the variation for different subtypes. Could someone please guide me through it from the beginning, i.e. calculating the average and standard deviation across each sample for a particular subtype?

Thanks.

r box plots

1 answer

Consider a file like this one

[mycom]$ cat test.txt

sample  subtype rpkm
patient1    LumA    0.1253201
patient2    LumB    3.00531
patient3    LumA    4.00531
patient4    LumB    3.00531
patient5    LumB    2.00531
patient6    LumB    1.00531

Step 1. Read file

file=read.table("test.txt", stringsAsFactors=FALSE, header=TRUE,colClasses=c("character","factor","numeric"))

Step 2. draw boxplot

boxplot(rpkm ~ subtype, data=file, col=c("gold","darkgreen"))

Here is the output Here is the boxplot

You can interpret the boxplot using this link

Log in to answer this question.