[Bioc-sig-seq] Random Intervals in GenomicRanges

Michael Dondrup Michael.Dondrup at uni.no
Thu Dec 2 16:23:58 CET 2010


Hi,

I don't know about a specific function (maybe there is) so I use the following code to simulate ranges. 
I simplified it a bit so it might not directly run but shows the concept.

simulate.GRanges <-  function (n, mean.length, genome.size ){
 # assuming read lengths are poisson distributed around the mean length, you could use a different random function
 # assuming reads are uniformly distributed wrt. start position 
  ir = IRanges(start=as.integer(runif(n, min=1, max=genome.size)), width=rpois(n, mean.length))
  ir = restrict(ir, 1, genome.size) # cut off reads at the end, not perfect
  strand = Rle(sample(x=c("+","-", "*"), size=n, replace=TRUE)) # make some strand information
  gr = GRanges(ir , seqnames="chr1",
    seqlengths=genome.size,
    strand=strand, universe="Mygenome") 
  return(gr)
}

You just need to get an estimate of read-length distribution from somewhere then.

Hope this is useful

Michael

On Dec 2, 2010, at 4:06 PM, Anna Terry wrote:

> Hi,
> 
> Is there any function in GenomicRanges (or other package) for getting a set of random ranges based on size distribution of a sample set?
> Similar functions are available in bedTools( http://code.google.com/p/bedtools/wiki/Usage#shuffleBed) and Random Intervals from the ENCODE tools on Galaxy.
> 
> Many Thanks
> Anna
> 
> _______________________________________________
> Bioc-sig-sequencing mailing list
> Bioc-sig-sequencing at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioc-sig-sequencing



More information about the Bioc-sig-sequencing mailing list