Entering edit mode
3.3 years ago
brtawe
•
0
I am trying to find overlap between my own set of genomic coordinates and genes, as shown below. I am able to get get the subset of genes that overlap using subsetByOverlaps, however, how do I map the genes back to the coordinates that I used to subset? I want to know which of my input coordinates overlapped with each gene(s)
I included a metadata column in my coordinates containing an ID, but that ID is missing from the subset output
mycoords.gr = as.data.frame(input) %>%
makeGRangesFromDataFrame(keep.extra.columns=TRUE) #make GRanges form Bed file
genes <- genes(TxDb.Hsapiens.UCSC.hg38.knownGene) #extract GRanges for genes
gene_list <- subsetByOverlaps(genes, mycoords.gr) #subset genes that overlap with my coordinates
gene_result = as(gene_list, "data.frame") #convert GRanges object to data frame
Thanks for any help!
That works great, thanks for the help!