This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to annotate one GenomicRanges object using another?

I have two genomicranges, one containing the gencode GFF v24

library(GenomicFeatures)

gen = makeTxDbFromGFF("gencode.gff")

tss = promoters(gen, upstream = 5000, downstream = 5000)

# > tss
# GRanges object with 199169 ranges and 2 metadata columns:
# seqnames     ranges strand  |   tx_id      tx_name
# <Rle>   <IRanges> <Rle>  | <integer>    <character>
# [1]   chr1 [ 6869, 16868]  +  |     1 ENST00000456328.2
# [2]   chr1 [ 7010, 17009]   +  |     2 ENST00000450305.2
# ...
# [199169]   chrM [11024, 21023]   -  |  199169 ENST00000387461.2
# -------
# seqinfo: 25 sequences (1 circular) from an unspecified genome; no seqlengths

another containing the regions I want annotated:

> mydata
GRanges object with 322394 ranges and 0 metadata columns:
           seqnames                 ranges strand
              <Rle>              <IRanges>  <Rle>
       [1]    chr10 [100005001, 100005200]      *
       [2]    chr10 [100005201, 100005400]      *

  [322394]     chrY   [56881001, 56881200]      *
  -------
  seqinfo: 25 sequences from an unspecified genome; no seqlengths

How do I transfer the gene names (tx_name) from my annotation to the data I want annotated?

genomicfeatures r

1 answer

Hi,

I think you can coerce the "tss" and "mydata" object into a data.frame and later and using a column which is common between the "tss" and "mydata", you can create a new data frame which you can later convert into genomic Ranges.

There is no mapping between the two genomicRanges.

Log in to answer this question.