Statistical mechanics of ontology based annotations

We present a statistical mechanical theory of the process of annotating an object with terms selected from an ontology. The term selection process is formulated as an ideal lattice gas model, but in a highly structured inhomogeneous field. The model enables us to explain patterns recently observed in real-world annotation data sets, in terms of the underlying graph structure of the ontology. By relating the external field strengths to the information content of each node in the ontology graph, the statistical mechanical model also allows us to propose a number of practical metrics for assessing the quality of both the ontology, and the annotations that arise from its use. Using the statistical mechanical formalism we also study an ensemble of ontologies of differing size and complexity; an analysis not readily performed using real data alone. Focusing on regular tree ontology graphs we uncover a rich set of scaling laws describing the growth in the optimal ontology size as the number of objects being annotated increases. In doing so we provide a further possible measure for assessment of ontologies.


Introduction
With larger and more complex data sets becoming increasingly common, the annotation of data in order to semantically enrich it is a crucial task within data science [1,2]. For example, in molecular biology a gene can be annotated by domain experts with terms, t, from a controlled vocabulary, thereby allowing other researchers to comprehend the function and role of that gene. Similarly, user tagging of information sources such as documents, photographs, or online content, provide additional meta-data and lead to emergent but uncontrolled vocabularies (often called folksonomies [3]). Terms within a vocabulary can be further organized in a hierarchical structure such as a taxonomy [1], in which terms closer to the root of the hierarchy are less specific than those further from the root. Hierarchical organization of vocabulary terms can also be used to specify richer semantic relationships between terms -richer than just indicating that one term is a simply a sub-type of another. These richer hierarchical semantic structures are generally called ontologies [4].
The annotations that result from an ontology or taxonomy can exhibit interesting patterns. For example, Kalankesh et al. [5] have shown that distributions of term frequencies, f t , taken from Gene Ontology (GO) [6] annotations typically follow Zipf's law [7,8]. Figure 1 shows a Zipf's law plot for annotations taken from the cellular component sub-ontology of GO. The schematic on the right-hand side of Fig.1 shows, for illustration, part of the ontology that was used to produce the annotation data set plotted on the left-hand side of Fig.1. Statistical mechanics provides us with a natural tool to understand these annotation patterns, by allowing us to develop a formalism that quantifies both the natural variations in the annotation process, and the ontology structure itself. Although structure-based measures of ontologies already exist [9], within this work we are quantifying the ontology structure from the perspective of the annotations that arise, rather than simply quantifying the ontology structure in isolation. The goals, and ultimately the benefits, of developing a statistical mechanics based formalism are both practical and theoretical.

Ontologies as information stores
Ontologies and taxonomies, whether formally constructed or emergent, represent a store of information. Organizing a hierarchical store of information requires effort to be expended to create an ordered structure. Work by Ferrer i Cancho et al., within an information theoretic framework, has shown how heavy tailed and essentially hierarchical patterns of term usage can arise simply from a principle of minimizing the communication effort expended when using those terms [10,11,12]. Within this current paper we also use information theoretic ideas, but it is the process of transferring information from an ontology to an annotated object that we study, i.e., after the hierarchical term structure has been determined or prescribed. We do so using an explicit statistical mechanical model that takes into the structure of the ontology. Whilst existing work within the literature has used a specific Hamiltonian to study patterns of word usage, that work has not per se been interested in the impact of any underlying  prescribed structure in the vocabulary [13]. Similarly, novel work by Palla et al. [14] and Tibély et al. [15] has related tag usage patterns to ontology structure, but focused on an in depth study of observed tag patterns, rather than taking a Hamiltonian model based approach.
The remainder of this paper is organized as follows -in Section 2 we express the annotation process as an ideal lattice gas model in an inhomogeneous field. In Section 3.1 we use the lattice gas model to understand the term frequency patterns seen by Kalankesh et al. [5], and we identify, LD t , the number of leaf descendants of a node t, as the key quantity controlling the expected term usage frequencies. In Section 4 we derive the most likely natural form for the inhomogeneous field strength, thereby giving rise to a local measure of the ontology. This natural form for the inhomogeneous field also allows us, in Section 5, to construct an ensemble of ontologies of differing complexity. By restricting the ensemble to the class of regular trees we reveal in Section 5.2 a set of transitions in the optimal tree size, and associated scaling laws, as the number of objects being annotated is increased. Finally in Section 6 we discuss a number of possible extensions of the statistical mechanical approach to quantifying ontology structures.

