Test your GeneNMF installation
masterTo verify that the installation was successful, load the library, load the provided sampleObj dataset, and run the runNMF function.
library(GeneNMF)
data(sampleObj)
sampleObj <- runNMF(sampleObj, k=5)repository·master·Indexed 41 days ago
https://github.com/carmonalab/genenmfAn R package for the discovery of recurrent gene programs in multi-sample single-cell omics data using Non-negative Matrix Factorization (NMF). It provides tools to reduce dimensionality via `runNMF()`, extract robust meta-programs across multiple samples using `multiNMF()` and `getMetaPrograms()`, and tune decomposition sparsity through parameters like `specificity.weight`.
To verify that the installation was successful, load the library, load the provided sampleObj dataset, and run the runNMF function.
library(GeneNMF)
data(sampleObj)
sampleObj <- runNMF(sampleObj, k=5)GeneNMF provides a workflow to extract robust gene programs (meta-programs) across multiple samples and different NMF factor counts ($k$).
multiNMF(sampleObj.list, k): Performs NMF over a list of Seurat objects for multiple values of $k$.getMetaPrograms(geneNMF.programs, nMP): Clusters the resulting gene programs into consensus meta-programs (MPs). It computes MP metrics and identifies the most influential MP genes.Example workflow:
# 1. Split a Seurat object into a list (e.g., by donor)
sampleObj.list <- Seurat::SplitObject(sampleObj, split.by = "donor")
# 2. Run NMF for a range of k values
geneNMF.programs <- multiNMF(sampleObj.list, k=4:9)
# 3. Extract consensus meta-programs
geneNMF.metaprograms <- getMetaPrograms(geneNMF.programs, nMP=5)sampleObj.list <- Seurat::SplitObject(sampleObj, split.by = "donor")
geneNMF.programs <- multiNMF(sampleObj.list, k=4:9)
geneNMF.metaprograms <- getMetaPrograms(geneNMF.programs, nMP=5)You can install the stable release of GeneNMF from CRAN or the latest development version from GitHub using the remotes package.
# Install release version from CRAN
install.packages("GeneNMF")
# Or for the latest version, install from GitHub
library(remotes)
remotes::install_github("carmonalab/GeneNMF")GeneNMF includes several parameters to tune the decomposition and the identification of meta-programs:
specificity.weight: Used to re-normalize NMF loadings to impose sparsity in the decomposition based on how specific a gene is for a given program.scale: Boolean to determine if expression matrices should be scaled (default behavior is not scaled).center: Boolean to determine if expression matrices should be centered (default behavior is not centered).nMP: The number of meta-programs to extract (formerly nprograms).weight.explained: A fraction of the total weight used to determine which genes are included in an MP. Only genes that cumulatively explain up to this fraction are included.min.confidence: Defines the confidence of a gene in an MP. Confidence is calculated as the fraction of individual programs in which the gene is determined to be part of the program (using weight.explained=0.8).The runNMF() function can be applied directly to a Seurat object to reduce dimensionality and detect gene programs.
Example usage:
sampleObj <- runNMF(sampleObj, k=5)