Warnings: regions$Name should be a factor containing UNIQUE names of the regions, ORDERED in the genome order.
We provide two data sets of autosomal humain genes, genes.b37 and genes.b38.
If x@snps$chr is not a vector of integers, it should be a factor with same levels as regions$Chr.
If flank.width is null, only the variants having their position between the regions$Start and the regions$End of a gene will be attributed to the corresponding gene.
When two regions overlap, variants in the overlapping zone will be assigned to those two regions, separated by a comma.
If flank.width is a positive number, variants flank.width downstream or upstream a gene will be annotated annotated to this gene. You can use flank.width = Inf
to have each variant attributed to the nearest gene.
If a variant is attributed to multiple genomic regions, it will be duplicated in the bed matrix with one row per genomic region if split = TRUE. Variants will have new IDs being CHR:POS:A1:A2:genomic.region.