Statistical mechanical theory of the annotation process
We consider an ontology to be represented by a rooted Directed Acyclic Graph (DAG) [16,17]. An example DAG, in this case a tree, is shown in Figure  2. Real-world ontologies are typically not pure trees, and we use a tree structure simply for illustrative purposes. The formalism we develop in this section will be equally applicable to any valid DAG structure. Associated with each node of the DAG is a particular term, and we use node and term interchangeably.
The directed edges between nodes of the DAG indicates that the child node conveys a possibly more specific meaning than the parent node, or represents a more specific subset of objects. For such an increase in specificity to occur the ontology topology must be ultimately be tree-like. Clearly, if a particular  Figure 2: Left hand schematic shows an example (tree) DAG representing an ontology. The nodes represent terms, denoted by t 1 − t 12 , which may be selected to annotate objects that belong to classes represented by the leaves of the DAG. Each leaf corresponds to a unique set of paths from the root, and so we denote the classes by P 1 − P 7 . The directed edges of the DAG indicate semantic relationships between the terms. The right-hand side shows a lattice-gas schematic of an example annotation, i.e. a selection of terms appropriate to 21 objects, o 1 , o 2 , . . . , o 21 , that have been assigned to the 7 classes P 1 − P 7 (3 objects per class). A cell occupied by a particle in the lattice-gas schematic indicates the term has been selected to annotate that object, whilst a filled (grey) cell indicates a cell that cannot be occupied as a consequence of the ontology structure.
term is applicable to an object then so are the terms associated with any of the ancestor nodes. At a leaf, we have a term that is applicable to a small subset of highly defined objects, possibly even a single object. Each leaf of the DAG determines a unique path or set of paths, denoted by P, consisting of all terms that can be traversed in moving from the root to the leaf. Thus we use leaf, class and P interchangeably and use t ∈ P to denote a term on the unique set of paths P. The prior probability of a particular class P is π P , and is just the proportion of all objects within the class P. If, within a data set we have a total of |O| objects and |O P | objects from class P, then we can construct a simple estimator,π P , of π P via,π Clearly, we expectπ P → π P as |O| → ∞. We then use N t to denote the expected number of classes within the data set to which a term t belongs, i.e., N t is simply the number of leaves which are descendants of term t in the ontology, weighted by the prior π P . Formally we define, and denote by N t its equivalent defined using the estimatorsπ P , i.e., The value of N t is essentially the probability, P (t), that term t is relevant to an object, irrespective of any further details of the object. Thus N t gives a probabilistic measure of the specificity of term t that reflects the structure of the ontology, and expert knowledge and information encoded within it. We therefore consider N t to measure the intrinsic information content of term t.
Specifically, we define the information content of term t as − log P (t) = − log N t [18]. An object belonging to the class represented by a leaf P can be annotated with any of the terms t belonging to P. We use n ot ∈ {0, 1} to denote whether term t is used to annotate object o. The discrete variables n ot are lattice gas occupancy numbers (or equivalently Ising spins). Consequently, we formulate the probability of a particular choice of annotations as a lattice-gas model. An example lattice-gas configuration corresponding to an example annotation is shown by the schematic on the right-hand side of Fig.2. The lattice-gas Hamiltonian is relatively simple and is given by, Here v ot represents the local field acting upon a particle at term t for object o, and determines how likely it is that term t will be selected when annotating object o. Ideally no mis-annotation occurs, i.e. only terms appropriate to each object are selected, and there would be the same probability of selecting term t provided the paths P to which the object belongs contains t. Thus, we set, v ot = v t t ∈ P and o ∈ P , h otherwise .
The value of h determines the global background level of mis-annotation that may occur. It is possible to consider a more structured form for v ot , e.g., to allow for greater likelihood of mis-annotation when a term t is close to, but not in, the paths P to which the object o belongs. However, for the remainder of this paper we consider the more simplified form for v ot given in Eq.(5) above and also only consider the scenario where no mis-annotation occurs. Consequently, we set h = ∞. Therefore, for each object, particular terms are forbidden if the term is not on any of the paths from the root node to the leaf node associated with the object. This is also illustrated in Fig.2. In practice, when analysing real data sets, it may be required to consider a finite value of h, to capture the mis-annotations that will inevitably occur. Within Eq.(4) we have also included a chemical potential, µ, which acts as a global field acting on all lattice cells. Equivalently, the fugacity z = exp(βµ) is essentially the global prior probability that a term will be selected by an annotator, and controls or limits the average number,n, of terms per object selected by an annotator. We have used β = 1/T to denote the inverse temperature. The temperature T does not at this stage have an explicit physical interpretation, other than to represent a parameter which controls the expectation value of the Hamiltonian in Eq.(4). However, in Section 4 we propose an intrinsic form for the external field v t in terms of the information content of the term t. With this intrinsic form for v t the temperature T then controls the average information retrieved from the ontology when an object is annotated. Clearly the temperature T will also determine the level of variation seen in annotations from otherwise identical annotators when annotating the same set of objects.
Since we only have non-interacting particles, the probability p t , of term t being used to annotate an object for which it is valid, is easily calculated as, Here n ot denotes the expectation (over annotations) of n ot . Likewise, with the simplification in Eq. (5) for v ot the partition function is straight-forward to evaluate, and for a particular set of objects is given by, Consequently, the expected value of log Z, averaged over all possible data sets, O, of size |O|, is, Likewise, the expected frequency, C t , of term t within the annotation data set is given by, with the expectation over all data sets of size |O| being, In all of the expressions above for the partition function Z we do not consider objects within the same class P to be interchangeable. It is likely that objects within the class P are unique and distinguishable, and simply possess a common characteristic rather than being replicates of each other. Finally, we note that for any real data set of term frequencies f t , Eq.(10) provides a simple means of constructing an estimate of the field strength operating on node t, by equating the expectation value for C t O given in Eq. (10) with f t . This gives us an estimatev t for v t given by, 3. Replicating the patterns of real annotation data sets 3.1. The relation between N t and leaf descendants Clearly, a first test of the lattice-gas model of the annotation process is whether it can replicate or explain the broad patterns seen in real annotation data sets, such as those seen by Kalankesh et al. [5]. From Eq.(10) we can see that C t O depends upon two factors; N t and p t . Due to the typically hierarchical nature of the ontology topology we would expect N t to have a broad distribution of values, and potentially to dominate the distribution of C t O . It is transparent that for class probabilities that are uniform across all possible classes then the value of N t is simply proportional to the number of leaf descendants, LD t , that can be reached from term t. For small deviations away from a uniform class probabilities we would still expect N t and LD t to be approximately proportional. Larger deviations away from uniform class probabilities effectively represent a pruning of the DAG into a smaller topology, with leaf nodes that correspond to small class probabilities being effectively eliminated. Consequently, for any DAG topology we still consider LD t to give useful insight into the expected term frequency C t O , and in the next section we assess the likely distribution for LD t for tree-like ontologies.

