Comments (4)
This is corrected in vioplot 0.3.6 on CRAN.
from vioplot.
Thanks for reporting. I've done some quick testing and it seems to be thresholded at >100
. Unclear why this is.
> library("vioplot")
Loading required package: sm
Package 'sm', version 2.2-5.6: type help(sm) for summary information
Loading required package: zoo
Attaching package: ‘zoo’
The following objects are masked from ‘package:base’:
as.Date, as.Date.numeric
> vioplot(x = c(0))
> vioplot(x = c(rep.int(0, 100)))
> vioplot(x = c(rep.int(0, 500)))
Error in cut.default(x, breaks = breaks) : 'breaks' are not unique
> vioplot(x = c(rep.int(0, 250)))
Error in cut.default(x, breaks = breaks) : 'breaks' are not unique
> vioplot(x = c(rep.int(0, 150)))
Error in cut.default(x, breaks = breaks) : 'breaks' are not unique
> vioplot(x = c(rep.int(0, 100)))
> vioplot(x = c(rep.int(0, 125)))
Error in cut.default(x, breaks = breaks) : 'breaks' are not unique
> vioplot(x = c(rep.int(0, 110)))
Error in cut.default(x, breaks = breaks) : 'breaks' are not unique
> vioplot(x = c(rep.int(0, 101)))
Error in cut.default(x, breaks = breaks) : 'breaks' are not unique
> vioplot(x = c(rep.int(0, 100)))
Is there a particular reason you wish to do this? I can't imagine a use case where plotting all of the same value as a violin would be informative. If you plot multiple groups this does not occur.
> vioplot(x = c(rep.int(0, 100), 1))
> vioplot(x = c(rep.int(0, 100)), y = c(rep.int(0, 100)))
> vioplot(x = c(rep.int(0, 101)), y = c(rep.int(0, 101)))
Error in cut.default(x, breaks = breaks) : 'breaks' are not unique
> vioplot(x = c(rep.int(0, 100)), y = c(rep.int(0, 100), 1))
> vioplot(x = c(rep.int(0, 101)), y = c(rep.int(0, 101)))
Error in cut.default(x, breaks = breaks) : 'breaks' are not unique```
If I can identify the issue we could replace the error by a point making the average (well mean, median, and mode would be the same in this case).
from vioplot.
This appears to be an issue with a dependency but we could test for the exception in the package.
> options(error = function() {
+ calls <- sys.calls()
+ if (length(calls) >= 2L) {
+ sink(stderr())
+ on.exit(sink(NULL))
+ cat("Backtrace:\n")
+ calls <- rev(calls[-length(calls)])
+ for (i in seq_along(calls)) {
+ cat(i, ": ", deparse(calls[[i]], nlines = 1L), "\n", sep = "")
+ }
+ }
+ if (!interactive()) {
+ q(status = 1)
+ }
+ })
> vioplot(x = c(rep.int(0, 101)), y = c(rep.int(0, 101)))
Error in cut.default(x, breaks = breaks) : 'breaks' are not unique
Backtrace:
1: stop("'breaks' are not unique")
2: cut.default(x, breaks = breaks)
3: cut(x, breaks = breaks)
4: binning.1d(x, y, breaks = breaks, nbins = nbins)
5: binning(x, y, nbins = opt$nbins)
6: h.select(x = x, y = NA, weights = weights, ...)
7: sm.density(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8: do.call("sm.density", c(list(data, xlim = est.xlim), args))
9: vioplot.default(x = c(rep.int(0, 101)), y = c(rep.int(0, 101)))
10: vioplot(x = c(rep.int(0, 101)), y = c(rep.int(0, 101)))```
from vioplot.
So this is how I stumbled upon the bug:
I was plotting some RNA-seq read counts for case vs. control for certain genes. I also wanted to add gaps in between each gene (so two violins, gap, two violins, gap, ... two violins). For this, I create the plot as an empty canvas and in every iteration I add two violins and one gap, therefore the violins are plotted one by one and for genes that have value of 0 expression for one group, the vioplot throws the error.
The way I bypassed the error in my code was to add e^-10 to the first lowest number, but of course you cannot do that and instead you can check if there are more than 100 items in the vector, you just trim it to 100 and then plot it.
from vioplot.
Related Issues (18)
- `las` and `ylab` does not work HOT 4
- Surprising behavior when passing xlim=c(1,2) HOT 12
- xaxt option is ignored
- Titles axes and position of legend in violin plots HOT 2
- h parameter documented as "height" rather than "density smoothing" HOT 2
- Feature Request: histogram instead of density kernel HOT 2
- yaxt = 'n' should only suppress plotting of the y-axis; currently, it suppresses both HOT 3
- Add examples of overlaying base R graphics to docs
- Recommendations HOT 2
- Error when using levels with spaces HOT 2
- Vioplot not working when formula categories are numbers HOT 2
- Spurious print(ylim) in vioplot HOT 1
- cex passed as argument is ignored HOT 2
- cex.names is not used HOT 1
- col is not reused when a vector is passed
- Option to change the color of the center line HOT 7
- Global state being set by the arguments: xlog=TRUE, horizontal=TRUE HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vioplot.