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