draw_from_multivariate_corr: Draw random samples from the given random structure

View source: R/dependentsim.R

draw_from_multivariate_corrR Documentation

Draw random samples from the given random structure

Description

Draw random samples from the given random structure

Usage

draw_from_multivariate_corr(random_structure, n_samples, size_factors = NULL)

Arguments

random_structure

The structure of the random data to draw, computed by get_random_structure()

n_samples

The number of samples to generate

size_factors

Vector of length n_samples of size factors for DESeq2-type data. By default, all samples are given 1. Not used if no datasets has type DESeq2.

Value

A list of generated datasets. List names correspond to those of the datasets used to generate the random structure. Each dataset has n_samples columns.

Examples

#' # Generate example data with Sigma as its covariance matrix
library(MASS)
Sigma = matrix(c(
  1,      0.8,    0,  0,  0,  0,
  0.8,    1,      0,  0,  0,  0,
  0,      0,      1,  0,  0,  0,
  0,      0,      0,  1,  0,  0,
  0,      0,      0,  0,  1,  0.3,
  0,      0,      0,  0,  0.3, 1
), nrow=6, ncol=6)
norm_data <- t(mvrnorm(n=20, mu=c(0,0,0,0,0,0), Sigma=Sigma))

# Simulate draws mimicking that data
rs_normal <- get_random_structure(list(data=norm_data), method="pca", rank=2, type="normal")
draws_normal <- draw_from_multivariate_corr(rs_normal, n_samples=30)

dependentsimr documentation built on Aug. 8, 2025, 6:23 p.m.