### Methods Source: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.R This code chunk is commented out and appears to be a setup for demonstrating different methods of geom_quasirandom and geom_beeswarm. ```R library(gridExtra) dat <- list( 'Normal'=rnorm(50), 'Dense normal'= rnorm(500), 'Bimodal'=c(rnorm(100), rnorm(100,5)), 'Trimodal'=c(rnorm(100), rnorm(100,5),rnorm(100,-3)) ) labs<-rep(names(dat),sapply(dat,length)) labs<-factor(labs,levels=unique(labs)) dat<-unlist(dat) p1<-ggplot(mapping=aes(labs, dat)) + geom_quasirandom(alpha=.2) + ggtitle('quasirandom') + labs(x='') + theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) p2<-ggplot(mapping=aes(labs, dat)) + geom_quasirandom(method='pseudorandom',alpha=.2) + ggtitle('pseudorandom') + labs(x='') + theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) p3<-ggplot(mapping=aes(labs, dat)) + geom_quasirandom(method='smiley',alpha=.2) + ggtitle('smiley') + labs(x='') + theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) p4<-ggplot(mapping=aes(labs, dat)) + geom_quasirandom(method='frowney',alpha=.2) + ggtitle('frowney') + labs(x='') + theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) p5<-ggplot(mapping=aes(labs, dat)) + geom_quasirandom(method='tukey',alpha=.2) + ggtitle('tukey') + labs(x='') + theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) p6<-ggplot(mapping=aes(labs, dat)) + geom_beeswarm(alpha=.2,size=.75) + ggtitle('geom_beeswarm') + labs(x='') + theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) grid.arrange(p1, p2, p3, p4, p5, p6, ncol=3) ``` -------------------------------- ### facetQuasi Source: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.R Example of using facet_grid with geom_quasirandom. ```R df<-data.frame(labs,dat,labs2) ggplot(df,aes(labs,dat,color=labs2)) + geom_quasirandom() + facet_grid(.~labs2) ``` -------------------------------- ### dodge Source: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.R Example demonstrating dodge.width for geom_quasirandom with color mapping. ```R labs2<-factor(rep(1:2,each=n)) ggplot(mapping=aes(labs,dat,color=labs2)) + geom_quasirandom(dodge.width=.8) ``` -------------------------------- ### dodgey Source: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.R Example demonstrating dodge.width for geom_quasirandom with y-axis as quantitative. ```R labs2<-factor(rep(1:2,each=n)) ggplot(mapping=aes(dat,labs,color=labs2)) + geom_quasirandom(dodge.width=.8) ``` -------------------------------- ### Dist Adjust Source: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.R This code chunk is commented out and appears to be a setup for demonstrating how distribution adjustment parameters like 'bandwidth', 'width', and 'nbins' affect the plot. ```R library(gridExtra) p1<-ggplot(mapping=aes(labs, dat)) + geom_quasirandom(bandwidth=2,alpha=.2) + ggtitle('bandwidth=2') + labs(x='') p2<-ggplot(mapping=aes(labs, dat)) + geom_quasirandom(bandwidth=.1,alpha=.2) + ggtitle('bandwidth=.1') + labs(x='') p3<-ggplot(mapping=aes(labs, dat)) + geom_quasirandom(width=.1,alpha=.2) + ggtitle('width=.1') + labs(x='') p4<-ggplot(mapping=aes(labs, dat)) + geom_quasirandom(nbins=100,alpha=.2) + ggtitle('nbins=100') + labs(x='') grid.arrange(p1, p2, p3, p4, ncol=1) ``` -------------------------------- ### varwidth Source: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.R Demonstrates the 'varwidth' parameter in geom_quasirandom, where the width of the swarm is adjusted based on the number of points in each category. This example uses datasets with varying numbers of points. ```R dat <- list( '10 points'=rnorm(10), '50 points'=rnorm(50,2), '200 points'=c(rnorm(400), rnorm(100,5)), '5000 points'= rnorm(5000,1) ) labs<-rep(names(dat),sapply(dat,length)) labs<-factor(labs,levels=unique(labs)) dat<-unlist(dat) ggplot(mapping=aes(labs, dat)) + geom_quasirandom(alpha=.3,varwidth=TRUE) ``` -------------------------------- ### package Source: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.R Loads the ggbeeswarm package and retrieves package information. ```R options(keep.source = TRUE, width = 60) packageInfo <- packageDescription("ggbeeswarm") library(ggbeeswarm) packageKeywords<-"visualization, display, one dimensional, grouped, groups, violin, scatter, points, quasirandom, beeswarm, van der Corput, beeswarm, ggplot, ggplot2" ``` -------------------------------- ### dodgeBee Source: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.R Example demonstrating dodge.width for geom_beeswarm with color mapping. ```R ggplot(mapping=aes(labs,dat,color=labs2)) + geom_beeswarm(dodge.width=.8,cex=2) ``` -------------------------------- ### ggOpts Source: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.R Example demonstrating adding color aesthetics to geom_quasirandom. ```R ggplot(mapping=aes(labs, dat)) + geom_quasirandom(aes(color=labs)) ``` -------------------------------- ### vpBeaver Source: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.R An example using the 'beaver' dataset to demonstrate geom_quasirandom. It plots temperature against beaver ID, showing the distribution of temperatures for Beaver 1 and Beaver 2. ```R beaver<-data.frame( 'Temperature'=c(beaver1$temp,beaver2$temp), 'Beaver'=rep( c('Beaver 1','Beaver 2'), c(nrow(beaver1),nrow(beaver2)) ) ) ggplot(beaver,mapping=aes(Beaver, Temperature)) + geom_quasirandom() ``` -------------------------------- ### ggPlot Source: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.R Basic example of using geom_quasirandom with ggplot. ```R library(ggbeeswarm) set.seed(12345) n<-100 dat<-rnorm(n*2) labs<-rep(c('a','b'),n) ggplot(mapping=aes(labs, dat)) + geom_quasirandom() ``` -------------------------------- ### ggFactors Source: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.R Example using factors for x-axis levels in geom_quasirandom. ```R labs2<-factor(labs,levels=c('b','a')) ggplot(mapping=aes(labs2, dat)) + geom_quasirandom(aes(color=labs)) ``` -------------------------------- ### yaxis Source: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.R Example of plotting with the y-axis as the quantitative variable. ```R ggplot(mapping=aes(dat,labs)) + geom_quasirandom(aes(color=labs)) ``` -------------------------------- ### dodgeYBee Source: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.R Example demonstrating dodge.width for geom_beeswarm with y-axis as quantitative. ```R ggplot(mapping=aes(dat,labs,color=labs2)) + geom_beeswarm(dodge.width=.8,cex=2) ``` -------------------------------- ### Facet Bee Source: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.R An example of using geom_beeswarm with faceting, similar to geom_quasirandom but with a different swarm algorithm. ```R ggplot(df,aes(labs,dat,color=labs2)) + geom_beeswarm(cex=3) + facet_grid(.~labs2) ``` -------------------------------- ### showDistAdjust Source: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.R Demonstrates how adjusting the 'bandwidth' and 'width' parameters, as well as using 'nbins', affects the distribution of points in a ggbeeswarm plot. ```R library(gridExtra) p1<-ggplot(mapping=aes(labs, dat)) + geom_quasirandom(bandwidth=2,alpha=.2) + ggtitle('bandwidth=2') + labs(x='') p2<-ggplot(mapping=aes(labs, dat)) + geom_quasirandom(bandwidth=.1,alpha=.2) + ggtitle('bandwidth=.1') + labs(x='') p3<-ggplot(mapping=aes(labs, dat)) + geom_quasirandom(width=.1,alpha=.2) + ggtitle('width=.1') + labs(x='') p4<-ggplot(mapping=aes(labs, dat)) + geom_quasirandom(nbins=100,alpha=.2) + ggtitle('nbins=100') + labs(x='') grid.arrange(p1, p2, p3, p4, ncol=1) ``` -------------------------------- ### Examples Source: https://cran.r-project.org/web/packages/ggbeeswarm/refman/ggbeeswarm.html Generate fake data and plot it using geom_quasirandom. ```R # Generate fake data distro <- data.frame( 'variable'=rep(c('runif','rnorm'),each=100), 'value'=c(runif(100, min=-3, max=3), rnorm(100)) ) ggplot2::ggplot(distro, ggplot2::aes(variable, value)) + geom_quasirandom(width=0.1) ``` -------------------------------- ### nbins Source: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.R Illustrates the effect of the 'nbins' parameter when using the 'smiley' method in geom_quasirandom, showing how different numbers of bins impact point distribution. ```R p1<-ggplot(mapping=aes(labs, dat)) + geom_quasirandom(method='smiley',alpha=.2) + ggtitle('Default (n/5)') + labs(x='') p2<-ggplot(mapping=aes(labs, dat)) + geom_quasirandom(method='smiley',nbins=50,alpha=.2) + ggtitle('nbins=50') + labs(x='') p3<-ggplot(mapping=aes(labs, dat)) + geom_quasirandom(method='smiley',nbins=100,alpha=.2) + ggtitle('nbins=100') + labs(x='') p4<-ggplot(mapping=aes(labs, dat)) + geom_quasirandom(method='smiley',nbins=250,alpha=.2) + ggtitle('nbins=250') + labs(x='') grid.arrange(p1, p2, p3, p4, ncol=1) ``` -------------------------------- ### Examples Source: https://cran.r-project.org/web/packages/ggbeeswarm/refman/ggbeeswarm.html Generate fake data and plot it using geom_beeswarm. ```R # Generate fake data distro <- data.frame( 'variable'=rep(c('runif','rnorm'),each=100), 'value'=c(runif(100, min=-3, max=3), rnorm(100)) ) ggplot2::ggplot(distro,ggplot2::aes(variable, value)) + geom_beeswarm(priority='density',size=2.5) ``` -------------------------------- ### Show Facet Bee Source: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.R This code chunk explicitly shows the geom_beeswarm function with faceting. ```R ggplot(df,aes(labs,dat,color=labs2)) + geom_beeswarm(cex=3) + facet_grid(.~labs2) ``` -------------------------------- ### vpGene Source: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.R Demonstrates geom_quasirandom with the 'vipor' package and 'integrations' data. It plots log-transformed gene distances against study, colored by 'latent', showing the distribution of integrations relative to genes. ```R library(vipor) ints<-integrations[integrations$nearestGene>0,] ints$logGeneDist<-log(ints$nearestGene) ggplot(ints,mapping=aes(study, logGeneDist,color=latent)) + geom_quasirandom(dodge.width=.9,alpha=.4) ``` -------------------------------- ### ggbeeswarm extends ggplot2 with violin point/beeswarm plots Source: https://cran.r-project.org/web/packages/ggbeeswarm/refman/ggbeeswarm.html Examples of using geom_quasirandom() with ggplot2. ```R ggplot2::ggplot(ggplot2::mpg,aes(class, hwy)) + geom_quasirandom() # Generate fake data distro <- data.frame( 'variable'=rep(c('runif','rnorm'),each=100), 'value'=c(runif(100, min=-3, max=3), rnorm(100)) ) ggplot2::ggplot(distro,aes(variable, value)) + geom_quasirandom() ggplot2::ggplot(distro,aes(variable, value)) + geom_quasirandom(width=.1) ``` -------------------------------- ### Arguments Source: https://cran.r-project.org/web/packages/ggbeeswarm/refman/ggbeeswarm.html Arguments for geom_quasirandom. ```R `mapping` | Set of aesthetic mappings created by `aes` or `aes_`. If specified and `inherit.aes = TRUE` (the default), is combined with the default mapping at the top level of the plot. You only need to supply `mapping` if there isn't a mapping defined for the plot. `data` | A data frame. If specified, overrides the default data frame defined at the top level of the plot. `stat` | The statistical transformation to use on the data for this layer, as a string. `...` | other arguments passed to ggplot2::layer `params` argument. `method` | Method used for distributing points. Options are `"quasirandom"` (default), `"pseudorandom"`, `"smiley"`, `"maxout"`, `"frowney"`, `"minout"`, `"tukey"`, `"tukeyDense"`. See `vipor::offsetSingleGroup()` for the details of each method. `width` | Maximum amount of spread (default: 0.4) `varwidth` | Vary the width by the relative size of each group. (default: `FALSE`) `bandwidth` | the bandwidth adjustment to use when calculating density Smaller numbers (< 1) produce a tighter "fit". (default: 0.5) `nbins` | the number of bins used when calculating density (has little effect with quasirandom/random distribution) `dodge.width` | Amount by which points from different aesthetic groups will be dodged. This requires that one of the aesthetics is a factor. To disable dodging between groups, set this to NULL. (default: 0) `groupOnX` | See `orientation`. `orientation` | The orientation (i.e., which axis to group on) is inferred from the data. This can be overridden by setting `orientation` to either `"x"` or `"y"`. `na.rm` | if `FALSE` (default), missing values are removed with a warning. If `TRUE`, missing values are silently removed. `show.legend` | logical. Should this layer be included in the legends? `NA`, the default, includes if any aesthetics are mapped. `FALSE` never includes, and `TRUE` always includes. `inherit.aes` | If `FALSE`, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g. `borders`. ``` -------------------------------- ### Usage Source: https://cran.r-project.org/web/packages/ggbeeswarm/refman/ggbeeswarm.html An internal function to calculate new positions for geom_beeswarm. ```R offset_beeswarm( data, yLim.expand, xRange, yRange, method = "swarm", cex = 1, side = 0L, priority = "ascending", fast = TRUE, corral = "none", corral.width = 0.2, preserve.data.axis = FALSE ) ``` -------------------------------- ### Usage Source: https://cran.r-project.org/web/packages/ggbeeswarm/refman/ggbeeswarm.html The usage of geom_quasirandom. ```R geom_quasirandom( mapping = NULL, data = NULL, stat = "identity", ..., method = "quasirandom", width = NULL, varwidth = FALSE, bandwidth = 0.5, nbins = NULL, dodge.width = NULL, groupOnX = NULL, orientation = NULL, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) ``` -------------------------------- ### position_quasirandom function usage Source: https://cran.r-project.org/web/packages/ggbeeswarm/refman/ggbeeswarm.html The usage signature for the position_quasirandom function, which arranges points using quasirandom noise to avoid overplotting. ```R position_quasirandom( method = "quasirandom", width = NULL, varwidth = FALSE, bandwidth = 0.5, nbins = NULL, dodge.width = 0, orientation = NULL, groupOnX = NULL, na.rm = FALSE ) ``` -------------------------------- ### Points, jittered to reduce overplotting using the beeswarm package Source: https://cran.r-project.org/web/packages/ggbeeswarm/refman/ggbeeswarm.html Usage of geom_beeswarm() with various arguments. ```R geom_beeswarm( mapping = NULL, data = NULL, stat = "identity", ..., method = "swarm", cex = 1, side = 0L, priority = "ascending", fast = TRUE, dodge.width = NULL, corral = "none", corral.width = 0.9, preserve.data.axis = FALSE, groupOnX = NULL, orientation = NULL, beeswarmArgs = list(), na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) ``` -------------------------------- ### position_beeswarm function signature Source: https://cran.r-project.org/web/packages/ggbeeswarm/refman/ggbeeswarm.html The signature of the position_beeswarm function, showing its default arguments. ```R position_beeswarm( method = "swarm", cex = 1, side = 0L, priority = "ascending", fast = TRUE, orientation = NULL, groupOnX = NULL, dodge.width = 0, corral = "none", corral.width = 0.2, preserve.data.axis = FALSE ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.