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.
rproportions(x, target, ..., alpha = 1)
rnmf.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.NMF-class. See the description of the
specific methods for more details on the supported
types.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.
# 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)) )