Question: Minimal region of overlap between two GRanges objects
1
8.0 years ago by
Daniel Brewer1.9k
Daniel Brewer1.9k wrote:
Dear mailing list, I have two GRanges objects each containing segments of copy number change for a tumour. I would like to find regions where there is copy number change in both the tumours. I though findOverlaps was giving me what I wanted but soon found that findOverlaps(A,B) != findOverlaps(B,A). I am sure there must be a reasonable way to do this but I cannot find it. Thanks Dan -- ************************************************************** Daniel Brewer, Ph.D. Institute of Cancer Research ************************************************************** The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP. This e-mail message is confidential and for use by the a...{{dropped:5}}
cancer • 790 views
modified 8.0 years ago by Martin Morgan ♦♦ 24k • written 8.0 years ago by Daniel Brewer1.9k
Answer: Minimal region of overlap between two GRanges objects
0
8.0 years ago by
Martin Morgan ♦♦ 24k
United States
Martin Morgan ♦♦ 24k wrote:
On 12/13/2011 07:00 AM, Daniel Brewer wrote: > Dear mailing list, > > I have two GRanges objects each containing segments of copy number > change for a tumour. I would like to find regions where there is > copy number change in both the tumours. I though findOverlaps was > giving me what I wanted but soon found that findOverlaps(A,B) != > findOverlaps(B,A). I am sure there must be a reasonable way to do > this but I cannot find it. Hi Dan -- > a = GRanges("chrA", IRanges(11, 20), seqlengths=c(chrA=100)) > b = GRanges("chrA", IRanges(16, 25), seqlengths=c(chrA=100)) > intersect(a, b) GRanges with 1 range and 0 elementMetadata values: seqnames ranges strand <rle> <iranges> <rle> [1] chrA [16, 20] * --- seqlengths: chrA 100 but maybe a working example from your end would help clarify what you're after / where things go wrong for you with findOverlaps. Martin > > Thanks > > Dan > -- Computational Biology Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: M1-B861 Telephone: 206 667-2793
Thanks Martin, Yes you're right a simple intersect works great. I had a suspicion I was missing something very obvious. Many thanks. Dan On 13 Dec 2011, at 4:49 PM, Martin Morgan wrote: > On 12/13/2011 07:00 AM, Daniel Brewer wrote: >> Dear mailing list, >> >> I have two GRanges objects each containing segments of copy number >> change for a tumour. I would like to find regions where there is >> copy number change in both the tumours. I though findOverlaps was >> giving me what I wanted but soon found that findOverlaps(A,B) != >> findOverlaps(B,A). I am sure there must be a reasonable way to do >> this but I cannot find it. > > Hi Dan -- > >> a = GRanges("chrA", IRanges(11, 20), seqlengths=c(chrA=100)) >> b = GRanges("chrA", IRanges(16, 25), seqlengths=c(chrA=100)) >> intersect(a, b) > GRanges with 1 range and 0 elementMetadata values: > seqnames ranges strand > <rle> <iranges> <rle> > [1] chrA [16, 20] * > --- > seqlengths: > chrA > 100 > > but maybe a working example from your end would help clarify what you're > after / where things go wrong for you with findOverlaps. > > Martin > >> >> Thanks >> >> Dan >> > > > -- > Computational Biology > Fred Hutchinson Cancer Research Center > 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 > > Location: M1-B861 > Telephone: 206 667-2793 -- ************************************************************** Daniel Brewer, Ph.D. Institute of Cancer Research Molecular Carcinogenesis MUCRC 15 Cotswold Road Sutton, Surrey SM2 5NG United Kingdom Tel: +44 (0) 20 8722 4109 ************************************************************** The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP. This e-mail message is confidential and for use by the a...{{dropped:5}}