Generate factorized matrices showing each feature's influence on the celda_CG model clustering

# S3 method for celda_CG
factorizeMatrix(counts, celda.mod, type = c("counts",
  "proportion", "posterior"))

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 model. Options are "celda_C" or "celda_CG". Celda object of class "celda_CG".

type

Character vector. A vector containing one or more of "counts", "proportion", or "posterior". "counts" returns the raw number of counts for each factorized matrix. "proportions" returns the normalized probabilities for each factorized matrix, which are calculated by dividing the raw counts in each factorized matrix by the total counts in each column. "posterior" returns the posterior estimates. Default `c("counts", "proportion", "posterior")`.

Value

A list of factorized matrices, of the types requested by the user. NOTE: "population" state matrices are always returned in cell population (rows) x transcriptional states (cols).

Examples

celda.sim = simulateCells("celda_CG") celda.mod = celda_CG(celda.sim$counts, K=celda.sim$K, L=celda.sim$L)
#> --------------------------------------------------------------------
#> Starting Celda_CG: Clustering cells and genes.
#> --------------------------------------------------------------------
#> Thu Sep 06 12:56:52 2018 .. Initializing chain 1 with 'random' (seed=12345)
#> Thu Sep 06 12:56:52 2018 .... Completed iteration: 1 | logLik: -1302242.28026966
#> Thu Sep 06 12:56:52 2018 .... Completed iteration: 2 | logLik: -1270044.02532694
#> Thu Sep 06 12:56:52 2018 .... Completed iteration: 3 | logLik: -1262209.15789703
#> Thu Sep 06 12:56:52 2018 .... Completed iteration: 4 | logLik: -1261712.35040107
#> Thu Sep 06 12:56:52 2018 .... Completed iteration: 5 | logLik: -1261712.57070977
#> Thu Sep 06 12:56:52 2018 .... Completed iteration: 6 | logLik: -1261711.00382116
#> Thu Sep 06 12:56:52 2018 .... Completed iteration: 7 | logLik: -1261716.24159949
#> Thu Sep 06 12:56:52 2018 .... Completed iteration: 8 | logLik: -1261479.73933942
#> Thu Sep 06 12:56:52 2018 .... Completed iteration: 9 | logLik: -1259874.14368698
#> Thu Sep 06 12:56:52 2018 .... Determining if any cell clusters should be split.
#> Thu Sep 06 12:56:52 2018 .... Cluster 1 was reassigned and cluster 4 was split in two.
#> Thu Sep 06 12:56:52 2018 .... Determining if any gene clusters should be split.
#> Thu Sep 06 12:56:53 2018 .... Cluster 2 was reassigned and cluster 9 was split in two.
#> Thu Sep 06 12:56:53 2018 .... Completed iteration: 10 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:53 2018 .... Completed iteration: 11 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:53 2018 .... Completed iteration: 12 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:53 2018 .... Completed iteration: 13 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:53 2018 .... Completed iteration: 14 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:53 2018 .... Completed iteration: 15 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:53 2018 .... Completed iteration: 16 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:53 2018 .... Completed iteration: 17 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:53 2018 .... Completed iteration: 18 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:53 2018 .... Completed iteration: 19 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:53 2018 .... Determining if any cell clusters should be split.
#> Thu Sep 06 12:56:53 2018 .... No additional splitting was performed.
#> Thu Sep 06 12:56:53 2018 .... Determining if any gene clusters should be split.
#> Thu Sep 06 12:56:54 2018 .... No additional splitting was performed.
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 20 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:54 2018 .. Finished chain 1 with seed 12345
#> Thu Sep 06 12:56:54 2018 .. Initializing chain 2 with 'random' (seed=12346)
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 1 | logLik: -1288484.90567663
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 2 | logLik: -1252316.73202744
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 3 | logLik: -1250339.95568952
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 4 | logLik: -1249564.71677654
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 5 | logLik: -1249563.6294892
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 6 | logLik: -1249564.31589985
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 7 | logLik: -1249563.24732323
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 8 | logLik: -1249563.4198964
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 9 | logLik: -1249563.4198964
#> Thu Sep 06 12:56:54 2018 .... Determining if any cell clusters should be split.
#> Thu Sep 06 12:56:54 2018 .... No additional splitting was performed.
#> Thu Sep 06 12:56:54 2018 .... Determining if any gene clusters should be split.
#> Thu Sep 06 12:56:54 2018 .... Cluster 1 was reassigned and cluster 5 was split in two.
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 10 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 11 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 12 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 13 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 14 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 15 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 16 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 17 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 18 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:54 2018 .... Completed iteration: 19 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:55 2018 .... Determining if any cell clusters should be split.
#> Thu Sep 06 12:56:55 2018 .... No additional splitting was performed.
#> Thu Sep 06 12:56:55 2018 .... Determining if any gene clusters should be split.
#> Thu Sep 06 12:56:55 2018 .... No additional splitting was performed.
#> Thu Sep 06 12:56:55 2018 .... Completed iteration: 20 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:55 2018 .. Finished chain 2 with seed 12346
#> Thu Sep 06 12:56:55 2018 .. Initializing chain 3 with 'random' (seed=12347)
#> Thu Sep 06 12:56:55 2018 .... Completed iteration: 1 | logLik: -1272446.65246189
#> Thu Sep 06 12:56:55 2018 .... Completed iteration: 2 | logLik: -1251530.86145074
#> Thu Sep 06 12:56:55 2018 .... Completed iteration: 3 | logLik: -1251528.38544994
#> Thu Sep 06 12:56:55 2018 .... Completed iteration: 4 | logLik: -1251523.68686302
#> Thu Sep 06 12:56:55 2018 .... Completed iteration: 5 | logLik: -1251527.44696783
#> Thu Sep 06 12:56:55 2018 .... Completed iteration: 6 | logLik: -1251522.13351871
#> Thu Sep 06 12:56:55 2018 .... Completed iteration: 7 | logLik: -1251526.73996701
#> Thu Sep 06 12:56:55 2018 .... Completed iteration: 8 | logLik: -1251529.06808316
#> Thu Sep 06 12:56:55 2018 .... Completed iteration: 9 | logLik: -1251527.40248727
#> Thu Sep 06 12:56:55 2018 .... Determining if any cell clusters should be split.
#> Thu Sep 06 12:56:55 2018 .... No additional splitting was performed.
#> Thu Sep 06 12:56:55 2018 .... Determining if any gene clusters should be split.
#> Thu Sep 06 12:56:56 2018 .... Cluster 1 was reassigned and cluster 5 was split in two.
#> Thu Sep 06 12:56:56 2018 .... Completed iteration: 10 | logLik: -1248422.30438372
#> Thu Sep 06 12:56:56 2018 .... Completed iteration: 11 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:56 2018 .... Completed iteration: 12 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:56 2018 .... Completed iteration: 13 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:56 2018 .... Completed iteration: 14 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:56 2018 .... Completed iteration: 15 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:56 2018 .... Completed iteration: 16 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:56 2018 .... Completed iteration: 17 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:56 2018 .... Completed iteration: 18 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:56 2018 .... Completed iteration: 19 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:56 2018 .... Determining if any gene clusters should be split.
#> Thu Sep 06 12:56:56 2018 .... No additional splitting was performed.
#> Thu Sep 06 12:56:56 2018 .... Completed iteration: 20 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:56 2018 .... Determining if any cell clusters should be split.
#> Thu Sep 06 12:56:56 2018 .... No additional splitting was performed.
#> Thu Sep 06 12:56:56 2018 .... Determining if any gene clusters should be split.
#> Thu Sep 06 12:56:57 2018 .... No additional splitting was performed.
#> Thu Sep 06 12:56:57 2018 .... Completed iteration: 21 | logLik: -1248355.63470669
#> Thu Sep 06 12:56:57 2018 .. Finished chain 3 with seed 12347
#> --------------------------------------------------------------------
#> Completed Celda_CG. Total time: 4.923161 secs
#> --------------------------------------------------------------------
factorized.matrices = factorizeMatrix(celda.sim$counts, celda.mod, "posterior")