Add nucleic acid sequence of regions to metadata column

add_sequence(ranges, genome, name = "sequence")

Arguments

ranges

GRanges object

genome

BSgenome object or any other valid input to `Biostrings::getSeq()` (Do `showMethods(Biostrings::getSeq)` to show valid types)

name

name of metadata column to hold sequence information (default: "sequence"). Note, this will overwrite existing columns without warning if the name already exists.

Value

`ranges` with new metadata column named "sequence" (or another value passed to `name`) holding the DNA or RNA sequence from `genome`

Examples

data(example_peaks, package = "memes")
dm.genome <- BSgenome.Dmelanogaster.UCSC.dm3::BSgenome.Dmelanogaster.UCSC.dm3
add_sequence(example_peaks, dm.genome)
#> GRanges object with 10 ranges and 1 metadata column:
#>        seqnames            ranges strand |               sequence
#>           <Rle>         <IRanges>  <Rle> |            <character>
#>    [1]    chr3L 14551117-14551323      * | AACTAAAATAGCAAATAAAA..
#>    [2]    chr3L 14625651-14625851      * | GCGCAGGCTGAAAAGAATCG..
#>    [3]    chr3L 14634333-14634597      * | TACCCACGCATCTTCAAAAT..
#>    [4]    chr3L 14636768-14637044      * | AACTTCCAAGACGTAAGACA..
#>    [5]    chr3L 14638220-14638449      * | AGCGCTAATAATTAGAAGAC..
#>    [6]    chr3L 14743289-14743632      * | AAAGTTCCATCACCGAAAAG..
#>    [7]    chr3L 14755114-14755492      * | ATAACGATTGCTTGGCAGCA..
#>    [8]    chr3L 14759085-14759603      * | GTTTTTCCATAGATGCGAGT..
#>    [9]    chr3L 14978519-14978765      * | TATTAACGAAAATTGCATAT..
#>   [10]    chr3L 15104231-15105654      * | GTGGCCCAGACACCCGTTCA..
#>   -------
#>   seqinfo: 1 sequence from an unspecified genome; no seqlengths