Giter VIP home page Giter VIP logo

Comments (4)

TomKellyGenetics avatar TomKellyGenetics commented on August 28, 2024 1

This is corrected in vioplot 0.3.6 on CRAN.

from vioplot.

TomKellyGenetics avatar TomKellyGenetics commented on August 28, 2024

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.

TomKellyGenetics avatar TomKellyGenetics commented on August 28, 2024

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.

mmahmoudian avatar mmahmoudian commented on August 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.