selectModel: Select the number of clusters

View source: R/main.R

selectModelR Documentation

Select the number of clusters

Description

Select the number of clusters by specified criteria.

Usage

  
  selectModel(obj, criteria = 'MBIC', pen.const=1)
  ## S3 method for class 'drscObject'
selectModel(obj, criteria = 'MBIC', pen.const=1)
  ## S3 method for class 'Seurat'
selectModel(obj, criteria = 'MBIC', pen.const=1)
  
  

Arguments

S

obj

an object with class Seurat by DR.SC or class drscObject by DR.SC_fit.

criteria

a string, specify the criteria used for selecting the number of clusters, supporting "MBIC", "BIC" and "AIC".

pen.const

an optional positive value, the adjusted constant used in the MBIC criteria. It usually takes value between 0.1 to 1.

Value

For S3 method of Seurat, it return a revised "Seurat" object with updated Idents(seu), spatial.drsc.cluster in the metadata and DimReduc object named dr-sc in the slot reductions. For S3 method of drscObject, it returns a list with the following components:

bestK

the selected number of clusters.

cluster

inferred class labels

hZ

extracted latent features.

icMat

a numeric matrix including the criteria value for each number of clusters K.

Note

nothing

Author(s)

Wei Liu

References

Wei Liu, Xu Liao, Yi Yang, Huazhen Lin, Joe Yeong, Xiang Zhou, Xingjie Shi & Jin Liu (2022). Joint dimension reduction and clustering analysis of single-cell RNA-seq and spatial transcriptomics data, Nucleic Acids Research, gkac219.

See Also

DR.SC, DR.SC_fit.

Examples

seu <- gendata_RNAExp(height=10, width=10,p=50, K=4)
library(Seurat)
seu <- NormalizeData(seu, verbose=FALSE)
# or choose 40 spatailly variable features using FindSVGs in DR.SC
seu <- FindSVGs(seu, nfeatures = 40, verbose=FALSE)
# users define the adjacency matrix
Adj_sp <- getAdj(seu, platform = 'ST')
dat <- GetAssayData(seu, assay = "RNA", slot='data')
X <- Matrix::t(dat)
# maxIter = 2 is only used for illustration, and user can use default.
drscList <- DR.SC_fit(X,Adj_sp=Adj_sp ,K=4, maxIter=2, verbose=TRUE)
drsc1 <- selectModel(drscList)
str(drsc1)

feiyoung/DR.SC documentation built on March 23, 2024, 6:31 p.m.