The distribution of the leaf descendant count LD t .
For irregular-trees precise evaluation of LD t given local information about the node t can be framed in terms of Galton-Watson processes [19,20], though there are few usefully applicable closed-form results available to us. In contrast, single parent regular trees are easier to study. For a single-parent regular tree with b children per node we can label the layers of the tree from l = 0 (at the root) to l = L (at the leaves). The total number of nodes in the tree is (b L+1 − 1)/(b − 1). The number of nodes in layer l is simply b l , whilst the number of leaf descendants for each node in layer l is b L−l , i.e., within each layer there is a simple reciprocal relationship between node counts and leaf descendant counts, suggesting a Zipf's behaviour for the distribution of LD t . More formally, for node t in layer l, with leaf descendant count LD t = b L−l , it is then a simple matter to find, Consequently, for large regular trees we will have P (LD t ≥ X) ≃ X −1 , i.e., a Zipf's law form. Overall, Eq.(12) suggests the origin of the Zipf's law behaviour observed by Kalankesh et al. [5] may be, in part, a consequence of the Zipf's law like behaviour of the distribution of LD t . However, whilst the structure of a regular tree will lead, on average, to a classical Zipf's law like behaviour, the degeneracy in leaf descendant count for nodes within the same layer leads to a For a real ontology, where we will have significant variation in the number of children and parents at the scale of individual nodes, we would expect to see more continuous cumulative probability plots for LD t . We have confirmed with further simulations of irregular tree-like ontologies (results not shown) that, typically, continuous Zipf's law like behaviour in LD t results when one has local variation in the node characteristics, e.g., variation in the average number of children per node or in the probability that a node has children. Similarly, the main part of Fig.3a shows the cumulative probability distribution plot for the leaf descendant count of the cellular component GO ontology. This is the ontology used for annotating the data set shown in Fig.1. The intrinsic power-law like behaviour is clearly evident, and so it perhaps unsurprising that we should observe power-law like behaviour in annotations based upon this ontology. As postulated, and in contrast to the distribution shown for the regular tree, this real-world ontology shows a more continuous spread of leaf descendant counts. However, as with the regular tree, the effective exponent of the approximate power-law form for the cellular component GO ontology is close to -1.

The external field v t : intrinsic and specific components
We have argued that term frequencies in real annotation data sets will be broadly determined by LD t . Figure 3b shows a log-log plot for the observed term frequencies, f t , of the data set shown in Fig.1, plotted against the number of leaf descendants within the ontology from which the annotation terms were drawn. The broad correspondence between observed log of the term frequencies and the log of the number of leaf descendants is clear, and is statistically significant (estimate of Pearson correlationρ = 0.454, 95%CI = [0.408, 0.498], p < 10 −8 for null hypothesis of ρ = 0). However, we would not expect an exact correspondence with the real observed term frequencies, f t , on the basis of N t alone. The precise value of C t O is determined by two factors; N t and p t , with p t determined by v t . We might expect v t itself to have an intrinsic component determined by the ontology topology, but the scatter in Fig.3b suggests that we should decompose v t into an intrinsic contribution, v (0) t , and a specific residual contribution, ∆v t .
Once a form for v (0) t has been specified and an estimate for v t has been obtained from observed term frequencies f t via Eq. (11), then an estimate for ∆v t can be obtained. Overall, the values of ∆v t reveal any biases towards particular terms beyond that expected on the basis of the ontology topology alone. Significant values of ∆v t can potentially indicate regions of the ontology which are not matching the requirements of the annotators, and where the ontology can potentially be improved or needs modification. Equally, having a form for v (0) t allows us to extend the theoretical statistical mechanical formalism by providing an explicit form for p t in the absence of any bias in v t . Therefore, in the remainder of the paper we derive an appropriate form for v (0) t and use it to study the consequences of increasing ontology complexity.

