Recent developments in data science, in particular computational biology, often integrate data from several sources, over diverse experiments, or databases leaves a challenge of truthfully visualize data where the number of data points vary between classes. Plot types like bar charts, violin plot, strip charts or box-and-whiskers plots can provide visual information about mean/median, variance of the data, number of data points or density distribution of data; but only pairs of plots or dense overlays of these plot types will provide all the relevant information. To aid the presentation of datasets with differing sample size we have developed a new type of plot overcoming limitations of current standards visualization charts.
sinaplot is inspired by the strip chart and the violin plot. By letting the normalized density of points restrict the jitter along the x-axis the plot displays the same contour as a violin plot, but resemble a simple strip chart for small number of data points. In this way the plot conveys information of both the number of data points, the density distribution, outliers and spread in a very simple, comprehensible and condensed format.
x <- c(rnorm(200, 4, 1), rnorm(200, 5, 2), rnorm(200, 6, 1.5))
groups <- c(rep("Cond1", 200), rep("Cond2", 200), rep("Cond3", 200))
library(sinaplot)
## Loading required package: ggplot2
sinaplot(x, groups)
We use a cohort of 2095 AML, ALL and healthy bone marrow samples to illustrate some of the strengths of sinaplot.
type | value |
---|---|
ALL t(12;21) | 7.553129 |
ALL t(12;21) | 7.252447 |
ALL t(12;21) | 5.608201 |
ALL t(12;21) | 5.971710 |
ALL t(12;21) | 6.554109 |
ALL t(12;21) | 5.655416 |
ALL t(12;21) | 6.127554 |
ALL t(12;21) | 6.043007 |
ALL t(12;21) | 7.681021 |
ALL t(12;21) | 5.959204 |
sinaplot(blood$value, blood$type)
Using the method = "neighbourhood"
to compute the borders we get a less smooth spread of the samples due to the absence of the kernel density estimate.
sinaplot(blood$value, blood$type, method = "neighbourhood")
Setting the argument groupwiseScale = FALSE we
turn off the relative scaling of all the sample types based on the one with the highest density.
sinaplot(blood$value, blood$type, method = "neighbourhood",
groupwiseScale = FALSE)
Using a subset of the blood
dataset we compare sinaplot with 5 popular plotting strategies, and show how our package integrates features from these methods to achieve truthful and yet simple representation of multiclass single variable data.
sessionInfo()
## R version 3.3.0 (2016-05-03)
## Platform: x86_64-apple-darwin13.4.0 (64-bit)
## Running under: OS X 10.11.4 (El Capitan)
##
## locale:
## [1] C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] sinaplot_0.1.5 ggplot2_2.1.0
##
## loaded via a namespace (and not attached):
## [1] Rcpp_0.12.5 digest_0.6.9 plyr_1.8.3 grid_3.3.0
## [5] gtable_0.2.0 formatR_1.4 magrittr_1.5 evaluate_0.9
## [9] scales_0.4.0 highr_0.6 stringi_1.0-1 rmarkdown_0.9.6
## [13] labeling_0.3 tools_3.3.0 stringr_1.0.0 munsell_0.4.3
## [17] yaml_2.1.13 colorspace_1.2-6 htmltools_0.3.5 knitr_1.13