saketkc / gencode_regions

Extract 3'UTR, 5'UTR, CDS, Promoter, Genes, Introns, Exons from GTF files
BSD 2-Clause "Simplified" License
101 stars 53 forks source link

In your R script (create_regions_from_gencode.R) there is a small bug #3

Open Alex-Nesta opened 5 years ago

Alex-Nesta commented 5 years ago
transcripts.data <- unlist(transcripts.data) ###ERROR
exons.data <- unlist(exons.data)
threeUTRs.data <- unlist(threeUTRs.data)
fiveUTRs.data <- unlist(fiveUTRs.data)
cds.data <- unlist(cds.data)
introns.data <- unlist(introns.data)
genes.data <- unlist(genes.data) ####ERROR

There error is:

Error in getListElement(x, i, ...) : 
  GRanges objects don't support [[, as.list(), lapply(), or unlist() at
  the moment
Calls: unlist ... FUN -> [[ -> [[ -> getListElement -> getListElement
Execution halted

I did not need those lines to work for my purposes, but just an FYI on the issue.

BioLaoXu commented 5 years ago

I have the same problem,Bioconductor 3.8 may not support the this,but I didn't solve it

saketkc commented 5 years ago

Thanks @Alex-Nesta and @xf78 for reporting the issue. I will try to have a fix soonish. In the meantime, can you check if the data you need is here: https://github.com/saketkc/gencode_regions/tree/master/data Happy to add if it's missing (which is very likely!)

bug1303 commented 5 years ago

I had the same issue, using GenomicFeatures v 1.34.3 (not sure which other packages/versions might be relevant for this). It appears that genes(), transcripts(), and promoters() return a GRanges object ["The only exception being when genes is used with single.strand.genes.only=FALSE, in which case a GRangesList object is returned."], while threeUTRsByTranscript(), fiveUTRsByTranscript(), cdsBy(), exonsBy(), intronsByTranscript() return a GRangesList object, so for the latter ones the unlist is required, but not for the former ones.

By simply removing the lines as mentioned above transcripts.data <- unlist(transcripts.data) and genes.data <- unlist(genes.data)

as well as replacing promoters.data <- unlist(promoters(TxDb, upstream=len, downstream=len)) with promoters.data <- promoters(TxDb, upstream=len, downstream=len)

I managed to recreate the files as provided in data/GRCm38/vM14/

longqh3 commented 3 years ago

I also encountered this issue currently, using conda hosted R-3.3.2 to install dependencies solved the issue. However, while conducting problem searching, I noticed that

The overall goal of all these changes is to bring more consitency between IRanges and GRanges objects
 (GRanges objects will also support [[, unlist(), as.list(), and lapply() in Bioconductor 3.8).

in unlist doesn't work for IRanges, so maybe downgrading to Bioconductor 3.8 version can also solve the issue (I'm not pretty sure, haven't tried yet).

DodotheMath commented 1 month ago

Running into this same issue now