sim_mat: Simulate Matrix with Metadata

View source: R/sim_mat.R

sim_matR Documentation

Simulate Matrix with Metadata

Description

Generates a matrix of random normal data, then optionally scales values between 0 and 1 column-wise. It also creates corresponding data frames for feature (column) and sample (row) metadata and can optionally introduce NA values into a specified proportion of rows. A correlation between columns rho (before scaling) can be added.

Usage

sim_mat(
  n = 100,
  p = 100,
  rho = 0.5,
  n_col_groups = 2,
  n_row_groups = 1,
  perc_total_na = 0.1,
  perc_col_na = 0.5,
  beta = TRUE
)

Arguments

n

An integer specifying the number of rows (samples). Default is 100.

p

An integer specifying the number of columns (features). Default is 100.

rho

Columns correlation before scaling (compound symmetry). Default is 0.5.

n_col_groups

An integer for the number of groups to assign to features/columns. Default is 2.

n_row_groups

An integer for the number of groups to assign to samples/rows. Default is 1.

perc_total_na

Proportion of all cells to set to NA. Default is 0.1.

perc_col_na

Proportion of columns across which those NAs are spread. Default is 0.5.

beta

If TRUE (default) scale values between 0 and 1 column wise.

Value

An object of class slideimp_sim. This is a list containing:

  • input: A numeric matrix of dimension n \times p containing the simulated values and injected NAs.

  • col_group: A data frame with $p$ rows mapping each feature to a group.

  • row_group: A data frame with $n$ rows mapping each sample to a group.

Examples

set.seed(123)
sim_data <- sim_mat(n = 50, p = 10, rho = 0.5)
sim_data

slideimp documentation built on April 17, 2026, 1:07 a.m.