bernatgel / karyoploteR

karyoploteR - An R/Bioconductor package to plot arbitrary data along the genome
https://bernatgel.github.io/karyoploter_tutorial/
299 stars 41 forks source link

Invalid seqlevels in kpPlotCoverage when a chromosome has no coverage #82

Open chaomacau opened 4 years ago

chaomacau commented 4 years ago

Hi,

I am using kpPlotCoverage, and in one of the chromosome in my data, there is no coverage at all but I still want a plot of the karyoplot for having a figure of the whole genome. Using kpPlotCoverage, this case causes an error with "invalid seqlevels" which comes from GenomeInfoDb::keepSeqlevels. Is there a way to get around this error?

bernatgel commented 4 years ago

Hi @chaomacau

I cannot reproduce the problem with a current version of karyoploteR. We had this issue in the past but was solved a few months ago.

Could you please give the output of sessionInfo()?

Also, could you give me a small example producing this error and the error message it generates?

Thanks

Bernat

chaomacau commented 4 years ago

Hi @bernatgel

Thank you for the prompt response. Below are my version information and a small example to reproduce the error.

Versions: [1] TxDb.Hsapiens.UCSC.hg38.knownGene_3.10.0 GenomicFeatures_1.38.2 AnnotationDbi_1.48.0
[4] Biobase_2.46.0 karyoploteR_1.12.4 regioneR_1.18.1
[7] GenomicRanges_1.38.0 GenomeInfoDb_1.22.1 IRanges_2.20.2
[10] S4Vectors_0.24.4 BiocGenerics_0.32.0 GenomeInfoDbData_1.2.2

Example to reproduce error: library(karyoploteR) library(GenomicRanges) library(TxDb.Hsapiens.UCSC.hg38.knownGene) chr<-c("chr5", "chr5", "chr6") start<-c(88800000, 12800000, 89600000) end<-c(115200000, 25600000, 102400000)

testdata<-data.frame(chr, start, end) grangedata<-GRanges(seqnames = testdata$chr, ranges=IRanges(start=testdata$start, end =testdata$end)) pp <- getDefaultPlotParams(plot.type = 1)

This is a control and has no error

kp <- plotKaryotype(genome="hg38", plot.type=1, chromosomes=c("chr5", "chr6"), plot.params=pp) kpl<-kpPlotCoverage(kp, grangedata, r0=0, r1=1, col="red")

If we are including chr7 which does not have any coverage in the data, an error occurs.

kp <- plotKaryotype(genome="hg38", plot.type=1, chromosomes=c("chr5", "chr6", "chr7"), plot.params=pp) kpl<-kpPlotCoverage(kp, grangedata, r0=0, r1=1, col="red") #Error "invalid seqlevels: chr7"

Thank you very much! Joyce

bernatgel commented 4 years ago

Hi Joyce,

Now I can reproduce. It seems the problem arises from an interaction between selecting a handful of chromosomes and having some of them empty. I'll take a look and get back to you as soon as it's fixed.

chaomacau commented 4 years ago

@bernatgel Thank you!