
Get the NMF gene loadings
get_nmf_gene_loadings.RdGetter function to extract the gene loadings matrix (features x k) from a
bulk NMF fit stored in BulkCoExp(). If no NMF fit is present,
returns NULL with a warning.
Arguments
- object
The class, see
BulkCoExp().
Examples
# gene loadings of a four-factor fit
syn <- generate_gene_module_data(n_samples = 24L, n_genes = 60L)
# NMF needs a non-negative matrix
mat <- syn$data - min(syn$data)
obj <- BulkCoExp(mat, syn$meta_data)
obj <- preprocess_bulk_coexp(
obj, hvg = NULL, scaling = FALSE, .verbose = FALSE
)
obj <- nmf_bulk(obj, k = 4L, .verbose = FALSE)
dim(get_nmf_gene_loadings(obj))
#> [1] 60 4