Arithmetic Operations Between GRanges' Scores
0
0
Entering edit mode
Dario Strbenac ★ 1.5k
@dario-strbenac-5916
Last seen 4 days ago
Australia

Is there any in-built functionality that can do arithmetic operations on different GRanges objects? For example, I would like to determine the difference in segmented copy number between the tumour tissue and cell line of a particular patient.

primaryTumourRanges <- GRanges("chr1", IRanges(c(1, seq(1001, 3001, 1000)), width = 1000), copyNumber = 1:4)
primaryTumourRanges 
GRanges object with 4 ranges and 1 metadata column:
      seqnames    ranges strand | copyNumber
         <Rle> <IRanges>  <Rle> |  <integer>
  [1]     chr1    1-1000      * |          1
  [2]     chr1 1001-2000      * |          2
  [3]     chr1 2001-3000      * |          3
  [4]     chr1 3001-4000      * |          4
cellLineRanges <- GRanges("chr1", IRanges(start = c(1, 1501), end = c(1500, 4000)), copyNumber = c(2, 4))
cellLineRanges 
GRanges object with 2 ranges and 1 metadata column:
      seqnames    ranges strand | copyNumber
         <Rle> <IRanges>  <Rle> |  <numeric>
  [1]     chr1    1-1500      * |          2
  [2]     chr1 1501-4000      * |          4
difference
GRanges object with 5 ranges and 1 metadata column:
      seqnames    ranges strand | difference
         <Rle> <IRanges>  <Rle> |  <numeric>
  [1]     chr1    1-1000      * |          1
  [2]     chr1 1001-1500      * |          0
  [3]     chr1 1501-2000      * |          2
  [4]     chr1 2001-3000      * |          1
  [5]     chr1 3001-4000      * |          0

Is there a more concise way to compute difference than concatenating ranges of both samples, disjoining them, finding the overlaps of the disjoint ranges to each of the original samples' ranges and finally subtracting the copy numbers between the disjointed ranges of cell line and tumour?

GenomicRanges • 804 views
ADD COMMENT

Login before adding your answer.

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