Generating Random Cell Type Proportions

Description

rproportions generates a random NMF model, whose mixture coefficients for each sample (i.e. column of the coefficient matrix) fulfil the sum-up-to-one constraint of proportions.

Usage

rproportions(x, target, ..., alpha = 1)

Arguments

...
extra arguments passed to rnmf.
alpha
shape parameter(s) for the dirichlet distribution. It must be a single numeric value, or a numeric vector of length the number of basis components in the NMF model -- which is generally specified in object. If a single numeric, it is used as a shape parameters for all components. If alpha=NA, then the coefficients are only scaled to sum-up to one. Note that because it appears after arguments ..., its name must be fully specified, or it will be passed to rnmf, while its default value used within rproportions.
x
an object that determines the rank, dimension and/or class of the generated NMF model, e.g. a numeric value or an object that inherits from class NMF-class. See the description of the specific methods for more details on the supported types.
target
optional specification of target dimensions. See section Methods for how this parameter is used by the different methods.

Details

Internally, it generates a full random NMF model using the function rnmf, and either scale the columns of its coefficient matrix so that they sum-up to one if alpha=NA, or re-draw them from a dirichlet distribution using the function rdirichlet if alpha is a single number or a numeric vector.

This function is suitable for seeding NMF computation, and is in fact registered as the seeding method ‘rprop’, which can be used in calls to nmf.

Examples


# target data
x <- rmatrix(20,10)

# generate models
rproportions(3, x)
## <Object of class:NMFstd>
## features: 20 
## basis/rank: 3 
## samples: 10
rproportions(3, 30, 15)
## <Object of class:NMFstd>
## features: 30 
## basis/rank: 3 
## samples: 15

# scaling only
rproportions(3, 20, 10, alpha=NA)
## <Object of class:NMFstd>
## features: 20 
## basis/rank: 3 
## samples: 10
# full shape specification
rproportions(3, x, alpha=c(1,2,3))
## <Object of class:NMFstd>
## features: 20 
## basis/rank: 3 
## samples: 10

# error if alpha has wrong length
try( rproportions(3, 20, 10, alpha=c(1,2,3,4)) )