Shifted dashed frame in Gviz boxplot
2
0
Entering edit mode
enricoferrero ▴ 660
@enricoferrero-6037
Last seen 3.0 years ago
Switzerland

In Gviz, when using plotTracks() to plot a DataTrack with type="boxplot", a dashed line is plotted around the first two boxplots:

 

Is it possible to turn that off? How?

Thanks,

gviz boxplot • 2.3k views
ADD COMMENT
0
Entering edit mode

Actually, I'm realising the real problem here is that the boxplots are shifted to the right, which is why the third boxplot is outside of the dashed box... Any idea what might be causing that?

ADD REPLY
2
Entering edit mode
@florianhahnenovartiscom-3784
Last seen 6.2 years ago
Switzerland

Hi Enrico,

just got around fixing this. Should become available shortly with Gviz 1.16.1. and 1.17.1

Thanks for reporting,

Florian

ADD COMMENT
0
Entering edit mode

Awesome, thanks Florian. I will test it as soon as I have a chance.

(I resorted to the histogram in the meantime.)

ADD REPLY
0
Entering edit mode

Is it possible to hide this dashed frame completely?

ADD REPLY
0
Entering edit mode

It is possible since version 1.31.6. You can set the the col.boxplotFrame="transparent" to hide it.

ADD REPLY
1
Entering edit mode
@florianhahnenovartiscom-3784
Last seen 6.2 years ago
Switzerland

Can you give a reproducible example with code and data. This looks like a bug to me, but hard to do anything about it without an example.

ADD COMMENT
0
Entering edit mode

Thanks Florian - I'm working on a minimal reproducible example and will get back to you.

ADD REPLY
0
Entering edit mode

Here we go:

library(Gviz)

# generate random data
set.seed(16)
seqnames <- paste0(sample(1:22, 100, replace=TRUE))
start <- sample(1000:10000, 100)
end <- start + sample(100:1000, 100)
values <- matrix(rexp(1700), 100)
colnames(values) <- paste(sample(c("Low", "Medium", "High"), 17, replace=TRUE), 1:17, sep=".")

# create GRanges
dataset <- cbind.data.frame(seqnames, start, end, values)
dataset <- GRanges(dataset)

# define some variables for plotting
gen <- "hg38"
chr <- "16"
from <- 5000
to <- 10000
groups <- factor(sub("(Low|Medium|High)\\.[0-9]+", "\\1", names(mcols(dataset))), levels=c("Low", "Medium", "High"))

# create DataTrack
dataset <- dataset[seqnames(dataset)==chr & start(dataset) >= from & end(dataset) <= to]
datatrack <- DataTrack(dataset, name="dataset", genome=gen, chromosome=chr, start=from, end=to, groups=groups, type="boxplot", legend=TRUE)

png("mwe.png", res=150, width=10*150, height=12*150)
plotTracks(datatrack, chromosome=chr, from=from, to=to, background.title="grey70")
dev.off()

 

You can see that in all cases the boxplots appear shifted to the right with some blank space on the left and the rightmost boxplot on the dashed boundary or beyond.

How can I fix this? I'm guessing this is due to how my GRanges object is built and/or the way groups in my DataTrack are defined?

Thank you.

ADD REPLY
0
Entering edit mode

OK, I've got a better, real-world example:

library(TxDb.Hsapiens.UCSC.hg38.knownGene)
library(Gviz)
set.seed(16)

# create GRanges with one range corresponding to a gene
gen <- "hg38"
chr <- "chr12"
start <- 121429097
end <- 121581015
values <- matrix(rexp(17), 1)
colnames(values) <- paste(sample(c("Low", "Medium", "High"), 17, replace=TRUE), 1:17, sep=".")
dataset <- cbind.data.frame(chr, start, end, values)
dataset <- GRanges(dataset)

# define groups
groups <- factor(sub("(Low|Medium|High)\\.[0-9]+", "\\1", names(mcols(dataset))), levels=c("Low", "Medium", "High"))

# create tracks
grtrack <- GeneRegionTrack(TxDb.Hsapiens.UCSC.hg38.knownGene, genome=gen, chromosome=chr, start=start, end=end, collapseTranscripts="meta")
dtrack <- DataTrack(dataset, name="dataset", genome=gen, chromosome=chr, start=start, end=end, groups=groups, type="boxplot", legend=TRUE)

# plot
png("mwe.png", res=150, width=10*150, height=12*150)
plotTracks(list(grtrack, dtrack), chromosome=chr, from=start-25000, to=end+25000)
dev.off()

From what I can see, the dashed frame is correctly aligned to the gene, but the boxplots are clearly shifted to the right for some reason.

Interestingly, I also get this warning message when calling plotTracks():

Warning message:
In min(diff(unique(sort(x)))) :
  no non-missing arguments to min; returning Inf

Any idea on how to fix this?

Thanks!

 

ADD REPLY
0
Entering edit mode

Hi Florian,

Did you have a chance to look at this?

Thank you,

Enrico

ADD REPLY

Login before adding your answer.

Traffic: 681 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6