\name{bgModel} \alias{bgModel} \title{Estimating the background Markov model} \description{ bgModel() obtains an estimate of the Markov model used by cosmo() for modeling the distribution of nucleotides that are not part of the motif. bgModel() can select the order of this model data-adaptively by likelihood-based cross-validation (a k-th order Markov model allows the probability of encountering the four different nucleotides in a given position to depend on the k previous nucleotides). } \usage{ bgModel(seqs, order=NULL, fold = 5, maxOrder = 6) } \arguments{ \item{seqs}{ This argument specifies the sequences that are to be used to estimate the background Markov model. If seqs == "browse", a browser appears that allows the user to select a file that contains the sequences in FASTA format. If seqs is another character string, it is assumed to give the path to a FASTA file containing the sequences of interest. Lastly, seqs may be a list with each element representing a sequence in the form of a single string such as "ACGTAGCTAG" ("seq" entry) and a description ("desc" entry).} \item{order}{\code{numerical} The order of the Markov background model. If this argument is NULL, the order is selected data-adaptively by likelihood-based cross-validation. Otherwise, a Markov model for the specified order is estimated.} \item{fold}{\code{numerical} cross-validation fold for selecting order of background Markov model} \item{maxOrder}{\code{numerical} Maximum order to consider for Markov background model.} } \details{ } \value{ A list with the folowing elements: \item{transMat}{The estimated transition matrix for the background Markov model. This is a list of matrices, with the first matrix given the transition probabilities for the 0th order Markov model, the second matrix giving the transition probabilities for a 1st order Markov model, and so on.} \item{order}{The selected order of the background Markov model.} \item{klDivs}{The Kullback-Leibler divergences for the different candidate orders for the background Markov model. Likelihood-based cross-validation selects the order with the minimum Kullback-Leibler divergence.} } \references{} \author{Oliver Bembom, \email{bembom@berkeley.edu}} \note{} \seealso{ \code{\link{cosmo}} } \examples{ ## path to example sequence file in FASTA format seqFile <- system.file("Exfiles","seq.fasta",package="cosmo") ## estimate transition matrix for order 2 tmat1 <- bgModel(seqFile, order=2) ## select order data-adaptively tmat2 <- bgModel(seqFile) } \keyword{}