Placing random non-overlaping segments across genome [GenomicRanges]
1
0
Entering edit mode
4.3 years ago

I am trying to make a script that will place non-overlapping genomic ranges across the genome.

Say for example I have a genomic ranges object like this:

GRanges object with 301 ranges and 0 metadata columns:
        seqnames              ranges strand
           <Rle>           <IRanges>  <Rle>
    [1]        1     4170526-4575820      *
    [2]        1   37967685-38149272      *
    [3]        1   48355039-48669750      *
    [4]        1 105099715-105482195      *
    [5]        1 125516774-126315385      *
    ...      ...                 ...    ...
  [297]       22   42501405-43058117      *
  [298]       22   45336458-45457711      *
  [299]       22   47534379-47788622      *
  [300]       22   47818121-47906157      *
  [301]       22   49589077-50320800      *
  -------
  seqinfo: 22 sequences from an unspecified genome; no seqlengths

These are all non-overlapping segments.

Is there a way to place randomly the same number and size of segments across the genome avoiding overlap? I.e. keeping the structure of the original genomic ranges object?

I am using a for loop and if statements, but the code is rather slow and messy.

Thanks.

r genomicranges • 1.2k views
ADD COMMENT
1
Entering edit mode
4.3 years ago

The regioneR library has a few handy functions for this. randomzieRegions will take a GRanges object, and shuffle the ranges around the genome. This sounds closest to what you want to do. createRandomRegions will generate a set of random regions given certain parameters.

ADD COMMENT
0
Entering edit mode

Thank you, I will check this package. Yes, the first functions looks very close to what I want to do!

ADD REPLY

Login before adding your answer.

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