MyNixOS website logo
Description

Dot Plots Mimicking Violin Plots.

Modifies dot plots to have different sizes of dots mimicking violin plots and identifies modes or peaks for them based on frequency and kernel density estimates (Rosenblatt, 1956) <doi:10.1214/aoms/1177728190> (Parzen, 1962) <doi:10.1214/aoms/1177704472>.

dotsViolin. Dot Plots Mimicking Violin Plots


Buy Me a Coffee at ko-fi.com

Modifies dot plots to have different sizes of dots mimicking violin plots and identifies modes or peaks for them (Rosenblatt, 1956; Parzen, 1962).

dotsViolin, an R package (R Core Team, 2023) uses gridExtra (Auguie, 2017), gtools (Bolker et al., 2022), tidyr (Wickham et al., 2023c), stringr (Wickham, 2022), dplyr (Wickham et al., 2023b), ggplot2 (Wickham et al., 2023a), lazyeval (Wickham, 2019), magrittr (Bache and Wickham, 2022), rlang (Henry and Wickham, 2023), scales (Wickham and Seidel, 2022), tidyselect (Henry and Wickham, 2022)

Documentation was written with R-packages roxygen2 (Wickham et al., 2022), knitr (Xie, 2023), Rmarkdown (Allaire et al., 2023).

Academic presentation related (Roa-Ovalle, 2019)

Installation

devtools::install_gitlab(repo = "ferroao/dotsViolin")

Releases

News

Citation

To cite package ‘dotsViolin’ in publications use:

Roa-Ovalle F, Telles M (2023). dotsViolin: Integrated tables in dot and violin R ggplots. R package version 0.0.1, https://gitlab.com/ferroao/dotsViolin.

To write citation to file:

sink("dotsViolin.bib")
toBibtex(citation("dotsViolin"))
sink()

Authors

Fernando Roa
Mariana PC Telles

Plot window

Define your plotting window size with something like par(pin=c(10,6)), or with svg(), png(), etc.

In VSCode, you could use something like this

{
  "r.plot.useHttpgd": false,
  "r.plot.devArgs": {
    "width": 800,
    "height": 600
  }
}

Examples

1 Discrete Data:

library(dotsViolin)

fabaceae_mode_counts <- get_modes_counts(fabaceae_clade_n_df, "clade", "parsed_n")
fabaceae_mode_counts
cladem1m2m3count
Caesalpinieae12NANA29
Cassieae1481264
Cercidoideae147NA33
Detarioideae128,17NA50
Dialioideae14NANA6
Dimorphandra and rel.1413NA16
Mimosoids132614221
outgroup81211145
Papilionoideae81171410
Umtiza and rel.14NANA7
library(dotsViolin)

fabaceae_clade_n_df_count <- make_legend_with_stats(fabaceae_mode_counts, "label_count", 1, TRUE)
fabaceae_clade_n_df$label_count <- fabaceae_clade_n_df_count$label_count[match(
  fabaceae_clade_n_df$clade,
  fabaceae_clade_n_df_count$clade
)]
desiredorder1 <- unique(fabaceae_clade_n_df$clade)
fabaceae_clade_n_df
                        tip.label          clade parsed_n
1     KX374504_Abarema_centiflora      Mimosoids       13
2   KX213142_Adenodolichos_bussei Papilionoideae       11
3      KX792912_Almaleea_cambagei Papilionoideae        8
4 KP109982_Amphithalea_cymbifolia Papilionoideae        9
5 KP230727_Argyrolobium_tuberosum Papilionoideae       13
6        GU220019_Ateleia_arsenii Papilionoideae       14
                              label_count
1 Mimosoids             13   26 14  (221)
2 Papilionoideae         8   11  7 (1410)
3 Papilionoideae         8   11  7 (1410)
4 Papilionoideae         8   11  7 (1410)
5 Papilionoideae         8   11  7 (1410)
6 Papilionoideae         8   11  7 (1410)
par(mar = c(0, 0, 0, 0), omi = rep(0, 4))

