Is there a package/function to generate random genomic position in R ? If not it's not complicated to write something using sample() but I do not want to re-re-re-reinvent the wheel ..
Edit : I wrote that. Some benchmarking with other given solutions in this thread seems to be required !
(Davetang is the author from gist.github.com/davetang/6548010):
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In fact it's not really random as my_random_chr[i]<- sample(x=my_chr,size=1) will pick a chromosome unregarding of its size. Anyway thank you I'll will rewrite the code for my usage and post it here ;)
what about bedtools [shuffle][1]. You can take a look at this link as well. Ideally they allow to pick up regions from the original master file.
I guess you can also use this code to generate one.
I don't think there is a function for it already, but I suggest you to get chromosome lengths from the TxDb.Hsapiens.UCSC.hg19.knownGene object from Homo.sapiens.
Is there a way to make random genomic ranges, but avoiding overlap between the segments? I want to randomly place non-overlapping segments (with a given length[width]) across the genome. Thanks.
(Davetang is the author from gist.github.com/davetang/6548010):
In fact it's not really random as
my_random_chr[i] <- sample(x=my_chr,size=1)
will pick a chromosome unregarding of its size. Anyway thank you I'll will rewrite the code for my usage and post it here ;)Nice but I don't like the for loop. It would be easy and much more elegant to convert it to a function and apply.
I wrote that : chr= chromosome names and chr.sizes = their associated size
You need a random position .may be with sample(1:length sequence,1,true) will gives one sample
what about bedtools
[shuffle][1]
. You can take a look at this link as well. Ideally they allow to pick up regions from the original master file. I guess you can also use this code to generate one.