SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
Genomic data plotting/visualization pirates.genome Bioinformatics 2 05-15-2014 09:56 PM
plotting graph in R from a bed file aevgup Bioinformatics 1 04-21-2014 02:06 PM
Plotting replicate FPKMs in log10 sazz Bioinformatics 3 07-20-2013 08:44 AM
edgeR plotting error stephenhart General 0 12-06-2012 03:07 AM
tool for plotting bioenvisage General 1 02-15-2010 10:12 AM

Reply
 
Thread Tools
Old 04-25-2014, 10:26 AM   #1
aevgup
Member
 
Location: usa

Join Date: Jul 2011
Posts: 17
Default Plotting in R

Hi Everyone,

I am trying to plot a histogram in R using this command which is serving my purpose

x <- read.table(file="cov.txt",header =FALSE)
When you look at the graph(see attached) then from 715 to 777 is my CODING REGION. I want to make a rectangular bar from position 715-777 and place it on the top of the graph. How can I do it

I wrote this and try to add lines or points but was not able to do it
firstCodonCdr1 = 239
lastCodonCdr1 = 259
cdr1NTs = ((firstCodonCdr1-1)*3+1)3*lastCodonCdr1)
cdrPositions = cdr1NTs

Any help !!

Thanks
Attached Images
File Type: png cov.png (3.7 KB, 10 views)

Last edited by aevgup; 04-25-2014 at 10:41 AM.
aevgup is offline   Reply With Quote
Old 04-25-2014, 10:49 AM   #2
blakeoft
Member
 
Location: Connecticut

Join Date: Oct 2013
Posts: 79
Default

I think you want to use the polygon function. See ?polygon to look at the help info. Basically:
Code:
polygon(x,y,col)
where x is the vector containing x coordinates of the vertices, y is y vertices and col is the color of the polygon. I think you'll plot your histogram, and then polygon() right after it. So it'll look like:
Code:
> hist(data)
> polygon(x,y,col)

Last edited by blakeoft; 04-25-2014 at 10:51 AM.
blakeoft is offline   Reply With Quote
Old 04-25-2014, 10:57 AM   #3
aevgup
Member
 
Location: usa

Join Date: Jul 2011
Posts: 17
Default plotting in R

Hi I used this code
x <- read.table(file="cov.txt",header =FALSE)

firstCodonCdr1 = 239
lastCodonCdr1 = 259
cdr1NTs = ((firstCodonCdr1-1)*3+1)3*lastCodonCdr1)
cdrPositions = cdr1NTs

plot(x$V2,x$V3,type="h",col="blue")
r = rep(50,63) # to make 63 times 50 to occur so that it matches length of x
par(new=TRUE)

polygon(cdrPositions,r,col="red")

No change happens in the graph.

I am attaching the cov.txt file too

I have been trying points and lines too but no luck!!

THanks
Attached Images
File Type: png cov.png (3.7 KB, 6 views)
Attached Files
File Type: txt cov.txt (3.1 KB, 4 views)
aevgup is offline   Reply With Quote
Old 04-25-2014, 11:18 AM   #4
blakeoft
Member
 
Location: Connecticut

Join Date: Oct 2013
Posts: 79
Default

This looks terrible, but I just did
Code:
> x <- read.table(file="cov.txt",header =FALSE)
> plot(x$V2,x$V3,type="h",col="blue")
> polygon(c(715,777,777,715),c(40,40,45,45), col="blue")
and got this picture. You can change the coordinates of the box if you want so that it doesn't look as bad, and also, the color might need some work. I think you can do it like col = rgb(a,b,c) where a b and c are the red blue and green color values.
Attached Images
File Type: png bar_on_hist.png (12.3 KB, 9 views)
blakeoft is offline   Reply With Quote
Old 04-25-2014, 11:31 AM   #5
aevgup
Member
 
Location: usa

Join Date: Jul 2011
Posts: 17
Default

Thanks for the reply. Your answer gave me another way to do it. How about this
Quote:
x <- read.table(file="cov.txt",header =FALSE)
plot(x$V2,x$V3,type="h",col="blue")
lines(c(715,777),c(45,45),col="red",lwd=8)
Regards
Attached Images
File Type: png cov2.png (3.7 KB, 10 views)
aevgup is offline   Reply With Quote
Old 04-29-2014, 04:57 AM   #6
Thias
Member
 
Location: Münster, Germany

Join Date: Mar 2013
Posts: 42
Default

Seems your problem is already solved, but in case you have 5o plot similar data in future again, I recommend the Gviz package on Bioconductor, which can be used to output beautiful plots for NGS-data.
Thias is offline   Reply With Quote
Old 04-29-2014, 06:41 AM   #7
aevgup
Member
 
Location: usa

Join Date: Jul 2011
Posts: 17
Default

Hi,
Thanks for letting me know about the package. I am trying this package now
aevgup is offline   Reply With Quote
Reply

Tags
plot

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 08:28 AM.


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