dots_and_violin(
  fabaceae_clade_n_df, "clade", "label_count", "parsed_n", 2,
  30, "Chromosome haploid number", desiredorder1, 1, .85, 4,
  "ownwork",
  violin = FALSE
)
par(mar = c(0, 0, 0, 0), omi = rep(0, 4))

dots_and_violin(
  fabaceae_clade_n_df, "clade", "label_count", "parsed_n", 2,
  30, "Chromosome haploid number", desiredorder1, 1, .85, 4,
  dots = FALSE
)
par(mar = c(0, 0, 0, 0), omi = rep(0, 4))

dots_and_violin(
  fabaceae_clade_n_df, "clade", "label_count", "parsed_n", 2,
  30, "Chromosome haploid number", desiredorder1, 1, .85, 4
)

2 Continuous Data:

Define your plotting window size with something like par(pin=c(10,6)), or with svg(), png(), etc.

library(dotsViolin)

fabaceae_Cx_peak_counts_per_clade_df <- get_peaks_counts_continuous(
  fabaceae_clade_1Cx_df,
  "clade", "Cx", 2, 0.25, 1, 2
)
fabaceae_Cx_peak_counts_per_clade_df
cladem1m2counts
CaesalpinieaeCaesalpinieae0.85,1.802
CassieaeCassieae0.690.52,0.566
CercidoideaeCercidoideae0.605
COM cladeCOM clade0.35,0.50,0.833
DetarioideaeDetarioideae2.210.84,2.014
Dimorphandra & rel.Dimorphandra & rel.0.73,0.792
MalvidsMalvids0.400.638
MimosoidsMimosoids0.700.4342
outgroupsoutgroups0.481.38,2.769
PapilionoideaePapilionoideae0.59212
Polygala amaraPolygala amara0.421
Umtiza & rel.Umtiza & rel.0.65,1.052
Vitis viniferaVitis vinifera0.431
library(dotsViolin)

namecol <- "labelcountcustom"
fabaceae_clade_1Cx_modes_count_df <- make_legend_with_stats(
  fabaceae_Cx_peak_counts_per_clade_df,
  namecol, 1, TRUE
)
fabaceae_clade_1Cx_df$labelcountcustom <-
  fabaceae_clade_1Cx_modes_count_df$labelcountcustom[match(
    fabaceae_clade_1Cx_df$clade,
    fabaceae_clade_1Cx_modes_count_df$clade
  )]
desiredorder <- unique(fabaceae_clade_1Cx_df$clade)
fabaceae_clade_1Cx_df
                              name     clade     Cx      genus ownwork
6      'Silene_latifolia_JF715055' outgroups 2.7000     Silene      no
7  'Fagopyrum_esculentum_NC010776' outgroups 1.4350  Fagopyrum      no
11    'Helianthus_annuus_NC007977' outgroups 2.4250 Helianthus      no
12        'Daucus_carota_NC008325' outgroups 2.8375     Daucus      no
14        'Olea_europaea_NC013707' outgroups 1.9500       Olea      no
18       'Coffea_arabica_NC008535' outgroups 0.6000     Coffea      no
                                      labelcountcustom
6  outgroups                     0.48 1.38,2.76    (9)
7  outgroups                     0.48 1.38,2.76    (9)
11 outgroups                     0.48 1.38,2.76    (9)
12 outgroups                     0.48 1.38,2.76    (9)
14 outgroups                     0.48 1.38,2.76    (9)
18 outgroups                     0.48 1.38,2.76    (9)
par(mar = c(0, 0, 0, 0), omi = rep(0, 4))

dots_and_violin(
  fabaceae_clade_1Cx_df, "clade", "labelcountcustom", "Cx", 3,
  3, "Genome Size", desiredorder, 0.03, 0.25, 2,
  "ownwork"
)
par(mar = c(0, 0, 0, 0), omi = rep(0, 4))

