selectModel: Model selection based on log likelihood

View source: R/RunModels.R

selectModelR Documentation

Model selection based on log likelihood

Description

Plots log likelihood of the different models and selects the best one based on the maximum likelihood (or specified by the user).

Usage

selectModel(
  object,
  select = NULL,
  type = "derivative",
  keepBinaryMatrix = TRUE,
  keepModels = TRUE,
  ...
)

Arguments

object

Initialized cisTopic object or list of LDA models.

select

Number of topics of the selected model. If NULL, the model with the best log likelihood is picked.

type

Method for automatic selection of the best number of topics. By default, we use 'derivative' which calculates the second derivative in each point and takes the maximum (recommended with runWarpLDAModels, where curves are less noisy). Alternatively, if set to 'maximum', the model with the maximum log-likelihood is selected (recommended with runCGSModels). For WarpLDA models, the minimum perplexity can be also used to select the best model.

keepBinaryMatrix

Whether to keep the binary accessibility matrix within the cisTopic object.

keepModels

Whether to keep all the models within the cisTopic object.

...

Ignored.

Value

Returns a cisTopic object (when the input is a cisTopic object) with the selected model stored in object@selected.model, and the log likelihoods of the models in object@log.lik. The unnormalized (when using runCGSModels) or normalized (when using runWarpLDAModels) cell assignments throughtout the sampling iterations are stored in cisTopicObject@selected.model$document_expects; while the corresponding unnormalized region assignments are stored in cisTopicObject@selected.model$topics.

Examples

bamfiles <- c('example_1.bam', 'example_2.bam', 'example_3.bam')
regions <- 'example.bed'
cisTopicObject <- CreatecisTopicObjectfromBAM(bamfiles, regions)
cisTopicObject <- runCGSModels(cisTopicObject)
cisTopicObject <- selectModel(cisTopicObject)

aertslab/cisTopic documentation built on April 6, 2024, 9:31 p.m.