Determination of the intrinsic field strength
To proceed we note that extracting or transferring information from the ontology to an object during the annotation process requires effort. Selecting more specific terms, far from the root, requires greater information about the object to be known by, or inferred by the annotator, and so we equate effort expended by an annotator with the intrinsic information content of the terms selected.
This choice corresponds to the maximum entropy solution for the term probabilities {p t } t under the constraint of capturing a given amount of information from the ontology using a fixed expected number of terms. To see this we first calculate the entropy, S[{p t }] for for a given set of term probabilities, {p t }. From Eq.(6) and Eq. (7) the entropy S[{p t }] is obtained as, In calculating the entropy in Eq. (14) we have clearly averaged over data sets of size |O|, as we wish to eliminate the effects of data set to data set variation and focus solely on the effect of data set size. If we wish to obtain the set of term probabilities {p t } which maximize the entropy subject to capturing a given amount of the stored information in the ontology and a given expected total number of selected terms, then we maximize, Here λ and φ are Lagrange multipliers. The maximum entropy term probabilities, p * t , are simply the set of term probabilities that maximize the expression in Eq. (15), and so we find, Comparing Eq.(6) and Eq. (16) we immediately see that this maximum entropy approach corresponds to setting, With β > 0 we impose the relation (without loss of generality) β = |λ|, giving v For λ < 0 terms with lower information content (larger N t ), that are closer to the root, will be preferentially selected during annotation, whilst for λ > 0 terms with smaller values of N t , that are closer to the leaves of the ontology are preferentially selected.
Substituting the expression for p * t from Eq.(16) into Eq. (9) we get the corresponding maximum entropy expected term frequencies as, Likewise, for the optimal term probabilities {p * t }, the free energy takes a value F * given by, Having obtained a suitable form for v (0) t it is a simple matter to determine whether, for any real data set, there is a non-zero specific field component ∆v t . This can be done by testing if the observed frequency f t is statistically significantly different from C * t O given by Eq. (18). If f t is significantly different to C * t O , then we can then combine Eq.(11), Eq. (13), and Eq. (17) to construct an estimate ∆v t =v t − v (0) t for ∆v t . Thus, we have, Realistically, for a large ontology we would only expect a small proportion of all the terms to be used when annotating an object, and so from Eq. (18) we would expect C * t O /|O| ≪ 1. This suggests that zN t ≪ 1 and that in general . This gives us a simple mechanism for estimating appropriate values of λ for real data sets. This also tells us that, with N t from tree-like ontologies expected to display a Zipf's law behaviour with an exponent close to -1, then we expect to see a Zipf's law like behaviour in the observed term frequencies f t with exponent −(1 − λ). As the exponents for f t observed by Kalankesh et al. [5] are close to -1, this suggests that the effective values of λ for real data sets are small in magnitude and potentially either side of λ = 0.
Finally, we note that as λ = 0 represents the boundary at which terms closer to the root are preferentially selected, an effective value of λ < 0 within a real data set may suggest that annotators do not have a strong desire to make use of the additional nodes provided by larger complex ontologies. Within our statistical mechanical framework we are able to explore whether there is a 'optimal' or preferred size to the ontology that annotators wish to use, and also how this 'optimal' size might scale with the number of objects being annotated. This we do in the next section.

Statistical mechanics of an ensemble of ontologies
Having set up a statistical mechanical model of the annotation process, we are in a position to perform more theoretical analyses and experiments that, whilst not being realisable, still provide valuable insight into the performance of annotators and the underlying ontology being used. For example, a key practical question we wish to address is to determine whether a real-world ontology is fit for purpose, or whether the ontology needs shrinking or expanding. To answer this question in real terms would require providing annotators with a range of ontology graphs and observing which ontology is used most frequently. Such an experiment is not readily performed in real terms. However, within the statistical mechanical framework we can address this question by extending the previous ensemble to one consisting of a large collection of annotators who annotate the same set of objects, but who can select the ontology to be used from a range of ontologies of differing complexity. Consequently, we will see variation in both the choice of topology H being used, and the annotation configuration {n ot } being selected. Considering this ensemble allows us to easily determine the most preferred, and hence most appropriate, ontology. This optimal ontology will depend upon a number of parameters, such as the number of objects being annotated, |O|, and annotator characteristics such as the average number of terms used per object and the average effort/information the annotator is willing to expend per object. The latter two characteristics are controlled by the parameters z and λ. Therefore, the remainder of Section 5 is focused on elucidating how the preferred, or optimal, ontology varies with the parameters |O|, z and λ. To determine the variation with respect to |O|, z and λ requires breaking the analysis down into a number of smaller, but still quite involved, steps. Firstly, in Section 5.1 we construct a suitable statistical mechanical potential, βΩ * , from which the optimal ontology topology H can be determined. In section 5.2 we restrict H to the class of regular trees to make analysis of βΩ * tractable. In Section 5.3 we further simplify the analysis by developing a closed form approximation to βΩ * for regular trees, and examining the asymptotic behaviour of the approximation as the number of objects |O| increases. In Section 5.4 we confirm the results of the asymptotic analysis on regular trees using numerical simulations. Finally, in Section 5.5 we use the insights gained from the analysis of βΩ * to understand what are the most likely observed values for the parameter λ.

