Returns a data.table showing counts of regions from the query that overlap with each bin. In other words, where on which chromosomes are the ranges distributed? You must provide binned regions. Only the midpoint of each query region is used to test for overlap with the bin regions.

calcChromBins(query, bins)

Arguments

query

A GenomicRanges or GenomicRangesList object with query regions

bins

Pre-computed bins (as a GRangesList object) to aggregate over; for example, these could be genome bins

Value

A data.table showing where on which chromosomes ranges are distributed.

Examples


chromSizes = getChromSizes("hg19")
genomeBins  = getGenomeBins(chromSizes)
chromDistribution = calcChromBins(vistaEnhancers, genomeBins)
#> Finding overlaps...
#> Setting regionIDs...
#> Combining...

vistaSftd = GenomicRanges::shift(vistaEnhancers, 100000)
vistaSftd2 = GenomicRanges::shift(vistaEnhancers, 200000)
calcChromBins(vistaEnhancers, GRangesList(vistaSftd, vistaSftd2))
#> Finding overlaps...
#> Setting regionIDs...
#> Combining...
#> Key: <regionID>
#>     regionID    chr     start       end withinGroupID regionGroupID     N
#>        <int> <fctr>     <int>     <int>         <int>         <int> <int>
#>  1:       51   chr1  83410681  83411769            51             1     1
#>  2:      100   chr1 213598113 213601134           100             1     1
#>  3:      115  chr10  36072893  36075932           115             1     1
#>  4:      143  chr10 102547082 102548985           143             1     1
#>  5:      192  chr11  31785358  31786884           192             1     1
#>  6:      306  chr14  29960530  29962348           306             1     1
#>  7:      437  chr16  54349595  54351153           437             1     1
#>  8:      444  chr16  54679727  54680655           444             1     1
#>  9:      629   chr2  59202072  59203380           629             1     1
#> 10:      636   chr2  59303218  59304548           636             1     1
#> 11:      663   chr2  66397528  66399214           663             1     1
#> 12:      716   chr2 146797739 146798645           716             1     1
#> 13:      739   chr2 164449677 164451112           739             1     1
#> 14:      788  chr20  39472457  39475024           788             1     1
#> 15:      996   chr5  92526547  92528433           996             1     1
#> 16:     1070   chr6  98361650  98363117          1070             1     1
#> 17:     1072   chr6  98462400  98463804          1072             1     1
#> 18:     1131   chr7  35459005  35459854          1131             1     1
#> 19:     1170   chr7 114395110 114396373          1170             1     1
#> 20:     1316   chrX  25015383  25018272          1316             1     1
#> 21:     1383   chr1  63664283  63665717            44             2     1
#> 22:     1577  chr12 103571348 103572610           238             2     1
#> 23:     1638  chr14  28598564  28600621           299             2     1
#> 24:     1643  chr14  29910886  29913340           304             2     1
#> 25:     1777  chr16  54523421  54524336           438             2     1
#> 26:     1958   chr2  58948341  58950140           619             2     1
#> 27:     2057   chr2 147333971 147334751           718             2     1
#> 28:     2409   chr6  98461650  98463117          1070             2     1
#> 29:     2514   chr7 115313552 115314543          1175             2     1
#> 30:     2636   chr9 128606148 128607653          1297             2     1
#>     regionID    chr     start       end withinGroupID regionGroupID     N