Given a Genomic Ranges of SNPs, how to inject these SNPs in genome via BSGenome? Let's say I have the genome hg19 loaded into R via BSGenome

library("BSgenome")    
hg19genome = getBSgenome('BSgenome.Hsapiens.UCSC.hg19', masked=FALSE)   


I then have a list of SNPs loaded as a GRanges object, gr

library(GenomicRanges)

 &gt; gr
 GRanges object with 212 ranges and 3 metadata columns:                                                                                                                                                                                                                                                                                                                                                
        seqnames               ranges strand |     width     REF    ALT                                                                                                                                                                                                                                                                                                                             
           &lt;Rle&gt;          v &lt;IRanges&gt;  &lt;Rle&gt; | &lt;numeric&gt;                                                                                                                                                                                                                                                                                                                        
    [1]        1 [86099032, 86099032]      * |         1     C      T                                                                                                                                                                                                                                                                                                                  
    [2]        1 [86099033, 86099033]      * |         1     C      A                                                                                                                                                                                                                                                                                                                   
    [3]        1 [86099199, 86099199]      * |         1     G      A  
  ....


Is there a straightforward way to inject these SNPs into hg19genome?
This seems relatively complicated given the structure of a BSGenome object.

The creator of the package answered this question previously on the Bioconductor support forums:
https://support.bioconductor.org/p/86665/#86757


  We don't provide an easy way to inject arbitrary SNPs in an arbitrary
  BSgenome at the moment. However, it should not be too hard to forge
  the BSgenome ... package. First you would need to
  compute the sequences of the mutated chromosomes (you can
  use replaceLetterAt for this), then write them to a 2bit file (put
  them in a DNAStringSet object and call rtracklayer::export on it),
  then use that 2bit file to forge the BSgenome ....
  package (see the BSgenomeForge vignette in the BSgenome package for
  how to do this).
  - Herve Pages


Here is another similar question with more info about replaceLetterAt: https://support.bioconductor.org/p/26199/