Quantifying ontology complexity and determination of the optimal ontology
To extend the ensemble to one that consists of ontologies of varying complexity we must first introduce a measure to quantifying the intrinsic complexity of each ontology. Continuing the information theoretic approach, we measure the complexity of an ontology by its total intrinsic information content − t log N t , and so introduce an additional control variable, ω > 0, to set the average intrinsic information content of a ontology node within this ensemble. The partition function for this ensemble becomes, where Z(H) is the partition function on a fixed DAG and log Z(H) is given by −βF * in Eq. (19). Larger values of ω will favour smaller values for the average intrinsic information per node, and so will favour smaller, lower complexity ontologies. Just as the partition function has been modified, then similarly, the appropriate potential for this ensemble is obtained by adding −ω t log N t to the optimal value of the free energy, βF * . This gives a potential, The most frequently selected, or optimal, ontology is that which minimizes βΩ * . The term −ω t log N t therefore serves an important function by regulating the ontology complexity, with more complex topologies being penalized more heavily.
We can see that the minimum value βΩ * ({N t } t , z, ω) changes on varying either the topology H or the total number of objects, |O|, to which the ontology applies. Consequently, we have the possibility of a change in optimal DAG topology as the number of objects, |O|, being annotated increases. As previously stated, this possibility of a change in the optimal DAG topology is something we wish to investigate further, though to do so over a range of general DAG topologies is unlikely to be tractable. However, as we have already argued for an ontology to be effective it will have a tree-like topology. This then highlights the importance of understanding the behaviour of βΩ * for tree-like ontologies. Even so, characterizing the behaviour of βΩ * for an arbitrary tree-like ontology is still likely to be a difficult task. Therefore, to gain further insight into the behaviour of βΩ * for tree-like ontologies we restrict our further analysis of βΩ * to regular trees.

Optimal ontology size for regular trees
For a regular tree with multi-furcating nodes, i.e., each parent having b children, we can label nodes according to which layer, l, the node is in. The root node is in layer l = 0, whilst leaf nodes are in the final layer L. Nodes in layer l have b L−l leaf descendants and there are b l nodes in layer l. Consequently, the total number of leaves is b L . For simplicity we will take the class distribution {π P } P to be uniform across the leaf nodes, i.e., π P = b −L for each of the classes corresponding to a leaf node. From these relations we can evaluate N t = b −l , for a term corresponding to a node in layer l. It is then a simple matter to re-write βΩ * as, The average number,n, of terms used per annotated object is determined by the fugacity z via the relation, Thus, if we wish to attain a specified valuen we simply solve Eq.(24) for the required value z. Similarly, the average information retrieved per object, I, is determined via the relation, The simple form for the βΩ * in Eq.(23) also allows us to analytically determine the tree size L that is optimal for annotating a given number of objects |O|. The optimal tree size is that which minimizes βΩ * . Due to the discrete nature of L, any growth we observe in the optimal ontology size will occur via a series of transitions. Naively, we would expect the optimal ontology size, L opt , to increase as the number of annotated objects is increased. That is, we would a priori expect L opt → ∞ as |O| → ∞. However, whether growth of L opt is possible or not may be affected by the particular value of z or λ. Consequently, in the next section our analysis will focus upon the behaviour of βΩ * as |O| and L increase, in particular in the regime |O|, L → ∞, for different choices of z and λ.

