Template:Clade/doc: Difference between revisions
→see also: fix listing |
m 1 revision imported from wikipedia:en:Template:Clade/doc |
||
(No difference)
|
Latest revision as of 01:57, 16 August 2025
![]() | This is a documentation subpage for Template:Terminate sentence It may contain usage information, categories and other content that is not part of the original template page. |
![]() | This template is used on approximately 9,300 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them. |
![]() | This template uses Lua: |
![]() | This template uses TemplateStyles: |
This template is used for drawing branching trees with the node and base labels being clickable links. Such diagrams are especially suited to represent evolutionary trees (cladograms).
Basic features
Usage
<syntaxhighlight lang="wikitext">
Base |
Node |
</syntaxhighlight>
produces
Base |
Node |
<syntaxhighlight lang="wikitext">
</syntaxhighlight>
produces
<syntaxhighlight lang="wikitext">
| |||||||
</syntaxhighlight>
produces
| |||||||
Note that the order of the parameters does not matter. Exactly the same output is produced by <syntaxhighlight lang="wikitext">
| |||||||
</syntaxhighlight>
| |||||||
Technical background
The clade template has many features for customising the appearance. Using them optimally requires some understanding of how the template works. The cladogram is constructed using nested HTML tables and the lines of the cladogram are borders of the cells (<td>
tags). Each clade template creates an HTML table with the elements show as follows:
Description | Table cell structure | Cladogram | Code using clade template | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A simple clade structure with a single child node (or leaf). This is an HTML table with two rows and two columns. The cells of the righthand column are merged using the rowspan attribute. |
|
|
<syntaxhighlight lang="wikitext">
| |||||||||||||||||||||||||||
Replace LeafA with another clade structure. A second HTML table is placed inside a the right-hand cell of the outer table. |
|
|
<syntaxhighlight lang="wikitext">
|
Styling brackets and branches
The appearance of the cladogram can be customised by changing the border attributes of the HTML cell elements, using the parameters |state=
, |color=
and |thickness=
as shown below:
Description | Template code | Resulting output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Styling brackets
The thickness, colour and state (solid, dashed, etc.) of bracket lines can be changed using the |
<syntaxhighlight lang="wikitext">
</syntaxhighlight> |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Styling individual branches
The thickness, colour and state of individual branch lines can be changed using the |
<syntaxhighlight lang="wikitext">
</syntaxhighlight>
|
|
Reverse clade
The cladograms can also be generated right to left using {{cladeR}}, as shown below.
Code | Output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
<syntaxhighlight lang="wikitext">
|
|
While this has limited value in English Wikipedia, it can be useful for presenting alternative phylogenies
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
<syntaxhighlight lang="wikitext">
Data in Newick formatA common method of presenting phylogenetic data is to use the Newick format. Many published papers provide data in Newick format in their supplementary materials and several taxonomic and phyogenetic websites provide downloads (e.g. Open Tree of Life). These Newick strings can be used to generate cladograms in several ways. Newick strings as a resourceFirstly, the Newick format data can be used to generate the clade structure markup using a text editor or one of several tools.
The phylogenetic tree shown to the right is represented by the following Newick and {{Clade}} code
The manual procedure for conversion in a text editor is
Fortunately, there are a number of methods for automating this task.
use constant N=>"\n"; use constant T=>"\t"; my $tree='((a,b),(c,d));'; # get sequence $tree=~s/[\n\r]//g; # loose those spaces $tree=~ s/\:[\.\d]+//g; # loose those lengths while ($tree=~ m/\(/) { foreach my $clade ($tree=~ m/\(([^\(\)]+)\)/g) { my @branches=split /\,/,$clade; s/(\t+)/$1\t/g for @branches; die 'ERROR: degenerate/empty node!'.N if $#branches<1; $tree=~ s/\(\Q$clade\E\)/${\join(,'Template:Clade',N,map(T.'')}/; # substitute } pos($tree)=0; } $tree=~s/(\t*)\t\}\}/$1\}\}/g; # lazy fix print $tree; </syntaxhighlight> Using Newick strings directlyThe Newick format data can also be added using the For instance, the following Newick string <syntaxhighlight lang="wikitext">((lion,jaguar,leopard),((siberian,bengal)tiger,snow leopard))panthera</syntaxhighlight> can be put in the clade code as in the following example:
The Newick format data provided Open Tree of Life and other sources typically has extraneous encoding data. This can be removed using the
}}</syntaxhighlight> produces
Using a boxYou can nest the templates and use links around the text. The entire cladogram can be placed in a box so that text flows nicely around it. You can use {{Cladogram}} to produce the box.
<syntaxhighlight lang="wikitext">
</syntaxhighlight> Controlling the layout of sistersWhen one sister is represented as a leaf node and the other as a labelled subclade, they do not appear to be at the same level. Consider this cladogram:
Although Banksia subser. Sphaerocarpae and Banksia subser. Leptophyllae are sisters, their names are not aligned in the cladogram. If this is considered undesirable, one solution is to use a label in both cases, as shown hereafter, which now shows the sisters at the same level.
Another 'trick' is to introduce a dummy clade. The red line in the following example shows where an extra clade has been inserted:
To achieve this, instead of <syntaxhighlight lang="wikitext">
</syntaxhighlight> which displays as:
use <syntaxhighlight lang="wikitext">
</syntaxhighlight> which displays as:
Bracketting and labelling nodesAdding vertical bars and bracketsTo insert a coloured 'bracket' around a set of leaf nodes which follow one another in the generated cladogram:
The horizontal lines can be omitted by using
Specifying bracket coloursYou can use any of the ways in which colours can be specified in HTML; e.g. the standard colour names, the three or six hex digit notations, such as #FC3 or #F3C630, or the Adding text labels to bracketsAccessibility guidelines require pages not to rely on colour alone, so it's particularly important to add labels if you have more than one bracket/bar and need to refer to them separately. A couple of methods are available.
In the example above grouplabel was used to label a bar marking the entire clade. It provided an alternative to labelA. However, if the bar is only applied to some terminals,
The
The Lua error in Module:Clade/example at line 54: attempt to concatenate field '?' (a nil value).</syntaxhighlight> |
output1=
}} DebuggingIf your cladogram doesn't display brackets/bars as you expected, check that:
LimitationsLabel lengthLabels produced by
Browser differences![]() Cladograms are drawn by generating hidden tables. The horizontal and vertical lines making up the tree are actually the edges of table cells. The tables are then drawn by the browser or user agent using its internal algorithms. As these differ from browser to browser, the trees produced will not look the same on all browsers. In particular, as of January 2017[update], there are two algorithms for laying out tables with empty cells, used by two groups of browsers. Most browsers now use the algorithm that produces cladograms like the two on the left in the diagram. Safari (under both MacOS and iOS) uses another algorithm, producing cladograms like the two on the right in the diagram. No automated "fix" for these differences exists at present. If there is a choice over the ordering of the terminal nodes (leaves) of the tree, cladograms look best in a Safari-like browser if as much branching as possible is at the bottom of the cladogram. Typically this is produced by arranging the terminal nodes downwards on the page in order of their evolutionary divergence. Compare the bottom row of the diagram to the top row. Inclusion in booksThere are many known bugs in rendering tables in the software which produces Wikipedia books; see the book tool feedback page. As of July 2011[update] these result in the lines in cladograms not displaying in books. (Cladograms are implemented as HTML tables, which allows complex but hard-to-convert formatting. For an alternative way to include book cladograms, try images.) Large cladogramsThere are limitations on the size and complexity of the cladograms which can be drawn:
Techniques for building large cladogramsBecause cladograms are build by nesting {{clade}} templates within each other, larger cladograms can exceed the expansion depth allowed by the Wikimedia software. The cladogram on the right fails on the twentieth nested clade template. There are two methods to get around this limitation:
Using sequential listing of taxaThis approach uses the template {{clade sequential}} to list taxa in a taxonomic sequence. In the following example six taxa are listed sequentially in the template and the cladogram has the first one as the first branch, the second next and so on until the final two are sisters. Because all taxa are added in one template call, this only counts once towards the 20 limit. The downside is that it is not possible to format each level independently.
The second example shows that some substructure can be added to each level with normal use of the {{clade}} template.
Using subtreesThis method uses the parameters The basic arrangement is illustrated below. The main tree has two subclades, A and B, and subclade B calls a third. {{clade example |decription=|code=|output= |
description1x=Basic tree without subclades | code1=<syntaxhighlight lang="wikitext">
The encoding relies on a number of conventions.
An example of a large phylogenetic tree divided into multiple subtrees can be found at {{Phylogeny/APG IV}}. Add interactivity with collapsible cladesSometimes with large phylogenetic trees it is hard to see the wood for the trees. The cladogram may exceed the screen height making it difficult to see the overall structure and important small clades are too hard to see. A way around this is to collapse the large clades and expand them interactively. The following example shows a simple example to illustrate the principle:
A note of caution. The Wikimedia collapsible elements require javascript and are currently disabled in the mobile view. In such cases the whole cladogram will be shown. As with any large phylogentic trees, editors should decide if having a smaller less inclusive tree makes the point more clearly. Graphical summary
See also
|