Compute purity of each cell's neighborhood, as defined by KNN graph. For each neighborhood, the proportion of cells belonging to the most represented cluster is computed as the purity score. The Purity score is stored in the metadata of the returned seurat object.

neighborPurity(object, graph, cluster.field = "seurat_clusters", verbose = T)

Arguments

object

Seurat object

graph

name of KNN graph to use for analysis. Must be present within provided seurat object. If absent, run FindNeighbors().

cluster.field

name of cluster metadata field to use for cluster membership data. Default is 'seurat_clusters'.

verbose

Print progress. Default is TRUE.

Value

Seurat object with purity score stored in metadata

Author

Nicholas Mikolajewicz

Examples


object <- FindNeighbors(object)
#> Error in FindNeighbors(object): object 'object' not found
object <- FindClusters(object, resolution = 1)
#> Error in FindClusters(object, resolution = 1): object 'object' not found
object <- neighborPurity(object, "RNA_nn")
#> Error in graph %in% names(object@graphs): object 'object' not found