This vignette contains part I of a set of examples on how to use
clugenr
in 3D. Examples require the following setup
code:
library(clugenr) # The clugenr library
options(rgl.useNULL = TRUE) # Create RGL plots in systems without displays (CI)
library(rgl)
setupKnitr(autoprint = TRUE) # Render RGL plots directly on generated page
# Load helper functions for plotting examples
source("plot_examples_3d.R", local = knitr::knit_global())
# Keep examples reproducible in newer R versions
RNGversion("3.6.0")
The 3D examples were plotted with the plot_examples_3d()
function available here.
direction
parameterangle_disp
parameter and using a custom
angle_deltas_fn
function# Custom angle_deltas function: arbitrarily rotate some clusters by 90 degrees
angdel_90 <- function(nclu, astd) sample(c(0, pi / 2), nclu, replace = TRUE)
direction
for each cluster and
changing angle_disp
# Define a main direction for each cluster
dirs <- matrix(c(1, 1, 1,
0, 0, 1,
1, 0, 0,
0, 1, 0,
-1, 1, 1),
nrow = 5, byrow = TRUE)
llength
parametere052 <- clugen(3, 5, 800, c(1, 0, 0), pi / 10, c(10, 10, 10), 0, 0, 0.5,
seed = seed, point_dist_fn = "n")
e053 <- clugen(3, 5, 800, c(1, 0, 0), pi / 10, c(10, 10, 10), 10, 0, 0.5,
seed = seed, point_dist_fn = "n")
e054 <- clugen(3, 5, 800, c(1, 0, 0), pi / 10, c(10, 10, 10), 30, 0, 0.5,
seed = seed, point_dist_fn = "n")
llength_disp
parameter and using a custom
llengths_fn
function# Custom llengths function: line lengths tend to grow for each new cluster
llen_grow <- function(nclu, llen, llenstd) {
llen * (0:(nclu - 1) + rnorm(nclu, sd = llenstd))
}
e055 <- clugen(3, 5, 800, c(1, 0, 0), pi / 10, c(10, 10, 10), 15, 0.0, 0.5,
seed = seed, point_dist_fn = "n")
e056 <- clugen(3, 5, 800, c(1, 0, 0), pi / 10, c(10, 10, 10), 15, 10.0, 0.5,
seed = seed, point_dist_fn = "n")
e057 <- clugen(3, 5, 800, c(1, 0, 0), pi / 10, c(10, 10, 10), 10, 0.1, 0.5,
seed = seed, point_dist_fn = "n", llengths_fn = llen_grow)
cluster_sep
parametercluster_offset
parameter and using a
custom clucenters_fn
function# Custom clucenters function: places clusters in a diagonal
centers_diag <- function(nclu, csep, coff) {
matrix(1, nrow = nclu, ncol = length(csep)) * (1:nclu * max(csep)) +
rep(coff, each = nclu)
}
e061 <- clugen(3, 8, 1000, c(1, 1, 1), pi / 4, c(10, 10, 10), 12, 3, 2.5, seed = seed)
e062 <- clugen(3, 8, 1000, c(1, 1, 1), pi / 4, c(10, 10, 10), 12, 3, 2.5, seed = seed,
cluster_offset = c(20, -20, 20))
e063 <- clugen(3, 8, 1000, c(1, 1, 1), pi / 4, c(10, 10, 10), 12, 3, 2.5, seed = seed,
cluster_offset = c(-50, -50, -50), clucenters_fn = centers_diag)