Asymptotic behaviour of the optimal ontology size for regular trees
The second term on the right-hand-side of Eq.(23) is easily evaluated as, To evaluate the first term on the right-hand-side of Eq.(23) we define a = b λ and make use of the Euler-Maclaurin sum formula [21] to obtain (see Appendix A for details), From the approximation in Eq. (27) we have, For convenience of later analysis we can also write Eq.(27) as, with obvious definitions for the functions f 1 and f 2 . With this more compact notation we can re-write Eq.(28) as, The approximation developed in Eq. (27) is extremely accurate for the values of z, a and L we are interested in (see Appendix A for details), and thereby allows us to accurately elucidate the growth behaviour of the optimal ontology size. To proceed, we consider the asymptotic behaviour of the approximation to βΩ * , as |O| and L → ∞. There are two regimes potentially worth studying in the asymptotic limit |O|, L → ∞. The first regime is wheren is fixed in size. In this regime the increasing number of terms available for annotating an object, as L → ∞, are not made use of, i.e., the increased information captured within the larger ontologies is effectively ignored. Consequently, we also find it instructive to consider a second regime where z is fixed, resulting inn scaling linearly with L. Detailed analysis of the behaviour of βΩ * under these two regimes is given below, for both λ < 0 and λ > 0.
n fixed as L → ∞, λ < 0 : For λ < 0 we have a = b λ < 1 and so a L → 0 as L → ∞. Therefore we can expand the right hand side of both Eq. (29) and Eq.(30) in powers of a L . Doing so, we find,n and so the leading order contributions to βΩ * take the form, (33) The optimal tree depth L opt is determined by minimizing βΩ * with respect to L. With the constant in Eq.(33) being independent of L we find that, provided We show in Appendix B that for 0 > log a > −6 − 4 √ 6 ≃ −15.8 we indeed have that ′′ 2 (z0) < 0. So in this regime for log a Eq.(34) predicts growth of L opt , via a series of transitions, as |O| is increased, with Eq.(34) giving the global scaling relation between the optimal value L opt and |O|. It is also worth noting that the scaling relation in Eq.(34) predicts that the number of leaf nodes, b Lopt , or equivalently the number of required classes, grows slower than the number of objects |O|. The restriction to log a > −15.8 is not an onerous one, as it is likely to be well outside the range of values for a that we are interested in (see the end of Appendix B for a discussion of this point).
n fixed as L → ∞, λ > 0 : For λ > 0 we have a = b λ > 1 and so from Eq. (28) we can see that in order to maintain a fixed value ofn as L → ∞ we must have the scaling z ∼ a −L . Thus, in general we write z =ẑ 1 a −L +ẑ 2 a −2L + O(a −3L ). With z ≥ 0 then we must haveẑ 1 ≥ 0 for this decomposition of z to hold over an arbitrary range of L. Substituting this form for z into Eq.(28) we find, . (35) From this we find, (36) The constant in the expansion above does not depend upon L. In Appendix C we show thatẑ 1ẑ2 f ′′ 1 (ẑ 1 ) < 0, leading to the immediate conclusion that, as L → ∞, the leading order non-constant term in the asymptotic expansion of the free energy is positive, and so cannot counter-balance the increasing contribution from the complexity penalty term. That is, large tree depths L will never be optimal (in the sense of producing a stationary value of βΩ * ) for any value of |O|, irrespective of the values ofn and a. A natural corollary is that the optimal tree depth, L opt , is then simply the smallest tree that will admit the required value ofn, i.e., L opt =n+ 1, though strictly speaking the leading order asymptotic analysis may not still be valid at such values of L. However, the fact that the asymptotic analysis suggests that using large trees is sub-optimal, irrespective of how many objects we wish to annotate, is surprising.
z fixed as L → ∞, λ < 0 : With a < 1 for λ < 0 we have za L → 0 as L → ∞, and so expanding βΩ * in powers of a L gives, Again, the constant in the expansion of βΩ * has no dependence upon L. As we have already shown in Appendix B, when log a < 0 we have 1 log a + 1 2 + log a 12 < 0. On setting the derivative (with respect to L) of Eq.(37) to zero we obtain, Again, we see that it is predicted that the number of classes grows slower than the number of objects |O|.
z fixed as L → ∞, λ > 0 : For λ > 0 we have a = b λ > 1 and so for z fixed we have za L → ∞ as L → ∞. Then to obtain the asymptotic behaviour of βΩ * we observe the following relations and representation for the dilogarithm Li 2 (x) [22], Utilising the results above for Li 2 (x) we finally arrive at the leading order behaviour of βF * , As before, the constant contains only terms that do not depend upon L. Setting ∂βΩ * ∂L L=Lopt = 0, we find the optimal tree depth L opt satisfies the leading order scaling relation, In contrast to the previous scenarios, we now have |O|b −Lopt ∼ constant, i.e. the number of objects per class (leaf node) is approximately constant (or more correctly, only a weak function of L opt ). It is also interesting to observe that with z fixed, the average number of terms used per object,n, is given by, Thus for fixed z we findn scaling linearly with L. If we have a measurement of n at a particular tree depth L 0 , then we can re-express Eq.(42) as, Summarizing the asymptotic behaviour across the four scenarios we have, As estimates for λ,n (and hence z) can already be obtained, the scaling laws (along with their associated amplitudes) provide us with a potential mechanism for assessing whether a tree-like ontology is of optimal size for the given number, |O|, of objects which it is being used to annotate. Thus, we can potentially assess whether an existing ontology should be expanded, or is overly complex for its current usage. Application of these scaling laws is clearly dependent upon their accuracy and the values of λ we are likely to encounter for larger ontologies. These aspects we assess in the next two sections.

