I'm trying to use rtracklayer's import function to import a GTF file. I downloaded the current comprehensive genome annotation for human from GENCODE, gunzipped the .gz file and tried the following:
library(rtracklayer)
granges <-import("gencode.v36.annotation.gtf")
I am getting the following error:
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'con' in selecting a method for function 'import': invalid class “GFF2File” object: undefined class for slot "resource" ("characterORconnection")
Also, adding the parameter format="gtf"
does not make a difference.
When searching for this on the web, I'm only getting results regarding a tool called IsoformSwitchAnalyzeR where the authors recommended updating their software. But I'm neither using their tool, nor is it even installed on my PC.
For now, I am importing the GTF files manually, but I would like to use rtracklayer's import function. I hope, someone can help.
What happens with
rtracklayer::import("gencode.v36.annotation.gtf")
?I'm getting exactly the same error as before.
What version of rtracklayer are you using?
sessionInfo()
.Also, annotation files such as GTFs are generally stored as TxDb objects in R, so depending on your downstream analysis you could use
GenomicFeatures::makeTxDbFromGFF
.It says
rtracklayer_1.48.0
Thanks for your suggestion. As I said, I am able to load these files manually, so I'm not really in need of another workaround, I'd just like rtracklayer to be working.
Having the same problem, have you managed to use "import"?
Adding this here in case it helps somebody - in my case the GTF itself was not formatted correctly. The problem disappeared when fixed the format.
Please do not add answers unless you're answering the top-level question. Use
Add Comment
orAdd Reply
instead. Your post has been moved to a comment this time.getting the same issue, did you ever solve the problem?
Format issue, you can try AGAT to sanitaze your file. I guess
agat_convert_sp_gff2gtf.pl
will do the job even if you provide a GTF as input. Be stringent to keep only official features e.g. GTF v2.5:--gtf_version 2.5
I used read.table and read.lines to see what was wrong with the file.
It this file downloaded from somewhere or was it manipulated before trying to read it? You can try downloading from GENCODE (any of their GTFs) and see whether this works. If not then it is some software-based thing, else it is something with your file.
I haven't tried since then. I'll try again in a few days, when I'll be analyzing my next RNA-seq data.