On Thu, Feb 2, 2012 at 2:12 PM, Chris Stubben <stubben@lanl.gov> wrote:

> Does anyone know how to add strands and number of overlapping bases to the
> findOverlaps output?  For example, given these locations
>
> x <- GRanges( "chr",
>  IRanges( c(3,11,17,25,28), c(9,18,24,31,35)) ,
> c("-", "+", "+","-","+" ))
>
> and the findOverlaps output...
>
> y<- as.matrix(findOverlaps(ranges(**x), ignoreSelf=TRUE,
> ignoreRedundant=TRUE))
> y
>    query subject
> [1,]     2       3
> [2,]     4       5
>
> I'd like to add the query and subject strands and number of overlapping
> bases
>
> query subject strands overlap
>    2          3     ++       2
>    4          5     -+       4
>
>
The query and subject columns index into the original ranges, so just index
into their strand() to get the strands, i.e., strand(x)[y[,"query"].  You
can then paste() that together. To get the amount of overlap, use
width(pintersect(x[y[,"query"]], x[y[,"subject"]])).

I'm assuming you know how to combine the match matrix with other fields
into a data.frame.

Btw, in devel we have made RangesMatching contain Vector so it supports
element metadata. This would be a good use case.

Michael


> Thanks,
> Chris Stubben
>
>
>
> --
> Los Alamos National Lab
> BioScience Division
> MS M888
> Los Alamos, NM 87545
>
> ______________________________**_________________
> Bioconductor mailing list
> Bioconductor@r-project.org
> https://stat.ethz.ch/mailman/**listinfo/bioconductor<https://stat.ethz.ch/mailman/listinfo/bioconductor>
> Search the archives: http://news.gmane.org/gmane.**
> science.biology.informatics.**conductor<http://news.gmane.org/gmane.science.biology.informatics.conductor>
>

	[[alternative HTML version deleted]]

