@@ -270,6 +270,7 @@ embed_latent_space <- function(counts,
270270# ' @return normalised PCA embedding matrix
271271# ' @importFrom Seurat RunPCA
272272# ' @importFrom Seurat Embeddings
273+ # ' @importFrom stats setNames
273274embed_pca <- function (counts ,
274275 dimensions ,
275276 features = NULL ,
@@ -503,27 +504,30 @@ embed_lsi_umap <- function(counts,
503504# ' @param counts Seurat object containing normalised counts
504505# ' @param dimensions number dimension to retain from NMF
505506# ' @param verbose logical if progress messages should be outputed
507+ # ' @importFrom NMF nmf coefficients
506508# ' @return normalised NMF embedding matrix
507509embed_nmf <- function (counts , dimensions , verbose = TRUE ) {
508- # --------------------------------------------------------------------------#
509- # adding this since I don't want to have this package as a dependancy
510- # The problem is that those functions are exported to name space
511- # but NMF only works if the package is attached.
512- # --------------------------------------------------------------------------#
513- inst <- requireNamespace(" NMF" , quietly = TRUE )
514- if (! inst ) {
515- stop(" NMF is not installed - Please install NMF
516- install.packages('NMF')
517- https://cran.r-project.org/web/packages/NMF/index.html" )
518- } else {
519- library(" NMF" )
520- }
510+ # #--------------------------------------------------------------------------#
511+ # # adding this since I don't want to have this package as a dependancy
512+ # # The problem is that those functions are exported to name space
513+ # # but NMF only works if the package is attached.
514+ # #--------------------------------------------------------------------------#
515+ # inst <- requireNamespace("NMF", quietly = TRUE)
516+ # if (!inst) {
517+ # stop("NMF is not installed - Please install NMF
518+ # install.packages('NMF')
519+ # https://cran.r-project.org/web/packages/NMF/index.html")
520+
521+ # } else {
522+ # library("NMF")
523+ # }
524+
521525
522526 # --------------------------------------------------------------------------#
523527 # Get the normalized count matrix and matrix with variable features
524528 # from the Seurat object
525529 # --------------------------------------------------------------------------#
526- vesalius ::: message_switch(" nmf_tensor" , verbose )
530+ message_switch(" nmf_tensor" , verbose )
527531 features <- check_features(counts )
528532 count_matrix <- as.matrix(Seurat :: GetAssayData(counts , layer = " data" ))
529533 count_matrix <- count_matrix [features , ]
@@ -539,7 +543,7 @@ embed_nmf <- function(counts, dimensions, verbose = TRUE) {
539543 # Get the NMF projections (W matrix) and normalize
540544 # --------------------------------------------------------------------------#
541545 nmf_projections <- t(NMF :: coefficients(nmf_result ))
542- nmf_projections <- apply(nmf_projections , 2 , vesalius ::: norm_pixel , " minmax" )
546+ nmf_projections <- apply(nmf_projections , 2 , norm_pixel , " minmax" )
543547 nmf_projections <- list (as.matrix(nmf_projections ))
544548 names(nmf_projections ) <- " NMF"
545549
0 commit comments