Simulation validation of optimal ontology growth and scaling laws
The possibility of growth in the optimal tree depth L opt arises in three of the four distinct regimes considered above; namely at fixed z for both λ < 0 and λ > 0, and also at fixedn for λ < 0. This is borne out by numerical calculations. In Figure 4a we have shown the growth, with |O|, in the tree depth L opt . For fixedn with λ < 0 the fugacity z tends to a finite non-zero value as L → ∞, so essentially we can regard the fixedn, λ < 0 regime as equivalent to the fixed z, λ < 0 regime. Therefore, we have performed the calculations at a number of different values for λ, but in all cases held the fugacity fixed to achieve a value of n = 25 7 at L = 5. All calculations of βΩ * have used the exact summation form for evaluation of βF * . The dashed lines shown in Fig.4a correspond to the growth in L opt predicted by by minimizing the leading order asymptotic contributions to the integral approximation of βΩ * . The correspondence between the simulation results and the long term growth trend predicted by the asymptotic analysis is good, confirming the leading order scaling relations given in Eq.(44). The predicted variation with λ (when λ < 0), in the slope of the scaling relation is also clearly apparent from Fig.4a.

The expected value of λ for increasing complexity
It is natural to ask which of the above scenarios, λ > 0 or λ < 0, is appropriate for a real annotation process? A 'least effort' argument would suggest that an annotator will attempt to limit the effort expended on annotating an object, and so I, the information retrieved per object, will most likely be fixed or only a weakly increasing function of |O|. At fixed z simple inspection of Eq. (25) shows that I is an increasing function of tree depth L opt , and hence |O|, for all values of λ. However, more detailed analysis of Eq.(25) (in particular applying the Ratio test for series convergence, when λ < 0) reveals that as L → ∞ we have (at fixed z), Therefore, we associate λ < 0 with a fixed, or only weakly growing value of I. This idea is corroborated if we consider the more intuitive scenario of a fixed value ofn (as opposed to fixed fugacity z) and a fixed value of I, and determine the required value of λ as the tree depth is L is increased. Figure  4b shows plots, against L, of the value of λ required. The value ofn is held fixed atn = 25/7 and we have fixed I(λ, L,n) = c × I(λ = 0, L = 5,n) for different values of c. The value of λ is then obtained by simultaneous solution of Eq. (24) and Eq. (25). Irrespective of the value of c we can see that increasing L at fixed I andn leads to λ < 0. Consequently, if the information or effort expended per object by an annotator is limited we expect small negative values of λ to be the norm. Furthermore, we note that the amount of annotation information retrieved per object essentially determines the specificity with which the different classes of objects are discriminated. Thus, as data sets of increasing size will potentially sample an increasing number of the classes P present in the population, a fixed value of I may not be sufficient to discriminate them, i.e., the annotation data set will not be of adequate quality. Therefore, the value of λ estimated from a real data set provides a topology derived metric to assess the quality of annotation and annotators, with a negative estimate for λ giving possible cause for concern.
6. Discussion and Conclusions Although the real-world ontologies used in annotating data sets may be fixed in form, the annotation process, by nature of it often being a manual process, is subject to variation. We have used statistical mechanics to construct a formalism of that variability in the annotation process. The formalism developed has allowed us to understand both the patterns seen in real data sets [5], and to suggest measures of the ontology structure itself. This has been done by using a simple lattice-gas model of the term selection process combined with information theoretic concepts. Although measures of ontology structures [9] already exist these do not tend to incorporate the effects of the expected variability in the annotation process. Likewise, many studies have previously combined information theoretic concepts with ontologies, but these works have largely not focused on assessing the underlying ontology structure. Instead studies have used information theoretic concepts in assessing the similarity of individual terms within an ontology [23,24,25], assessing the similarity between annotated objects [26], assessing the similarity between two annotation data sets [27], assessing the similarity between users [28], or in empirical studies of the growth in tag frequencies [29]. Similarly, studies of annotation and tag statistics that relate to the underlying ontology structure exist within the physics literature [14,15], but these have not been based upon a Hamiltonian model of the annotation process. By constructing a Hamiltonian model of the annotations we have built upon the work of Palla et al. [14] and Tibély et al. [15], and been able to construct, in a principled fashion, statistical mechanical measures of the ontology itself.
Having developed a simple lattice-gas model of the annotation process the statistical mechanical formalism has enabled us to progress further and to perform hypothetical experiments over an ensemble of different ontology structures, and in doing so gain new insight where it is not readily possible to perform real experiments. Our analysis of an ensemble of different ontology structures has focused on regular trees, though despite this restriction we still expect the highlevel conclusions drawn in Sections 5.2, 5.4, and 5.5 to be more universally valid. Firstly, our detailed analysis of βΩ * identifies a natural or optimal ontology size, and associated growth scaling law, given the number of objects |O| to be annotated. The scaling laws derived provide us with 'rules-of-thumb' to decide when an ontology should be expanded to match the needs of the data sets to which it is being applied. Secondly, our analysis in Section 5.5 reveals a natural tendency towards λ < 0, as more complex ontologies are used to annotate larger collections of objects. This suggests that values of λ appropriate to real-world annotation data sets will be typically small in magnitude, possibly even negative. This is borne out by the power-law exponents observed by Kalankesh et al. [5]. Small values of λ would imply that annotators are typically recovering less information from the ontology than if they selected terms uniformly at random. As we equate effort expended with the information retrieved, a negative value of λ suggests the effort being expended during the annotation is below that appropriate to the ontology complexity. This may be due to the structure of the ontology being more complex than is necessary to discriminate between the classes of objects being annotated, the annotation effort expended not being sufficient, or simply that there is currently insufficient evidence available to the annotators to discriminate between certain objects. With the statistical mechanical formalism we can potentially extend the analysis presented here to construct measures capable of distinguishing these different possibilities.
The statistical mechanical analysis we have presented here is based upon a relatively simple Hamiltonian. The richness of the behaviour we observe in the statistical mechanical model is more a consequence of the inhomogeneous field induced by the ontology topology. However, the statistical mechanical analysis we have presented here is far from complete. The advantage of having expressed the annotation process in terms of a statistical mechanical formalism is that we can easily extend our analysis to obtain quantitative results for other scenarios or other Hamiltonians. For example, to further reflect more realistic annotation patterns the analysis could be extended to take into account the non-independence of term usage. Indeed, term co-occurrence frequencies have been studied by Tibely et al. [15], with terms that are closer (as measured by path length on the ontology DAG) occurring together more frequently than those further apart. Incorporating tag co-occurrence probabilities would turn our lattice-gas model from a non-interacting model to an interacting model. Alternatively, our statistical mechanical analysis can potentially be extended to account for more realistic aspects and nuances of the annotation process, e.g., mis-selection of terms that are not appropriate to the object being annotated.
Applying the Euler-Maclaurin sum formula to L l=0 log 1 + zb lλ gives, to lowest order of expansion [21], where B 2 is the second Bernoulli number, B 2 (x) = x 2 − x + 1 6 is the second Bernoulli polynomial, and a = b λ . The first integral on the right-hand-side of Eq.(A.1) can be expressed in terms of the dilogarithm function, Li 2 (x) [30,22], as, To arrive at a final approximation to L l=0 log 1 + za l that is convenient for further analysis we simply take some point between the two bounds in Eq.(A.3). By replacing B 2 (s − ⌊s⌋) by its average value of zero, in the last integral in Eq.(A.1), we arrive at the approximation, We should note that the approximation in Eq.(A.4) is simply equivalent to dropping the remainder term in the representation of the Euler-Maclaurin sum formula we have used.  Fig.A.5a the same value for the fugacity z has been used in both free energy calculations. Namely, we have used the value of z required to achieve a value ofn = 25/7, as determined from the exact summation relation in Eq. (24). Similarly, in Fig.A.5b shows the fractional difference between the exact summation in Eq.(A.4) and the integral based approximation, at different values of L and λ but for a fixed value of z. Again, the same fixed value for the fugacity z has been used in both free energy calculations, namely that required to achieve a value ofn = 25/7 when L = 5, as determined from exact summation relation in Eq. (24). Fig.A.5b would suggest that for fixed z the approximation in Eq.(A.4) is again accurate to 2 parts in 1000.

