Use NMF to perform dimension reduction.

runNMF(
  gobject,
  spat_unit = NULL,
  feat_type = NULL,
  expression_values = c("normalized", "scaled", "custom"),
  reduction = c("cells", "feats"),
  name = NULL,
  feats_to_use = "hvf",
  return_gobject = TRUE,
  scale_unit = TRUE,
  k = 20,
  method = c("rcppml"),
  rev = FALSE,
  set_seed = TRUE,
  seed_number = 1234,
  verbose = TRUE,
  toplevel = 1L,
  ...
)

Arguments

gobject

giotto object

spat_unit

spatial unit (e.g. "cell")

feat_type

feature type (e.g. "rna", "dna", "protein")

expression_values

expression values to use

reduction

"cells" or "feats"

name

arbitrary name for NMF run

feats_to_use

subset of features to use for NMF

return_gobject

boolean: return giotto object (default = TRUE)

scale_unit

scale features before NMF (default = TRUE)

k

NMF rank (number of components to decompose into). Default is 20

method

which implementation to use (only rcppml right now)

rev

do a reverse NMF

set_seed

use of seed

seed_number

seed number to use

verbose

verbosity of the function

toplevel

relative stackframe where call was made

...

additional parameters for NMF (see details)

Value

giotto object with updated NMF dimension reduction

Details

See nmf for more information about other parameters.

Examples

g <- GiottoData::loadGiottoMini("visium")
#> 1. read Giotto object
#> 2. read Giotto feature information
#> 3. read Giotto spatial information
#> 3.1 read Giotto spatial shape information
#> 3.2 read Giotto spatial centroid information
#> 3.3 read Giotto spatial overlap information
#> 4. read Giotto image information
#> python already initialized in this session
#>  active environment : '/usr/bin/python3'
#>  python version : 3.12
x <- runNMF(g, k = 20)
#> "hvf" column was found in the feats metadata information and will be
#>  used to select highly variable features
#> [Running RcppML NMF]. This citation shown once per session:
#> Zachary J. DeBruine, Karsten Melcher, Timothy J. Triche Jr
#>  Fast and robust non-negative matrix factorization for single-cell experiments
#>  bioRxiv 2021.09.01.458620.
#>  https://doi.org/10.1101/2021.09.01.458620
#> 
#> iter |      tol 
#> ---------------
#>    1 | 8.68e-01
#>    2 | 1.06e-01
#>    3 | 4.20e-02
#>    4 | 2.40e-02
#>    5 | 1.50e-02
#>    6 | 1.07e-02
#>    7 | 8.13e-03
#>    8 | 5.39e-03
#>    9 | 3.11e-03
#>   10 | 2.04e-03
#>   11 | 1.53e-03
#>   12 | 1.18e-03
#>   13 | 9.46e-04
#>   14 | 7.65e-04
#>   15 | 6.38e-04
#>   16 | 5.10e-04
#>   17 | 4.68e-04
#>   18 | 4.30e-04
#>   19 | 3.94e-04
#>   20 | 3.51e-04
#>   21 | 3.07e-04
#>   22 | 2.39e-04
#>   23 | 1.90e-04
#>   24 | 1.70e-04
#>   25 | 1.53e-04
#>   26 | 1.35e-04
#>   27 | 1.21e-04
#>   28 | 1.05e-04
#>   29 | 9.11e-05
#> Setting dimension reduction [cell][rna] nmf
x <- runUMAP(x,
    dim_reduction_to_use = "nmf",
    dimensions_to_use = 1:20,
    name = "nmf_umap"
)
#> Setting dimension reduction [cell][rna] nmf_umap
x <- createNearestNetwork(x,
    dim_reduction_to_use = "nmf",
    dim_reduction_name = "nmf",
    dimensions_to_use = 1:20
)
x <- doLeidenCluster(x, name = "nmf_leiden", network_name = "sNN.nmf")
#> Error in py_run_file_impl(file, local, convert): ModuleNotFoundError: No module named 'igraph'
#> Run `reticulate::py_last_error()` for details.
plotUMAP(x, dim_reduction_name = "nmf_umap", cell_color = "nmf_leiden")
#> Error: dimPlot2D()
#>  nmf_leiden is not a color or a column name
spatPlot2D(x, cell_color = "nmf_leiden")
#> Error: spatPlot2D()
#>  nmf_leiden is not a color or a column name