Calculates the erplexity of each model's cluster assignments given the provided count matrix, as well as resamplings of that count matrix, providing a distribution of perplexities and a better sense of the quality of a given K/L choice.

calculatePerplexityWithResampling(counts, celda.list, resample = 5,
  seed = 12345)

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.list

Object of class 'celda_list'.

resample

Integer. The number of times to resample the counts matrix for evaluating perplexity. Default 5.

seed

Parameter to set.seed() for random number generation. Default 12345.

Value

celda_list. Returns the provided `celda.list` with a `perplexity` property, detailing the perplexity of all K/L combinations that appeared in the celda_list's models.

Examples

## Simulate a small dataset with 5 cell clusters and 10 feature modules celda.sim = simulateCells(model="celda_CG", K=5, L=10, G=100) ## Run various combinations of parameters with 'celdaGridSearch' cgs = celdaGridSearch(celda.sim$counts, model="celda_CG", params.test=list(K=4:6, L=9:11), params.fixed=list(sample.label=celda.sim$sample.label), best.only=TRUE, nchains=1)
#> --------------------------------------------------------------------
#> Starting celdaGridSearch with celda_CG
#> Number of cores: 1
#> --------------------------------------------------------------------
#> Error in { current.run = c(run.params[i, ]) chain.params = list() for (j in names(params.test)) { chain.params[[j]] = current.run[[j]] } chain.params$counts = counts chain.params$seed = all.seeds[ifelse(i%%nchains == 0, nchains, i%%nchains)] chain.params$max.iter = max.iter chain.params$nchain = 1 chain.params$count.checksum = count.checksum chain.params$verbose = verbose chain.params$logfile = paste0(logfile.prefix, "_", paste(paste(colnames(run.params), run.params[i, ], sep = "-"), collapse = "_"), "_Seed-", chain.params$seed, "_log.txt") res = do.call(model, c(chain.params, params.fixed)) return(list(res))}: task 1 failed - "unused argument (gamma)"
cgs = calculatePerplexityWithResampling(celda.sim$counts, cgs)
#> Error in isTRUE(class(celda.list)[1] == "celda_list"): object 'cgs' not found
#> Error in plotGridSearchPerplexity(cgs): object 'cgs' not found