Plot Of Exons In R
2
4
Entering edit mode
12.8 years ago
pufferfish ▴ 290

I have a vector of ids in R which corresponds to the exons that another vector of probes belongs to. e.g

c(10001,10001,10002,10003,10004,10005)

where the first two probes belong to the same exon

How can I plot this on a graph as thick rectangles? The example below was generated with python, but I'd like to do this in R alt text

A more generic, portable solution would be preferable, since I could experiment with different plotting libraries myself. i.e. What sort of object would I need to create and plot?

This could perhaps be generalized and posted on Stackoverflow instead, but I suspect this is a problem others here have encountered already.

r exon visualization • 5.2k views
ADD COMMENT
4
Entering edit mode
12.8 years ago
Neilfws 49k

I assume you have more information than the vector of probe IDs, since you'll need it to generate a plot like your example.

I use GenomeGraphs from R Bioconductor for this type of plot. Take a look at the publication; you'll see some examples very similar to the one that you posted.

If that's not suitably "generic and portable", a lot can be achieved using ggplot2.

ADD COMMENT
0
Entering edit mode

Looking for something more generic. E.g. in python I converted it to vector of rectangle coordinates, then drew them. I'm hoping it's something easier in R. Some sort of interval operation on the list first to check whether a probe is part of the previous exon Will carry on scratching around...

ADD REPLY
0
Entering edit mode

Oops, yes I also have the intensity data, which I know how to plot. Only supplied the exon IDs because I'm specifically interested in how one would plot the horizontal bars below.

ADD REPLY
0
Entering edit mode

I assumed you'd need the exon coordinates (relative or absolute) for that.

ADD REPLY
0
Entering edit mode
12.8 years ago

Answering the questions that appear in your comments to @neifws:

  • You would simply plot a vector of rectangle coordinates using the rect function.
  • For generic interval operations, you should look into the GenomicRanges package, which is built on top of the functionality found in IRanges. Briefly, you would store the positions of where your probes align in a GRanges object and your exonic locations in an other GRanges object, then you'd use the findOverlaps or subsetByOverlaps functions to figure out which probes land in which exons.
ADD COMMENT

Login before adding your answer.

Traffic: 1823 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