Question: plotting boxplots in R
0
gravatar for vinayjrao
3 months ago by
vinayjrao100
JNCASR, India
vinayjrao100 wrote:

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.

box plots R • 264 views
ADD COMMENTlink modified 3 months ago by Vijay Lakhujani2.5k • written 3 months ago by vinayjrao100
2

You can find detailed documentation ggplot2-boxplot.

ADD REPLYlink written 3 months ago by arta480
2
gravatar for Vijay Lakhujani
3 months ago by
Vijay Lakhujani2.5k
India
Vijay Lakhujani2.5k wrote:

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 COMMENTlink modified 3 months ago • written 3 months ago by Vijay Lakhujani2.5k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1254 users visited in the last hour