| 1 |
\section{Profile SCFG construction: the \texttt{cmbuild} program} |
| 2 |
\label{section:cmbuild} |
| 3 |
\setcounter{footnote}{0} |
| 4 |
|
| 5 |
Infernal builds a model of consensus RNA secondary |
| 6 |
structure using a formalism called a \emph{covariance model} (CM), |
| 7 |
which is a type of \emph{profile stochastic context-free grammar} |
| 8 |
(profile SCFG) \citep{Eddy94,Durbin98,Eddy02b}. |
| 9 |
|
| 10 |
What follows is a technical description of what a CM is, how it |
| 11 |
corresponds to a known RNA secondary structure, and how it is built |
| 12 |
and parameterized.\footnote{Much of this text is taken from |
| 13 |
\citep{Eddy02b}.} You certainly don't have to understand the technical |
| 14 |
details of CMs to understand \prog{cmbuild} or Infernal, |
| 15 |
but it will probably help to at least skim this part. After that is a |
| 16 |
description of what the \prog{cmbuild} program does to build a CM from |
| 17 |
an input RNA multiple alignment, and how to control the behavior of |
| 18 |
the program. |
| 19 |
|
| 20 |
\subsection{Technical description of a covariance model} |
| 21 |
|
| 22 |
\subsubsection{Definition of a stochastic context free grammar} |
| 23 |
|
| 24 |
A stochastic context free grammar (SCFG) consists of the following: |
| 25 |
|
| 26 |
\begin{itemize} |
| 27 |
\item $M$ different nonterminals (here called \emph{states}). I will use capital |
| 28 |
letters to refer to specific nonterminals; $V$ and $Y$ will be used |
| 29 |
to refer generically to unspecified nonterminals. |
| 30 |
\item $K$ different terminal symbols (e.g. the observable alphabet, |
| 31 |
{a,c,g,u} for RNA). I will use small letters $a,b$ to refer |
| 32 |
generically to terminal symbols. |
| 33 |
\item a number of \emph{production rules} of the form: $V \rightarrow |
| 34 |
\gamma$, where $\gamma$ can be any string of nonterminal and/or |
| 35 |
terminal symbols, including (as a special case) the empty string |
| 36 |
$\epsilon$. |
| 37 |
\item Each production rule is associated with a probability, such that |
| 38 |
the sum of the production probabilities for any given |
| 39 |
nonterminal $V$ is equal to 1. |
| 40 |
\end{itemize} |
| 41 |
|
| 42 |
\subsubsection{SCFG productions allowed in CMs} |
| 43 |
|
| 44 |
A CM is a specific, repetitive SCFG architecture consisting of groups |
| 45 |
of model states that are associated with base pairs and |
| 46 |
single-stranded positions in an RNA secondary structure consensus. A |
| 47 |
CM has seven types of states and production rules: |
| 48 |
|
| 49 |
\vspace{0.5em} |
| 50 |
\begin{center} |
| 51 |
\begin{tabular}{lllll} |
| 52 |
State type & Description & Production & Emission & Transition\\ \hline |
| 53 |
P & (pair emitting) & $P \rightarrow a Y b$ & $e_v(a,b)$ & $t_v(Y)$ \\ |
| 54 |
L & (left emitting) & $L \rightarrow a Y$ & $e_v(a)$ & $t_v(Y)$ \\ |
| 55 |
R & (right emitting) & $R \rightarrow Y a$ & $e_v(a)$ & $t_v(Y)$ \\ |
| 56 |
B & (bifurcation) & $B \rightarrow S S$ & 1 & 1 \\ |
| 57 |
D & (delete) & $D \rightarrow Y$ & 1 & $t_v(Y)$ \\ |
| 58 |
S & (start) & $S \rightarrow Y$ & 1 & $t_v(Y)$ \\ |
| 59 |
E & (end) & $E \rightarrow \epsilon$ & 1 & 1 \\ |
| 60 |
\end{tabular} |
| 61 |
\end{center} |
| 62 |
\vspace{0.5em} |
| 63 |
|
| 64 |
Each overall production probability is the independent product of an |
| 65 |
emission probability $e_v$ and a transition probability $t_v$, both of |
| 66 |
which are position-dependent parameters that depend on the state $v$ |
| 67 |
(analogous to hidden Markov models). For example, a particular pair |
| 68 |
(P) state $v$ produces two correlated letters $a$ and $b$ (e.g. one of |
| 69 |
16 possible base pairs) with probability $e_v(a,b)$ and transits to |
| 70 |
one of several possible new states $Y$ of various types with |
| 71 |
probability $t_v(Y)$. A bifurcation (B) state splits into two new |
| 72 |
start ($S$) states with probability 1. The E state is a special case |
| 73 |
$\epsilon$ production that terminates a derivation. |
| 74 |
|
| 75 |
A CM consists of many states of these seven basic types, each with its |
| 76 |
own emission and transition probability distributions, and its own set |
| 77 |
of states that it can transition to. Consensus base pairs will be |
| 78 |
modeled by P states, consensus single stranded residues by L and R |
| 79 |
states, insertions relative to the consensus by more L and R states, |
| 80 |
deletions relative to consensus by D states, and the branching |
| 81 |
topology of the RNA secondary structure by B, S, and E states. The |
| 82 |
procedure for starting from an input multiple alignment and |
| 83 |
determining how many states, what types of states, and how they are |
| 84 |
interconnected by transition probabilities is described next. |
| 85 |
|
| 86 |
\subsubsection{From consensus structural alignment to guide tree} |
| 87 |
|
| 88 |
Figure~\ref{fig:input_alignment} shows an example input file: a |
| 89 |
multiple sequence alignment of homologous RNAs, with a line in WUSS |
| 90 |
notation that describes the consensus RNA secondary structure. The |
| 91 |
first step of building a CM is to produce a binary \emph{guide tree} |
| 92 |
of \emph{nodes} representing the consensus secondary structure. The |
| 93 |
guide tree is a parse tree for the consensus structure, with nodes as |
| 94 |
nonterminals and alignment columns as terminals. |
| 95 |
|
| 96 |
\begin{figure}[t] |
| 97 |
\begin{center} |
| 98 |
\includegraphics[scale=0.8]{Figures/input_alignment} |
| 99 |
\end{center} |
| 100 |
\caption{\small\textbf{An example RNA sequence family.} Left: a toy multiple |
| 101 |
alignment of three sequences, with 28 total columns, 24 of which will |
| 102 |
be modeled as consensus positions. The [structure] line annotates the |
| 103 |
consensus secondary structure in WUSS notation. |
| 104 |
Right: the secondary structure of the ``human'' sequence.} |
| 105 |
\label{fig:input_alignment} |
| 106 |
\end{figure} |
| 107 |
|
| 108 |
The guide tree has eight types of nodes: |
| 109 |
|
| 110 |
\vspace{0.5em} |
| 111 |
\begin{center} |
| 112 |
\begin{tabular}{lll} |
| 113 |
Node & Description & Main state type \\ \hline |
| 114 |
MATP & (pair) & P \\ |
| 115 |
MATL & (single strand, left) & L \\ |
| 116 |
MATR & (single strand, right) & R \\ |
| 117 |
BIF & (bifurcation) & B \\ |
| 118 |
ROOT & (root) & S \\ |
| 119 |
BEGL & (begin, left) & S \\ |
| 120 |
BEGR & (begin, right) & S \\ |
| 121 |
END & (end) & E \\ |
| 122 |
\end{tabular} |
| 123 |
\end{center} |
| 124 |
\vspace{0.5em} |
| 125 |
|
| 126 |
These consensus node types correspond closely with the CM's final |
| 127 |
state types. Each node will eventually contain one or more states. The |
| 128 |
guide tree deals with the consensus structure. For individual |
| 129 |
sequences, we will need to deal with insertions and deletions with |
| 130 |
respect to this consensus. The guide tree is the skeleton on which we |
| 131 |
will organize the CM. For example, a MATP node will contain a P-type |
| 132 |
state to model a consensus base pair; but it will also contain several |
| 133 |
other states to model infrequent insertions and deletions at or |
| 134 |
adjacent to this pair. |
| 135 |
|
| 136 |
The input alignment is first used to construct a consensus secondary |
| 137 |
structure (Figure~\ref{fig:cm_nodetree}) that defines which aligned |
| 138 |
columns will be ignored as non-consensus (and later modeled as |
| 139 |
insertions relative to the consensus), and which consensus alignment |
| 140 |
columns are base-paired to each other. For the purposes of this |
| 141 |
description, I assume that both the structural annotation and the |
| 142 |
labeling of insert versus consensus columns is given in the input |
| 143 |
file, as shown in the alignment in Figure~\ref{fig:input_alignment}, |
| 144 |
where both are are indicated by the WUSS notation in the [structure] |
| 145 |
line (where, e.g., insert columns are marked with \otext{.}). (In |
| 146 |
practice, \prog{cmbuild} does need secondary structure annotation, but |
| 147 |
it doesn't require insert/consensus annotation or full WUSS notation |
| 148 |
in its input alignment files; this would require a lot of manual |
| 149 |
annotation. More on this later.) |
| 150 |
|
| 151 |
\begin{figure}[t] |
| 152 |
\begin{center} |
| 153 |
\includegraphics[width=5in]{Figures/cm_nodetree} |
| 154 |
\end{center} |
| 155 |
\caption{\small\textbf{The structural alignment is converted to a guide |
| 156 |
tree.} Left: the consensus secondary structure is derived from the |
| 157 |
annotated alignment in Figure~\ref{fig:input_alignment}. Numbers in |
| 158 |
the circles indicate alignment column coordinates: e.g. column 4 base |
| 159 |
pairs with column 14, and so on. Right: the CM guide tree |
| 160 |
corresponding to this consensus structure. The nodes of the tree are |
| 161 |
numbered 1..24 in preorder traversal (see text). MATP, MATL, and MATR |
| 162 |
nodes are associated with the columns they generate: e.g., node 6 is a |
| 163 |
MATP (pair) node that is associated with the base-paired columns 4 and |
| 164 |
14.} |
| 165 |
\label{fig:cm_nodetree} |
| 166 |
\end{figure} |
| 167 |
|
| 168 |
Given the consensus structure, consensus base pairs are assigned to |
| 169 |
MATP nodes and consensus unpaired columns are assigned to MATL or MATR |
| 170 |
nodes. One ROOT node is used at the head of the tree. Multifurcation |
| 171 |
loops and/or multiple stems are dealt with by assigning one or more |
| 172 |
BIF nodes that branch to subtrees starting with BEGL or BEGR head |
| 173 |
nodes. (ROOT, BEGL, and BEGR start nodes are labeled differently |
| 174 |
because they will be expanded to different groups of states; this has |
| 175 |
to do with avoiding ambiguous parse trees for individual sequences, as |
| 176 |
described below.) Alignment columns that are considered to be |
| 177 |
insertions relative to the consensus structure are ignored at this |
| 178 |
stage. |
| 179 |
|
| 180 |
In general there will be more than one possible guide tree for any |
| 181 |
given consensus structure. Almost all of this ambiguity is eliminated |
| 182 |
by three conventions: (1) MATL nodes are always used instead of MATR |
| 183 |
nodes where possible, for instance in hairpin loops; (2) in describing |
| 184 |
interior loops, MATL nodes are used before MATR nodes; and (3) BIF |
| 185 |
nodes are only invoked where necessary to explain branching secondary |
| 186 |
structure stems (as opposed to unnecessarily bifurcating in single |
| 187 |
stranded sequence). One source of ambiguity remains. In invoking a |
| 188 |
bifurcation to explain alignment columns $i..j$ by two substructures |
| 189 |
on columns $i..k$ and $k+1..j$, there will be more than one possible |
| 190 |
choice of $k$ if $i..j$ is a multifurcation loop containing three or |
| 191 |
more stems. The choice of $k$ impacts the performance of the divide |
| 192 |
and conquer algorithm; for optimal time performance, we will want |
| 193 |
bifurcations to split into roughly equal sized alignment problems, so |
| 194 |
I choose the $k$ that makes $i..k$ and $k+1..j$ as close to the same |
| 195 |
length as possible. |
| 196 |
|
| 197 |
The result of this procedure is the guide tree. The nodes of the guide |
| 198 |
tree are numbered in preorder traversal (e.g. a recursion of ``number |
| 199 |
the current node, visit its left child, visit its right child'': thus |
| 200 |
parent nodes always have lower indices than their children). The guide |
| 201 |
tree corresponding to the input multiple alignment in |
| 202 |
Figure~\ref{fig:input_alignment} is shown in |
| 203 |
Figure~\ref{fig:cm_nodetree}. |
| 204 |
|
| 205 |
\subsubsection{From guide tree to covariance model} |
| 206 |
|
| 207 |
A CM must deal with insertions and deletions in individual sequences |
| 208 |
relative to the consensus structure. For example, for a consensus base |
| 209 |
pair, either partner may be deleted leaving a single unpaired residue, |
| 210 |
or the pair may be entirely deleted; additionally, there may be |
| 211 |
inserted nonconsensus residues between this pair and the next pair in |
| 212 |
the stem. Accordingly, each node in the master tree is expanded into |
| 213 |
one or more \emph{states} in the CM as follows: |
| 214 |
|
| 215 |
\vspace{0.5em} |
| 216 |
\begin{center} |
| 217 |
\begin{tabular}{llccc} |
| 218 |
& & total \#& \# of split& \# of insert\\ |
| 219 |
Node & States & states & states & states \\ \hline |
| 220 |
MATP & [MP ML MR D] IL IR & 6 & 4 & 2 \\ |
| 221 |
MATL & [ML D] IL & 3 & 2 & 1 \\ |
| 222 |
MATR & [MR D] IR & 3 & 2 & 1 \\ |
| 223 |
BIF & [B] & 1 & 1 & 0 \\ |
| 224 |
ROOT & [S] IL IR & 3 & 1 & 2 \\ |
| 225 |
BEGL & [S] & 1 & 1 & 0 \\ |
| 226 |
BEGR & [S] IL & 2 & 1 & 1 \\ |
| 227 |
END & [E] & 1 & 1 & 0 \\ \hline |
| 228 |
\end{tabular} |
| 229 |
\end{center} |
| 230 |
\vspace{0.5em} |
| 231 |
|
| 232 |
Here we distinguish between consensus (``M'', for ``match'') states |
| 233 |
and insert (``I'') states. ML and IL, for example, are both L type |
| 234 |
states with L type productions, but they will have slightly different |
| 235 |
properties, as described below. |
| 236 |
|
| 237 |
The states are grouped into a \emph{split set} of 1-4 states (shown in |
| 238 |
brackets above) and an \emph{insert set} of 0-2 insert states. The |
| 239 |
split set includes the main consensus state, which by convention is |
| 240 |
first. One and only one of the states in the split set must be visited |
| 241 |
in every parse tree (and this fact will be exploited by the divide and |
| 242 |
conquer algorithm). The insert state(s) are not obligately visited, |
| 243 |
and they have self-transitions, so they will be visited zero or more |
| 244 |
times in any given parse tree. |
| 245 |
|
| 246 |
State transitions are then assigned as follows. For bifurcation nodes, |
| 247 |
the B state makes obligate transitions to the S states of the child |
| 248 |
BEGL and BEGR nodes. For other nodes, each state in a split set has a |
| 249 |
possible transition to every insert state in the \emph{same} node, and |
| 250 |
to every state in the split set of the \emph{next} node. An IL state |
| 251 |
makes a transition to itself, to the IR state in the same node (if |
| 252 |
present), and to every state in the split set of the next node. An IR |
| 253 |
state makes a transition to itself and to every state in the split set |
| 254 |
of the next node. |
| 255 |
|
| 256 |
There is one exception to this arrangement of transitions: insert |
| 257 |
states that are immediately before an END node are effectively |
| 258 |
\emph{detached} from the model by making transitions into them |
| 259 |
impossible. This inelegant solution was imposed on the CM model |
| 260 |
building procedure to fix a design flaw that allowed an ambiguity in |
| 261 |
the determination of a parsetree given a structure. The detachment of |
| 262 |
these special insert states removes this ambiguity. |
| 263 |
|
| 264 |
This arrangement of transitions guarantees that (given the guide tree) |
| 265 |
there is unambiguously one and only one parse tree for any given |
| 266 |
individual structure. This is important. The algorithm will find a |
| 267 |
maximum likelihood parse tree for a given sequence, and we wish to |
| 268 |
interpret this result as a maximum likelihood structure, so there must |
| 269 |
be a one to one relationship between parse trees and secondary |
| 270 |
structures \citep{Giegerich00}. |
| 271 |
|
| 272 |
The final CM is an array of $M$ states, connected as a directed graph |
| 273 |
by transitions $t_v(y)$ (or probability 1 transitions $v \rightarrow |
| 274 |
(y,z)$ for bifurcations) with the states numbered such that $(y,z) |
| 275 |
\geq v$. There are no cycles in the directed graph other than cycles |
| 276 |
of length one (e.g. the self-transitions of the insert states). We can |
| 277 |
think of the CM as an array of states in which all transition |
| 278 |
dependencies run in one direction; we can do an iterative dynamic |
| 279 |
programming calculation through the model states starting with the |
| 280 |
last numbered end state $M$ and ending in the root state $1$. An |
| 281 |
example CM, corresponding to the input alignment of |
| 282 |
Figure~\ref{fig:input_alignment}, is shown in |
| 283 |
Figure~\ref{fig:cm_graph}. |
| 284 |
|
| 285 |
As a convenient side effect of the construction procedure, it is |
| 286 |
guaranteed that the transitions from any state are to a |
| 287 |
\emph{contiguous} set of child states, so the transitions for state |
| 288 |
$v$ may be kept as an offset and a count. For example, in |
| 289 |
Figure~\ref{fig:cm_graph}, state 12 (an MP) connects to states 16, 17, |
| 290 |
18, 19, 20, and 21. We can store this as an offset of 4 to the first |
| 291 |
connected state, and a total count of 6 connected states. We know |
| 292 |
that the offset is the distance to the next non-split state in the |
| 293 |
current node; we also know that the count is equal to the number of |
| 294 |
insert states in the current node, plus the number of split set states |
| 295 |
in the next node. These properties make establishing the connectivity |
| 296 |
of the CM trivial. Similarly, all the parents of any given state are |
| 297 |
also contiguously numbered, and can be determined analogously. We are |
| 298 |
also guaranteed that the states in a split set are numbered |
| 299 |
contiguously. This contiguity is exploited by the divide and conquer |
| 300 |
implementation. |
| 301 |
|
| 302 |
\begin{figure}[tp] |
| 303 |
\begin{center} |
| 304 |
\includegraphics[width=5in]{Figures/cm_graph} |
| 305 |
\end{center} |
| 306 |
\caption{\small\textbf{A complete covariance model.} Right: the CM |
| 307 |
corresponding to the alignment in Figure~\ref{fig:input_alignment}. |
| 308 |
The model has 81 states (boxes, stacked in a vertical array). Each |
| 309 |
state is associated with one of the 24 nodes of the guide tree (text |
| 310 |
to the right of the state array). States corresponding to the |
| 311 |
consensus are in white. States responsible for insertions and |
| 312 |
deletions are gray. The transitions from bifurcation state B10 to |
| 313 |
start states S11 and S46 are in bold because they are special: they |
| 314 |
are an obligate (probability 1) bifurcation. All other transitions |
| 315 |
(thin arrows) are associated with transition probabilities. Emission |
| 316 |
probability distributions are not represented in the figure. Left: the |
| 317 |
states are also arranged according to the guide tree. A blow up of |
| 318 |
part of the model corresponding to nodes 6, 7, and 8 shows |
| 319 |
more clearly the logic of the connectivity of transition probabilities |
| 320 |
(see main text), and also shows why any parse tree must transit through |
| 321 |
one and only one state in each ``split set''.} |
| 322 |
\label{fig:cm_graph} |
| 323 |
\end{figure} |
| 324 |
|
| 325 |
\subsubsection{Parameterization} |
| 326 |
|
| 327 |
Using the guide tree and the final CM, each individual sequence in the |
| 328 |
input multiple alignment can be converted unambiguously to a CM parse |
| 329 |
tree, as shown in Figure~\ref{fig:parsetrees}. Weighted counts for |
| 330 |
observed state transitions and singlet/pair emissions are then |
| 331 |
collected from these parse trees. These counts are converted to |
| 332 |
transition and emission probabilities, as maximum \emph{a posteriori} |
| 333 |
estimates using mixture Dirichlet priors |
| 334 |
\citep{Sjolander96,Durbin98,NawrockiEddy07}. |
| 335 |
|
| 336 |
\begin{figure}[t] |
| 337 |
\begin{center} |
| 338 |
\includegraphics[width=5in]{Figures/parsetrees} |
| 339 |
\end{center} |
| 340 |
\caption{\small\textbf{Example parse trees.} Parse trees are shown for the |
| 341 |
three sequences/structures from Figure~\ref{fig:input_alignment}, |
| 342 |
given the CM in Figure~\ref{fig:cm_graph}. For each sequence, each |
| 343 |
residue must be associated with a state in the parse tree. (The |
| 344 |
sequences can be read off its parse tree by starting at the upper left |
| 345 |
and reading counterclockwise around the edge of parse tree.) Each |
| 346 |
parse tree corresponds directly to a secondary structure -- base pairs |
| 347 |
are pairs of residues aligned to MP states. A collection of parse |
| 348 |
trees also corresponds to a multiple alignment, by aligning residues |
| 349 |
that are associated with the same state -- for example, all three |
| 350 |
trees have a residue aligned to state ML4, so these three residues |
| 351 |
would be aligned together. Insertions and deletions relative to the |
| 352 |
consensus use nonconsensus states, shown in gray.} |
| 353 |
\label{fig:parsetrees} |
| 354 |
\end{figure} |
| 355 |
|
| 356 |
\subsubsection{Comparison to profile HMMs} |
| 357 |
|
| 358 |
The relationship between an SCFG and a covariance model is analogous |
| 359 |
to the relationship of hidden Markov models (HMMs) and profile HMMs |
| 360 |
for modeling multiple sequence alignments |
| 361 |
\citep{Krogh94,Durbin98,Eddy98}. A comparison may be instructive to |
| 362 |
readers familiar with profile HMMs. A profile HMM is a repetitive HMM |
| 363 |
architecture that associates each consensus column of a multiple |
| 364 |
alignment with a single type of model node -- a MATL node, in the |
| 365 |
above notation. Each node contains a ``match'', ``delete'', and |
| 366 |
``insert'' HMM state -- ML, IL, and D states, in the above notation. |
| 367 |
The profile HMM also has special begin and end states. Profile HMMs |
| 368 |
could therefore be thought of as a special case of CMs. An |
| 369 |
unstructured RNA multiple alignment would be modeled by a guide tree |
| 370 |
of all MATL nodes, and converted to an unbifurcated CM that would |
| 371 |
essentially be identical to a profile HMM. (The only difference is |
| 372 |
trivial; the CM root node includes a IR state, whereas the start node |
| 373 |
of a profile HMM does not.) All the other node types (especially MATP, |
| 374 |
MATR, and BIF) and state types (e.g. MP, MR, IR, and B) are SCFG |
| 375 |
augmentations necessary to extend profile HMMs to deal with RNA |
| 376 |
secondary structure. |
| 377 |
|
| 378 |
|
| 379 |
\subsection{The \prog{cmbuild} program, step by step} |
| 380 |
%\addtocontents{faq}{\textbf{Questions about using cmbuild:}} |
| 381 |
|
| 382 |
The \prog{cmbuild} command line syntax is: |
| 383 |
|
| 384 |
\user{cmbuild <options> [cmfile] [alifile]} |
| 385 |
|
| 386 |
where \prog{[alifile]} is the name of the input alignment file, and |
| 387 |
\prog{[cmfile]} is the name of the output CM file. What follows |
| 388 |
describes the steps that \prog{cmbuild} goes through, and the most |
| 389 |
important options that can be chosen to affect its behavior. |
| 390 |
|
| 391 |
\subsubsection{Alignment input file} |
| 392 |
|
| 393 |
The input alignment file must be in Stockholm format, and it must have |
| 394 |
a consensus secondary structure annotation line (\otext{\#=GC SS\_cons}). |
| 395 |
|
| 396 |
The program is actually capable of reading many common multiple |
| 397 |
alignment formats (ClustalW, PHYLIP, GCG MSF, and others) but no other |
| 398 |
format currently supports consensus RNA secondary structure |
| 399 |
annotation. This may change in the future, either when other formats |
| 400 |
allow structure annotation, or when \prog{cmbuild} is capable of |
| 401 |
inferring consensus structure from the alignment by automated |
| 402 |
comparative analysis, as the earlier COVE suite was capable |
| 403 |
of \citep{Eddy94}. |
| 404 |
|
| 405 |
If the file does not exist, is not readable, or is not in a recognized |
| 406 |
format, the program exits with a ``Alignment file doesn't exist or is |
| 407 |
not readable'' error. If the file does not have consensus secondary |
| 408 |
structure annotation, the program exits with a ``no consensus |
| 409 |
structure annotation'' error. This includes all non-Stockholm |
| 410 |
alignment files. |
| 411 |
|
| 412 |
% EPN, Wed Apr 2 12:47:54 2008, the cat my.sto | cmbuild command |
| 413 |
% in this faq no longer works. |
| 414 |
\begin{srefaq}{Why does \prog{cmbuild} have a \prog{--informat} option, if it only |
| 415 |
accepts Stockholm?} If you don't specify \prog{--informat}, the |
| 416 |
software has to autodetect the file format. Autodetection of file |
| 417 |
formats doesn't work in certain advanced/nonstandard cases, for |
| 418 |
instance if you're reading the alignment from standard input instead |
| 419 |
of from a file. The \prog{--informat} allows you to override |
| 420 |
autodetection; e.g. \prog{cat my.sto | cmbuild --informat Stockholm |
| 421 |
my.cm -} is an example of reading the alignment from piped standard |
| 422 |
input. |
| 423 |
\end{srefaq} |
| 424 |
|
| 425 |
\subsubsection{Parsing secondary structure annotation} |
| 426 |
|
| 427 |
The structure annotation line only needs to indicate which columns are |
| 428 |
base paired to which. It does not have to be in full WUSS notation. |
| 429 |
Even if it is, the details of the notation are largely ignored. |
| 430 |
Nested pairs of \otext{<>}, \otext{()}, \otext{[]}, or \otext{{}} symbols |
| 431 |
are interpreted as base paired columns. All other columns marked with |
| 432 |
the symbols \otext{:,\_-.~} are interpreted as single stranded columns. |
| 433 |
|
| 434 |
A simple minimal annotation is therefore to use \otext{<>} symbols to |
| 435 |
mark base pairs and \otext{.} for single stranded columns. |
| 436 |
|
| 437 |
If a secondary structure annotation line is in WUSS notation and it |
| 438 |
contains valid pseudoknot annotation (e.g.\ additional non-nested |
| 439 |
stems marked with AAA,aaa or BBB,bbb, etc.), this annotation is |
| 440 |
ignored because Infernal cannot handle |
| 441 |
pseudoknots. Internally, these columns are treated as if they were |
| 442 |
marked with \otext{.} symbols. |
| 443 |
|
| 444 |
\begin{srefaq}{How should I choose to annotate pseudoknots?} |
| 445 |
Infernal can only deal with nested base pairs. If there is |
| 446 |
a pseudoknot, you have to make a choice of which stem to annotate as |
| 447 |
normal nested structure (thus including it in the model) and which |
| 448 |
stem to call additional ``pseudoknotted'' structure (thus ignoring it |
| 449 |
in the model). For example, for a simple two-stem pseudoknot, should |
| 450 |
you annotate it as \otext{AAAA.<<<<aaaa....>>>>}, or |
| 451 |
\otext{<<<<.AAAA>>>>....aaaa}? From an RNA structure viewpoint, which |
| 452 |
stem I label as the pseudoknotted one is an arbitrary choice; but |
| 453 |
since one of the stems in the pseudoknot will have to be modeled as a |
| 454 |
single stranded region by Infernal, the choice makes a |
| 455 |
slight difference in the performance of your model. You want your |
| 456 |
model to capture as much information content as possible. Thus, since |
| 457 |
the information content of the model is a sum of the sequence |
| 458 |
conservation plus the additional information contributed by pairwise |
| 459 |
correlations in base-paired positions, you should tend to annotate the |
| 460 |
shorter stem as the ``pseudoknot'' (modeling as many base pairs as |
| 461 |
possible), and you should also annotate the stem with the more |
| 462 |
conserved primary sequence as the ``pseudoknot'' (if one stem is more |
| 463 |
conserved at the sequence level, you won't lose as much by modeling |
| 464 |
that one as primary sequence consensus only). |
| 465 |
\end{srefaq} |
| 466 |
|
| 467 |
If (aside from any ignored pseudoknot annotation) the structure |
| 468 |
annotation line contains characters other than \otext{<>()[]{}:\_-,.~} |
| 469 |
then those characters are ignored (treated as \otext{.}) and a warning |
| 470 |
is printed. |
| 471 |
|
| 472 |
If, after this ``data cleaning'', the structure annotation is |
| 473 |
inconsistent with a secondary structure (for example, if the number of |
| 474 |
\otext{<} and \otext{>} characters isn't the same), then the program |
| 475 |
exits with a ``failed to parse consensus structure annotation'' error. |
| 476 |
|
| 477 |
\subsubsection{Sequence weighting} |
| 478 |
|
| 479 |
By default, the input sequences are weighted in two ways to compensate |
| 480 |
for biased sampling (phylogenetic correlations). Relative sequence |
| 481 |
weights are calculated by the Henikoff position-based method. |
| 482 |
\citep{Henikoff94b}. (The \prog{--wpb} option forces position-based |
| 483 |
weights, but is redundant since that's the default.) To turn relative |
| 484 |
weighting off (e.g. set all weights to 1.0), use the \prog{--wnone} |
| 485 |
option. |
| 486 |
|
| 487 |
Some alignment file formats allow relative sequence weights to be |
| 488 |
given in the file. This includes Stockholm format, which has |
| 489 |
\otext{\#=GS WT} weight annotations. Normally \prog{cmbuild} ignores any |
| 490 |
such input weights. The \prog{--wgiven} option tells \prog{cmbuild} |
| 491 |
to use them. This lets you set the weights with any external |
| 492 |
procedure you like; for example, the \prog{esl-weight} utility program in |
| 493 |
Easel\footnote{This program will be in |
| 494 |
\ccode{infernal/easel/miniapps/} after building Infernal.} |
| 495 |
implements some common weighting algorithms, |
| 496 |
including the Gerstein/Sonnhammer/Chothia weighting scheme |
| 497 |
\citep{Gerstein94}. |
| 498 |
|
| 499 |
Absolute weights (the ``effective sequence number'') is calculate by |
| 500 |
``entropy weighting'' \citep{Karplus98}. This sets the balance between |
| 501 |
the prior and the data, and affects the information content of the |
| 502 |
model. Entropy weighting reduces the effective sequence number (the |
| 503 |
total sum of the weights) and increases the entropy (degrading the |
| 504 |
information content) of the model until a threshold is reached. The |
| 505 |
default entropy is 1.41 bits per position (roughly 0.59 bits of |
| 506 |
information, relative to uniform base composition). This threshold can |
| 507 |
be changed with the \prog{--ere <x>} option. Entropy weighting may |
| 508 |
be turned off entirely with the \prog{--enone} option. |
| 509 |
|
| 510 |
|
| 511 |
\subsubsection{Architecture construction} |
| 512 |
|
| 513 |
The CM architecture is now constructed from your input alignment and |
| 514 |
your secondary structure annotation, as described in the previous |
| 515 |
section. |
| 516 |
|
| 517 |
The program needs to determine which columns are consensus (match) |
| 518 |
columns, and which are insert columns. (Remember that although WUSS |
| 519 |
notation allows insertions to be annotated in the secondary structure |
| 520 |
line, \prog{cmbuild} is only paying attention to annotated base |
| 521 |
pairs.) By default, it does this by a simple rule based on the |
| 522 |
frequency of residues (non-gaps) in a column. If the frequency of |
| 523 |
residues is lower than a threshold, the column is considered to be |
| 524 |
an insertion. Importantly though this frequency is determined using |
| 525 |
the relative weights from the sequence weighting step, instead of |
| 526 |
absolute gaps (e.g. a residue in a sequence with weight $0.8$ will count |
| 527 |
as $0.8$ residues). |
| 528 |
|
| 529 |
The threshold defaults to 0.5. It can be changed to another number |
| 530 |
\otext{<x>} (from 0 to 1.0) by the \prog{--symfrac <x>} option. The |
| 531 |
lower the number, the more columns are included in the model. At |
| 532 |
\prog{--symfrac 0.0}, all the columns are considered to be part of |
| 533 |
the consensus. At \prog{--symfrac 1.0}, only columns with no gaps are. |
| 534 |
|
| 535 |
You can also manually specify which columns are consensus versus |
| 536 |
insert by including reference coordinate annotation (e.g. a |
| 537 |
\otext{\#=GC RF} line, in Stockholm format) and using the |
| 538 |
\prog{--hand} option. There's an example of this in the tutorial. Any |
| 539 |
columns marked by non-gap symbols become consensus columns. (The |
| 540 |
simplest thing to do is mark consensus columns with x's, and insert |
| 541 |
columns with \otext{.}'s. Remember that spaces aren't allowed in |
| 542 |
alignments in Stockholm format.) If you set the \prog{--hand} option but |
| 543 |
your file doesn't have reference coordinate annotation, the program |
| 544 |
exits with an error. |
| 545 |
|
| 546 |
\subsubsection{Parameterization} |
| 547 |
|
| 548 |
Weighted observed emission and transition counts are then collected |
| 549 |
from the alignment data. These count vectors $c$ are then converted to |
| 550 |
estimated probabilities $p$ using mixture Dirichlet priors |
| 551 |
\citep{Sjolander96, Durbin98, NawrockiEddy07}. You can provide your |
| 552 |
own prior as a file, using the \prog{--prior <f>} option. |
| 553 |
|
| 554 |
As an exception, insert state emission probabilities are not learned |
| 555 |
from the counts from implicit parse trees of sequences in the input |
| 556 |
alignment, instead they are all set to 0.25 for each of the four RNA |
| 557 |
nucleotides. Another exception is made for transition counts in |
| 558 |
ROOT\_IL and ROOT\_IR states from the implicit parsetrees. Any |
| 559 |
transition counts in these states are \emph{ignored} by the |
| 560 |
construction procedure -- they are set to zero before the transition |
| 561 |
probability parameters for these states are determined. |
| 562 |
|
| 563 |
\subsubsection{Naming the model} |
| 564 |
|
| 565 |
Each CM gets a name. Stockholm format allows the alignment to have a |
| 566 |
name, provided in the \otext{\#=GF ID} tag. If this name is provided, |
| 567 |
it is used as the CM name. |
| 568 |
|
| 569 |
Stockholm format allows more than one alignment per file, and |
| 570 |
\prog{cmbuild} supports this: CM files can contain more than one |
| 571 |
model, and if you say e.g.\ \prog{cmbuild Rfam.cm Rfam.sto} where |
| 572 |
\otext{Rfam.sto} contains a whole database of alignments, |
| 573 |
\prog{cmbuild} will create a database of CMs in the \prog{Rfam.cm} file, |
| 574 |
one per alignment. |
| 575 |
|
| 576 |
If a name is not provided in the Stockholm \otext{\#=GF ID} |
| 577 |
annotation, the name given to each CM is the input filename. This will |
| 578 |
not work if the alignment file has more than one alignment. In that |
| 579 |
case, you must include names for each alignment. |
| 580 |
|
| 581 |
If the alignment file only has 1 alignment in it, you can override the |
| 582 |
automatic naming conventions and provide your own name with the \prog{-n <s>} |
| 583 |
option, where \prog{<s>} is any string. |
| 584 |
|
| 585 |
\subsubsection{Saving the model} |
| 586 |
|
| 587 |
The model is now saved to a file, according to the filename specified |
| 588 |
on the command line. By default, a new file is created, and the model |
| 589 |
is saved in a portable ASCII text format. This format is described in |
| 590 |
section~\ref{section:formats} of this guide. |
| 591 |
|
| 592 |
If the cmfile already exists, the program exits with an error. The |
| 593 |
\prog{-F} option causes the new model to overwrite an existing |
| 594 |
cmfile. |
| 595 |
|
| 596 |
|