R Under development (unstable) (2023-10-23 r85401 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ### TEST-SUITE ##################################################################################### > # Description: This script runs the plotting code in BoutrosLab.plotting.general for testing purposes > # The plots are stored in variables and plotted together in a single multiple in order to save plot-generation time > > warning(paste( + 'BPG will discontinue this test file in v8.0.0.', + 'Instead, tests will use the standard testthat format.', + 'For more information, see https://testthat.r-lib.org/' + )); Warning message: BPG will discontinue this test file in v8.0.0. Instead, tests will use the standard testthat format. For more information, see https://testthat.r-lib.org/ > > ### LOAD LIBRARY ################################################################################### > library(BoutrosLab.plotting.general); Loading required package: lattice Loading required package: latticeExtra Loading required package: cluster Loading required package: hexbin Loading required package: grid Attaching package: 'BoutrosLab.plotting.general' The following object is masked from 'package:stats': dist > > ### PLOTTING FUNCTIONS ############################################################################# > test.data <- data.frame( + x = 1:10, + y = LETTERS[1:10], + z = rnorm(10), + type = rep(LETTERS[1:2], 5), + stringsAsFactors = TRUE + ); > > # testing legend.grob > covariate.legend <- list( + legend = list( + colours = default.colours(2), + labels = levels(test.data$type)[1:2] + ) + ); > > legend.grob2 <- legend.grob( + legends = covariate.legend + ); Warning message: In FUN(X[[i]], ...) : 'x' is NULL so the result will be NULL > > # testing covariates.grob > covariate.colours1 <- as.character(test.data$type); > covariate.colours1[covariate.colours1 == 'A'] <- default.colours(2)[1]; > covariate.colours1[covariate.colours1 == 'B'] <- default.colours(2)[2]; > > # create an object to draw the covariates from > covariates1 <- list( + rect = list( + col = 'black', + fill = covariate.colours1, + lwd = 1.5 + ) + ); > > covariates.grob1 <- covariates.grob( + covariates = covariates1, + ord = c(1:10), + side = 'top', + size = .8 + ); > > barplot <- create.barplot( + formula = y ~ x, + data = test.data, + legend = list( + bottom = list( + fun = covariates.grob1 + ), + right = list( + fun = legend.grob2 + ), + inside = list( + fun = draw.key, + args = list( + key = get.corr.key( + x = test.data$x, + y = test.data$y, + label.items = c('spearman', 'spearman.p', 'kendall', 'beta1') + ) + ), + x = 0.5, + y = 0.5 + ) + ), + description = 'testing metadata' + ); Warning messages: 1: In model.response(mf, "numeric") : using type = "numeric" with a factor response will be ignored 2: In Ops.factor(y, z$residuals) : '-' not meaningful for factors > > # this isn't printed anywhere > dend <- create.dendrogram( + x = data.frame(test.data$z, rnorm(10)) + ); > > # # This is the slowest running function > # heatmap <- create.heatmap( > # x = as.matrix(test.data$z), > # clustering.method = 'none' > # ); > > dotmap <- create.dotmap( + x = test.data$z + ); > > hexbin <- create.hexbinplot( + formula = z ~ x, + data = test.data + ); > > # Also using generate.at.final() > density <- create.densityplot( + x = list( + a = test.data$x, + b = test.data$z + ), + xat = c(0, 1.1, 1.5, 1, 6, 4), + yat = c(0.34, 0.38, 0.7), + type = c('g', 'l'), + resolution = 100 + ); > > manhattanplot <- create.manhattanplot( + formula = x ~ y, + data = test.data + ); > > polygonplot <- create.polygonplot( + formula = NA ~ x, + data = test.data, + max = test.data$x, + min = test.data$z, + xlimits = c(0, 10), + ylimits = c(-2, 10) + ); > > qqcomp <- create.qqplot.comparison( + x = list(test.data$x, test.data$z) + ); > > scatter <- create.scatterplot( + formula = x ~ z, + data = test.data + ); > > seg <- create.segplot( + formula = y ~ x + z, + data = test.data + ); > > violin <- create.violinplot( + formula = y ~ z, + data = test.data + ); > > strip <- create.stripplot( + formula = z ~ y, + data = test.data + ); > > boxplot <- create.boxplot( + formula = x ~ y, + data = test.data + ); > > # these do not easily join the multiplot > histogram <- create.histogram( + x = test.data$z + ); > > qqfit <- create.qqplot.fit( + x = test.data$z + ); > > # Plot everything in one plot for quicker running time > create.multiplot( + file = NULL, + plot.objects = list(polygonplot, manhattanplot, hexbin, dotmap, density, qqcomp, scatter, seg, violin, barplot, strip, boxplot) + ); > > ### HELPER FUNCTIONS ############################################################################### > > get.line.breaks(1:10); [1] 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5 9.5 > > scientific.notation(1234, 2, type = 'list'); $base [1] "1.23" $exponent [1] 3 > scientific.notation(0, 2); [1] 0 > scientific.notation(c(1234, 1234), 1); expression("1.2" %*% 10^3, "1.2" %*% 10^3) > > # This returns the same thing as when type = 'expression' - should something be changed? > scientific.notation(c(1234, 1234), 1, type = 'list'); expression("1.2" %*% 10^3, "1.2" %*% 10^3) > > display.statistical.result(1234); expression("P: 1200") > > ### COLOUR FUNCTIONS ############################################################################### > default.colours(12, is.greyscale = FALSE); [1] "orange" "chartreuse4" "darkorchid4" "gold" "dodgerblue" [6] "firebrick3" "yellowgreen" "darkorange1" "slateblue4" "seagreen3" [11] "violetred3" "turquoise3" > default.colours(5, palette.type = 'chromosomes', is.greyscale = FALSE); [1] "darkred" "firebrick1" "pink1" "darkorange3" "darkorange" > default.colours(5, palette.type = 'seq'); [1] "#C1D8AA" "#83B155" "#458B00" "#2E5C00" "#172E00" > default.colours(c(4, 4), palette.type = c('seq', 'div')); [[1]] [1] "#C1D8AA" "#83B155" "#458B00" "#2E5C00" [[2]] [1] "#B32B2B" "#DD4E4E" "#EB7C7C" "#F7BEBE" > > # display.colours(default.colours(3)); > # display.colours(grey(0.5)); > > force.colour.scheme(c('stopgain snv', 'splicing'), 'annovar.annotation'); [1] "orchid4" "gold1" > > proc.time() user system elapsed 1.00 0.17 1.15