Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


NMF (version 0.2.2)

syntheticNMF: Simulating Datasets

Description

The function syntheticNMF generates random target matrices that follow some defined NMF model, and may be used to test NMF algorithms. It is designed to designed to produce data with known or clear classes of samples.

Usage

syntheticNMF(n, r, p, offset = NULL, noise = TRUE,
    factors = FALSE, seed = NULL)

Arguments

n
number of rows of the target matrix.
r
specification of the factorization rank. It may be a single numeric, in which case argument p is required and r groups of samples are generated from a draw from a multinomial distribution with equal probabili
p
number of columns of the synthetic target matrix. Not used if parameter r is a vector (see description of argument r).
offset
specification of a common offset to be added to the synthetic target matrix, before noisification. Its may be a numeric vector of length n, or a single numeric value that is used as the standard deviation of a centred normal distribut
noise
a logical that indicate if noise should be added to the matrix.
factors
a logical that indicates if the NMF factors should be return together with the matrix.
seed
a single numeric value used to seed the random number generator before generating the matrix. The state of the RNG is restored on exit.

Value

  • a matrix, or a list if argument factors=TRUE.

    When factors=FALSE, the result is a matrix object, with the following attributes set: [object Object],[object Object],[object Object],[object Object],[object Object]

    Moreover, the result object is an ExposeAttribute object, which means that relevant attributes are accessible via $, e.g., res$coefficients. In particular, methods coef and basis will work as expected and return the true underlying coefficient and basis matrices respectively.

Examples

Run this code
# roxygen generated flag
options(R_CHECK_RUNNING_EXAMPLES_=TRUE)

# generate a synthetic dataset with known classes: 50 features, 18 samples (5+5+8)
n <- 50
counts <- c(5, 5, 8)

# no noise
V <- syntheticNMF(n, counts, noise=FALSE)
aheatmap(V)

# with noise
V <- syntheticNMF(n, counts)
aheatmap(V)

Run the code above in your browser using DataLab