Question: Plot Of Exons In R
4
pufferfish260 wrote:

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 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 • 3.8k views
modified 8.6 years ago by Steve Lianoglou5.0k • written 8.7 years ago by pufferfish260
4
Neilfws48k wrote:

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.

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...

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.

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

0
Steve Lianoglou5.0k wrote:

• 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.