Perplexity can be seen as a measure of how well a provided set of cluster assignments fit the data being clustered.

# S3 method for celda_C
calculatePerplexity(counts, celda.mod, new.counts = NULL)

Arguments

counts

Integer matrix. Rows represent features and columns represent cells. This matrix should be the same as the one used to generate `celda.mod`.

celda.mod

Celda object of class "celda_C"

new.counts

A new counts matrix used to calculate perplexity. If NULL, perplexity will be calculated for the 'counts' matrix. Default NULL.

Value

Numeric. The perplexity for the provided count data and model.

Examples

celda.sim = simulateCells(model="celda_C") celda.mod = celda_C(celda.sim$counts, K=celda.sim$K)
#> --------------------------------------------------------------------
#> Starting Celda_C: Clustering cells.
#> --------------------------------------------------------------------
#> Thu Sep 06 12:54:31 2018 .. Initializing chain 1 with 'random' (seed=12345)
#> Thu Sep 06 12:54:31 2018 .... Completed iteration: 1 | logLik: -1403838.03777873
#> Thu Sep 06 12:54:31 2018 .... Completed iteration: 2 | logLik: -1400194.39761642
#> Thu Sep 06 12:54:31 2018 .... Completed iteration: 3 | logLik: -1377050.9603928
#> Thu Sep 06 12:54:31 2018 .... Completed iteration: 4 | logLik: -1377050.9603928
#> Thu Sep 06 12:54:31 2018 .... Completed iteration: 5 | logLik: -1377050.9603928
#> Thu Sep 06 12:54:31 2018 .... Completed iteration: 6 | logLik: -1377050.9603928
#> Thu Sep 06 12:54:31 2018 .... Completed iteration: 7 | logLik: -1377050.9603928
#> Thu Sep 06 12:54:31 2018 .... Completed iteration: 8 | logLik: -1377050.9603928
#> Thu Sep 06 12:54:31 2018 .... Completed iteration: 9 | logLik: -1377050.9603928
#> Thu Sep 06 12:54:31 2018 .... Determining if any cell clusters should be split.
#> Thu Sep 06 12:54:31 2018 .... Cluster 1 was reassigned and cluster 4 was split in two.
#> Thu Sep 06 12:54:31 2018 .... Completed iteration: 10 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:31 2018 .... Completed iteration: 11 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:31 2018 .... Completed iteration: 12 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:31 2018 .... Completed iteration: 13 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:31 2018 .... Completed iteration: 14 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:31 2018 .... Completed iteration: 15 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:31 2018 .... Completed iteration: 16 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:31 2018 .... Completed iteration: 17 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:31 2018 .... Completed iteration: 18 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:31 2018 .... Completed iteration: 19 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:31 2018 .... Determining if any cell clusters should be split.
#> Thu Sep 06 12:54:32 2018 .... No additional splitting was performed.
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 20 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .. Finished chain 1 with seed 12345
#> Thu Sep 06 12:54:32 2018 .. Initializing chain 2 with 'random' (seed=12346)
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 1 | logLik: -1383993.83150535
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 2 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 3 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 4 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 5 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 6 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 7 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 8 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 9 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Determining if any cell clusters should be split.
#> Thu Sep 06 12:54:32 2018 .... No additional splitting was performed.
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 10 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 11 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Determining if any cell clusters should be split.
#> Thu Sep 06 12:54:32 2018 .... No additional splitting was performed.
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 12 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .. Finished chain 2 with seed 12346
#> Thu Sep 06 12:54:32 2018 .. Initializing chain 3 with 'random' (seed=12347)
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 1 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 2 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 3 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 4 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 5 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 6 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 7 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 8 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 9 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Determining if any cell clusters should be split.
#> Thu Sep 06 12:54:32 2018 .... No additional splitting was performed.
#> Thu Sep 06 12:54:32 2018 .... Completed iteration: 10 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:32 2018 .... Determining if any cell clusters should be split.
#> Thu Sep 06 12:54:33 2018 .... No additional splitting was performed.
#> Thu Sep 06 12:54:33 2018 .... Completed iteration: 11 | logLik: -1358078.99551138
#> Thu Sep 06 12:54:33 2018 .. Finished chain 3 with seed 12347
#> --------------------------------------------------------------------
#> Completed Celda_C. Total time: 1.796968 secs
#> --------------------------------------------------------------------
perplexity = calculatePerplexity(celda.sim$counts, celda.mod)