dots_and_violin(
  fabaceae_clade_1Cx_df, "clade", "labelcountcustom", "Cx", 3,
  3, "Genome Size", desiredorder, 0.03, 0.25, 2,
  dots = FALSE
)
par(mar = c(0, 0, 0, 0), omi = rep(0, 4))

dots_and_violin(
  fabaceae_clade_1Cx_df, "clade", "labelcountcustom", "Cx", 3,
  3, "Genome Size", desiredorder, 0.03, 0.25, 2,
  "ownwork",
  violin = FALSE
)

References

R-packages

Allaire J, Xie Y, Dervieux C, McPherson J, Luraschi J, Ushey K, Atkins A, Wickham H, Cheng J, Chang W, Iannone R. 2023. Rmarkdown: Dynamic documents for r. R package version 2.24. https://CRAN.R-project.org/package=rmarkdown

Auguie B. 2017. gridExtra: Miscellaneous functions for "grid" graphics. R package version 2.3. https://CRAN.R-project.org/package=gridExtra

Bache SM, Wickham H. 2022. Magrittr: A forward-pipe operator for r. R package version 2.0.3. https://CRAN.R-project.org/package=magrittr

Bolker B, Warnes GR, Lumley T. 2022. Gtools: Various r programming tools. R package version 3.9.4. https://github.com/r-gregmisc/gtools

Henry L, Wickham H. 2022. Tidyselect: Select from a set of strings. R package version 1.2.0. https://CRAN.R-project.org/package=tidyselect

Henry L, Wickham H. 2023. Rlang: Functions for base types and core r and tidyverse features. R package version 1.1.1. https://CRAN.R-project.org/package=rlang

R Core Team. 2023. R: A language and environment for statistical computing R Foundation for Statistical Computing, Vienna, Austria. https://www.R-project.org/

Wickham H. 2019. Lazyeval: Lazy (non-standard) evaluation. R package version 0.2.2. https://CRAN.R-project.org/package=lazyeval

Wickham H. 2022. Stringr: Simple, consistent wrappers for common string operations. R package version 1.5.0. https://CRAN.R-project.org/package=stringr

Wickham H, Chang W, Henry L, Pedersen TL, Takahashi K, Wilke C, Woo K, Yutani H, Dunnington D. 2023a. ggplot2: Create elegant data visualisations using the grammar of graphics. R package version 3.4.4. https://CRAN.R-project.org/package=ggplot2

Wickham H, Danenberg P, Csárdi G, Eugster M. 2022. roxygen2: In-line documentation for r. R package version 7.2.3. https://CRAN.R-project.org/package=roxygen2

Wickham H, François R, Henry L, Müller K, Vaughan D. 2023b. Dplyr: A grammar of data manipulation. R package version 1.1.3. https://CRAN.R-project.org/package=dplyr

Wickham H, Seidel D. 2022. Scales: Scale functions for visualization. R package version 1.2.1. https://CRAN.R-project.org/package=scales

Wickham H, Vaughan D, Girlich M. 2023c. Tidyr: Tidy messy data. R package version 1.3.0. https://CRAN.R-project.org/package=tidyr

Xie Y. 2023. Knitr: A general-purpose package for dynamic report generation in r. R package version 1.43. https://yihui.org/knitr/

Academia

Parzen E. 1962. On estimation of a probability density function and mode The Annals of Mathematical Statistics, 33: 1065–1076. https://doi.org/10.1214/aoms/1177704472

Roa-Ovalle F. 2019. Poliploidia e duplicação genômica nas leguminosas brasileiras In: Rocha LL da (ed) Sociedade Botânica do Brasil. https://70cnbot.botanica.org.br/wp-content/uploads/2019/11/Livro-70%C2%BA-Congresso-Nacional-de-Bot%C3%A2nica..pdf

Rosenblatt M. 1956. Remarks on some nonparametric estimates of a density function The Annals of Mathematical Statistics, 27: 832–837. https://doi.org/10.1214/aoms/1177728190

Metadata

Version

0.0.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows