plotting boxplots in R
1
0
Entering edit mode
6.1 years ago
vinayjrao ▴ 250

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 • 4.7k views
ADD COMMENT
2
Entering edit mode

You can find detailed documentation ggplot2-boxplot.

ADD REPLY
2
Entering edit mode
6.1 years ago

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

ADD COMMENT

Login before adding your answer.

Traffic: 1814 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6