Go Back   SEQanswers > Bioinformatics > Bioinformatics

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to zoom X axis using R? ziseputi Bioinformatics 3 03-07-2013 03:53 AM
SOLiD QV plot av_d SOLiD 5 07-19-2012 11:22 PM
LD decay plot xujie Bioinformatics 0 06-24-2012 07:26 AM
How to separate coverage of forward and reverse reads on same axis? Kennels Bioinformatics 6 05-04-2011 12:12 AM
Anyone seen an intensity plot like this? sequencer_lee Illumina/Solexa 7 07-11-2008 11:57 AM

Thread Tools
Old 05-15-2013, 01:08 AM   #1
Location: Bangalore, India

Join Date: Mar 2013
Posts: 42
Default Rscript plot for y-axis


I am plotting 2 y-axis graph. I have given the script

gene_lens<- read.table ('check.txt', header=FALSE)
colnames(gene_lens)<- c('gene', 'control', 'IP')
plot(gene_lens$gene, gene_lens$control, type='h', xlab='base position', ylim=c(0,1000), ylab='read depth', col="skyblue")
plot(gene_lens$gene, gene_lens$IP, type='h', xlab='base position', ylim=c(0,1000), ylab='read depth', col="red")

But it gives me y axis with 0, 200, 400, 600, 800, 1000. I just want 0, 500, 1000 to be on the scale. (Basically want to reduce the size of the graph). Kindly suggest any edition.

kushald is offline   Reply With Quote
Old 05-15-2013, 08:19 PM   #2
Location: RTP, NC, USA

Join Date: Jun 2009
Posts: 28

In future, it would be good to post a reproducible example, like including a small dummy data.frame for the "gene_lens" example you described. I made one up just to test, but I have no idea what your real data looks like.
Easiest way to accomplish your goal is to add this to your plot() call:
which will turn off printing the y-axis during the plot() call. Make sure to add it to both plot() commands.
Then use the axis() function with your specific requirements:
axis(2, at=c(0, 500, 1000));
I suggest adding xaxt="n" to the second plot() command, and silencing the second xlab and ylab so they wouldn't double-plot the labels (makes them look bold-pixelated.) Lastly, I didn't know how you intended to handle overlapping lines, so I improvised on line widths so I could see everything. Here is what I came up with:
gene_lens <- data.frame("gene"=c(100,500,750,900),
plot(gene_lens$gene, gene_lens$control, type='h',
    xlab='base position', ylim=c(0,1000), ylab='read depth',
    col="skyblue3", yaxt="n", lwd=6);
plot(gene_lens$gene, gene_lens$IP, type='h', xlab='',
    ylim=c(0,1000), ylab='', col="red", yaxt="n",
    xaxt="n", lwd=2);
atN <- c(0, 500, 1000);
axis(2, at=atN, labels=format(atN, big.mark=","), las=2);
I added format() to the axis labels so the numbers are a little friendlier, the "las=2" part to make the axis labels perpendicular to the y-axis. Avoids people having to twist their heads sideways to read the labels. Makes them look like confused puppies. :-)

Lastly, I'm not sure I'm familiar with this type of plot, but it seems like you're going for a sort of bar chart? If so, you may try the barplot2() function in the gplots package, something like this:
barplot2(t(as.matrix(gene_lens[,c("control", "IP")])), beside=TRUE,
   names.arg=gene_lens$gene, xlab='base position', col=c("seagreen", "orange"),
   yaxt="n", ylim=c(0,1000));
axis(2, las=2, at=c(0,500,1000));
jmw86069 is offline   Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -8. The time now is 03:04 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO