I'm trying to annotate some data from a Bisulphite experiment, from which I have a GRanges object without any annotation:
GRanges object with 872900 ranges and 0 metadata columns:
seqnames ranges strand
<Rle> <IRanges> <Rle>
[1] chr10 48196 *
[2] chr10 48486 *
[3] chr10 49247 *
[4] chr10 49258 *
[5] chr10 49595 *
... ... ... ...
[872896] chrY 26439351 *
[872897] chrY 56866730 *
[872898] chrY 56871726 *
[872899] chrY 56879863 *
[872900] chrY 56885734 *
-------
seqinfo: 24 sequences from an unspecified genome; no seqlengths
I'm pulling annotation data from TxDb.Hsapiens.UCSC.hg19.knownGene to annotate each position with promoters and genes.
Before using nearest
, findOverlaps
, ... I thought to collect the information in a single object with sensible names for the other researchers.
But when I combine the resulting object there is an error that prevents me checking the output:
suppressPackageStartupMessages(library("TxDb.Hsapiens.UCSC.hg19.knownGene"))
genes <- genes(TxDb.Hsapiens.UCSC.hg19.knownGene, column = "gene_id",
single.strand.genes.only=FALSE)
genes <- sort(genes)
promoters <- promoters(TxDb.Hsapiens.UCSC.hg19.knownGene, column = "gene_id")
promoters <- sort(promoters)
gp <- c(genes, promoters)
gp
#> GRangesList object of length 106419:
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'object' in selecting a method for function 'show': error in evaluating the argument 'x' in selecting a method for function 'as.list': subscript is a NSBS object that is incompatible with the current
#> subsetting operation
Created on 2023-01-03 with reprex v2.0.2
PS: I would appreciate any suggestion that helped me annotate and existing GRanges with annotation data.
I am probably missing something as I haven't found HOWTOs or vignettes documenting how to do this.