This function trains a Non-negative Matrix Factorization (NMF) model for SE deconvolution based on given spatial ecotype fractions and gene expression matrix. Prior to NMF, each gene is scaled to mean 0 and unit variance. To satisfy the non-negativity requirement of NMF, the expression matrix is processed using posneg transformation, which converts the expression matrix into two matrices, one containing only positive values and the other containing only negative values with the sign inverted. The two matrices are subsequently concatenated to produce the training data.
Usage
NMFGenerateW(
Fracs,
ExpMat,
scale = TRUE,
nfeature = 2000,
nfeature.per.se = 50,
method = "brunet"
)
Arguments
- Fracs
A fraction matrix, with rows as samples.
- ExpMat
A gene expression matrix with genes in rows and samples in columns.
- scale
Logical indicating whether to scale the gene expression matrix. Default is TRUE.
- nfeature
Integer specifying the top variable features for training the models (default: 2000).
- nfeature.per.se
Integer specifying the maximal number of features to select for each SE (default: 50).
- method
A character string specifying the NMF method to use. Default is "brunet".