Appendix B.
To observe growth in L opt as |O| → ∞, at fixedn with λ < 0, we require, We start by analysing the behaviour of the numerator of Eq.(B.1). From Eq. (27) and Eq. (29) we have that f 1 (x) is defined as, We wish to determine the behaviour of f ′ 1 (0) for a ∈ R and 0 < a < 1. To do so we seek the roots of f With log a < 0 it is clear that if log(1 + x) > x/(1 + x) , ∀x > 0 then we will have f ′′ 2 (x) < 0 , ∀x > 0. At x = 0 we have log(1 + x) = x/(1 + x). We also have, With z 2 0 > 0 we find that the numerator of Eq.(B.1) is negative. For an exactly calculated partition function we might expectn(z 0 ) to be monotonically increasing in z 0 . However, as we are utilising an integral approximation to the exact expression for βΩ * given in Eq.(23), we continue our analysis with dn(z 0 )/dz 0 as given above. Explicitly, we find, where again y = log a < 0. Examination of the discriminant (with respect to x) of the numerator in the right-hand-side of Eq.(B.9) reveals that in order for the right-hand-side of Eq.(B.9) to be positive requires log a < −6 − 4 √ 6 ≃ −15.8. Therefore, overall we find that the left-hand-side of Eq.(B.1) is negative for 0 > log a > −6−4 √ 6. This threshold value of a we regard as somewhat extreme and outside the range that we are likely to be interested in -a value of log a = −15.8 corresponds to a reduction by a factor of more than 10 7 in the probability of selecting a term, in going from one layer of the tree to the next layer. The possibility that dn(z)/dz may be negative for some z in the limit L → ∞ is most likely due to a breakdown in the accuracy of the integral approximation in Eq.(A.1). Indeed, from Eq.(24) we see that the exact expression for dn(z)/dz is given by, which is clearly positive for all λ and for all z > 0, a > 0.