1983 lines
2.3 MiB
HTML
1983 lines
2.3 MiB
HTML
|
<!DOCTYPE html>
|
|||
|
|
|||
|
<html>
|
|||
|
|
|||
|
<head>
|
|||
|
|
|||
|
<meta charset="utf-8" />
|
|||
|
<meta name="generator" content="pandoc" />
|
|||
|
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
|
|||
|
|
|||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|||
|
|
|||
|
<meta name="author" content="Tal Galili" />
|
|||
|
|
|||
|
<meta name="date" content="2024-11-15" />
|
|||
|
|
|||
|
<title>Introduction to dendextend</title>
|
|||
|
|
|||
|
<script>// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
|||
|
// be compatible with the behavior of Pandoc < 2.8).
|
|||
|
document.addEventListener('DOMContentLoaded', function(e) {
|
|||
|
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
|||
|
var i, h, a;
|
|||
|
for (i = 0; i < hs.length; i++) {
|
|||
|
h = hs[i];
|
|||
|
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
|||
|
a = h.attributes;
|
|||
|
while (a.length > 0) h.removeAttribute(a[0].name);
|
|||
|
}
|
|||
|
});
|
|||
|
</script>
|
|||
|
|
|||
|
<style type="text/css">
|
|||
|
code{white-space: pre-wrap;}
|
|||
|
span.smallcaps{font-variant: small-caps;}
|
|||
|
span.underline{text-decoration: underline;}
|
|||
|
div.column{display: inline-block; vertical-align: top; width: 50%;}
|
|||
|
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|||
|
ul.task-list{list-style: none;}
|
|||
|
</style>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<style type="text/css">
|
|||
|
code {
|
|||
|
white-space: pre;
|
|||
|
}
|
|||
|
.sourceCode {
|
|||
|
overflow: visible;
|
|||
|
}
|
|||
|
</style>
|
|||
|
<style type="text/css" data-origin="pandoc">
|
|||
|
pre > code.sourceCode { white-space: pre; position: relative; }
|
|||
|
pre > code.sourceCode > span { line-height: 1.25; }
|
|||
|
pre > code.sourceCode > span:empty { height: 1.2em; }
|
|||
|
.sourceCode { overflow: visible; }
|
|||
|
code.sourceCode > span { color: inherit; text-decoration: inherit; }
|
|||
|
div.sourceCode { margin: 1em 0; }
|
|||
|
pre.sourceCode { margin: 0; }
|
|||
|
@media screen {
|
|||
|
div.sourceCode { overflow: auto; }
|
|||
|
}
|
|||
|
@media print {
|
|||
|
pre > code.sourceCode { white-space: pre-wrap; }
|
|||
|
pre > code.sourceCode > span { display: inline-block; text-indent: -5em; padding-left: 5em; }
|
|||
|
}
|
|||
|
pre.numberSource code
|
|||
|
{ counter-reset: source-line 0; }
|
|||
|
pre.numberSource code > span
|
|||
|
{ position: relative; left: -4em; counter-increment: source-line; }
|
|||
|
pre.numberSource code > span > a:first-child::before
|
|||
|
{ content: counter(source-line);
|
|||
|
position: relative; left: -1em; text-align: right; vertical-align: baseline;
|
|||
|
border: none; display: inline-block;
|
|||
|
-webkit-touch-callout: none; -webkit-user-select: none;
|
|||
|
-khtml-user-select: none; -moz-user-select: none;
|
|||
|
-ms-user-select: none; user-select: none;
|
|||
|
padding: 0 4px; width: 4em;
|
|||
|
color: #aaaaaa;
|
|||
|
}
|
|||
|
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
|
|||
|
div.sourceCode
|
|||
|
{ }
|
|||
|
@media screen {
|
|||
|
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
|
|||
|
}
|
|||
|
code span.al { color: #ff0000; font-weight: bold; }
|
|||
|
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; }
|
|||
|
code span.at { color: #7d9029; }
|
|||
|
code span.bn { color: #40a070; }
|
|||
|
code span.bu { color: #008000; }
|
|||
|
code span.cf { color: #007020; font-weight: bold; }
|
|||
|
code span.ch { color: #4070a0; }
|
|||
|
code span.cn { color: #880000; }
|
|||
|
code span.co { color: #60a0b0; font-style: italic; }
|
|||
|
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; }
|
|||
|
code span.do { color: #ba2121; font-style: italic; }
|
|||
|
code span.dt { color: #902000; }
|
|||
|
code span.dv { color: #40a070; }
|
|||
|
code span.er { color: #ff0000; font-weight: bold; }
|
|||
|
code span.ex { }
|
|||
|
code span.fl { color: #40a070; }
|
|||
|
code span.fu { color: #06287e; }
|
|||
|
code span.im { color: #008000; font-weight: bold; }
|
|||
|
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; }
|
|||
|
code span.kw { color: #007020; font-weight: bold; }
|
|||
|
code span.op { color: #666666; }
|
|||
|
code span.ot { color: #007020; }
|
|||
|
code span.pp { color: #bc7a00; }
|
|||
|
code span.sc { color: #4070a0; }
|
|||
|
code span.ss { color: #bb6688; }
|
|||
|
code span.st { color: #4070a0; }
|
|||
|
code span.va { color: #19177c; }
|
|||
|
code span.vs { color: #4070a0; }
|
|||
|
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; }
|
|||
|
</style>
|
|||
|
<script>
|
|||
|
// apply pandoc div.sourceCode style to pre.sourceCode instead
|
|||
|
(function() {
|
|||
|
var sheets = document.styleSheets;
|
|||
|
for (var i = 0; i < sheets.length; i++) {
|
|||
|
if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue;
|
|||
|
try { var rules = sheets[i].cssRules; } catch (e) { continue; }
|
|||
|
var j = 0;
|
|||
|
while (j < rules.length) {
|
|||
|
var rule = rules[j];
|
|||
|
// check if there is a div.sourceCode rule
|
|||
|
if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") {
|
|||
|
j++;
|
|||
|
continue;
|
|||
|
}
|
|||
|
var style = rule.style.cssText;
|
|||
|
// check if color or background-color is set
|
|||
|
if (rule.style.color === '' && rule.style.backgroundColor === '') {
|
|||
|
j++;
|
|||
|
continue;
|
|||
|
}
|
|||
|
// replace div.sourceCode by a pre.sourceCode rule
|
|||
|
sheets[i].deleteRule(j);
|
|||
|
sheets[i].insertRule('pre.sourceCode{' + style + '}', j);
|
|||
|
}
|
|||
|
}
|
|||
|
})();
|
|||
|
</script>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<style type="text/css">body {
|
|||
|
background-color: #fff;
|
|||
|
margin: 1em auto;
|
|||
|
max-width: 700px;
|
|||
|
overflow: visible;
|
|||
|
padding-left: 2em;
|
|||
|
padding-right: 2em;
|
|||
|
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|||
|
font-size: 14px;
|
|||
|
line-height: 1.35;
|
|||
|
}
|
|||
|
#TOC {
|
|||
|
clear: both;
|
|||
|
margin: 0 0 10px 10px;
|
|||
|
padding: 4px;
|
|||
|
width: 400px;
|
|||
|
border: 1px solid #CCCCCC;
|
|||
|
border-radius: 5px;
|
|||
|
background-color: #f6f6f6;
|
|||
|
font-size: 13px;
|
|||
|
line-height: 1.3;
|
|||
|
}
|
|||
|
#TOC .toctitle {
|
|||
|
font-weight: bold;
|
|||
|
font-size: 15px;
|
|||
|
margin-left: 5px;
|
|||
|
}
|
|||
|
#TOC ul {
|
|||
|
padding-left: 40px;
|
|||
|
margin-left: -1.5em;
|
|||
|
margin-top: 5px;
|
|||
|
margin-bottom: 5px;
|
|||
|
}
|
|||
|
#TOC ul ul {
|
|||
|
margin-left: -2em;
|
|||
|
}
|
|||
|
#TOC li {
|
|||
|
line-height: 16px;
|
|||
|
}
|
|||
|
table {
|
|||
|
margin: 1em auto;
|
|||
|
border-width: 1px;
|
|||
|
border-color: #DDDDDD;
|
|||
|
border-style: outset;
|
|||
|
border-collapse: collapse;
|
|||
|
}
|
|||
|
table th {
|
|||
|
border-width: 2px;
|
|||
|
padding: 5px;
|
|||
|
border-style: inset;
|
|||
|
}
|
|||
|
table td {
|
|||
|
border-width: 1px;
|
|||
|
border-style: inset;
|
|||
|
line-height: 18px;
|
|||
|
padding: 5px 5px;
|
|||
|
}
|
|||
|
table, table th, table td {
|
|||
|
border-left-style: none;
|
|||
|
border-right-style: none;
|
|||
|
}
|
|||
|
table thead, table tr.even {
|
|||
|
background-color: #f7f7f7;
|
|||
|
}
|
|||
|
p {
|
|||
|
margin: 0.5em 0;
|
|||
|
}
|
|||
|
blockquote {
|
|||
|
background-color: #f6f6f6;
|
|||
|
padding: 0.25em 0.75em;
|
|||
|
}
|
|||
|
hr {
|
|||
|
border-style: solid;
|
|||
|
border: none;
|
|||
|
border-top: 1px solid #777;
|
|||
|
margin: 28px 0;
|
|||
|
}
|
|||
|
dl {
|
|||
|
margin-left: 0;
|
|||
|
}
|
|||
|
dl dd {
|
|||
|
margin-bottom: 13px;
|
|||
|
margin-left: 13px;
|
|||
|
}
|
|||
|
dl dt {
|
|||
|
font-weight: bold;
|
|||
|
}
|
|||
|
ul {
|
|||
|
margin-top: 0;
|
|||
|
}
|
|||
|
ul li {
|
|||
|
list-style: circle outside;
|
|||
|
}
|
|||
|
ul ul {
|
|||
|
margin-bottom: 0;
|
|||
|
}
|
|||
|
pre, code {
|
|||
|
background-color: #f7f7f7;
|
|||
|
border-radius: 3px;
|
|||
|
color: #333;
|
|||
|
white-space: pre-wrap;
|
|||
|
}
|
|||
|
pre {
|
|||
|
border-radius: 3px;
|
|||
|
margin: 5px 0px 10px 0px;
|
|||
|
padding: 10px;
|
|||
|
}
|
|||
|
pre:not([class]) {
|
|||
|
background-color: #f7f7f7;
|
|||
|
}
|
|||
|
code {
|
|||
|
font-family: Consolas, Monaco, 'Courier New', monospace;
|
|||
|
font-size: 85%;
|
|||
|
}
|
|||
|
p > code, li > code {
|
|||
|
padding: 2px 0px;
|
|||
|
}
|
|||
|
div.figure {
|
|||
|
text-align: center;
|
|||
|
}
|
|||
|
img {
|
|||
|
background-color: #FFFFFF;
|
|||
|
padding: 2px;
|
|||
|
border: 1px solid #DDDDDD;
|
|||
|
border-radius: 3px;
|
|||
|
border: 1px solid #CCCCCC;
|
|||
|
margin: 0 5px;
|
|||
|
}
|
|||
|
h1 {
|
|||
|
margin-top: 0;
|
|||
|
font-size: 35px;
|
|||
|
line-height: 40px;
|
|||
|
}
|
|||
|
h2 {
|
|||
|
border-bottom: 4px solid #f7f7f7;
|
|||
|
padding-top: 10px;
|
|||
|
padding-bottom: 2px;
|
|||
|
font-size: 145%;
|
|||
|
}
|
|||
|
h3 {
|
|||
|
border-bottom: 2px solid #f7f7f7;
|
|||
|
padding-top: 10px;
|
|||
|
font-size: 120%;
|
|||
|
}
|
|||
|
h4 {
|
|||
|
border-bottom: 1px solid #f7f7f7;
|
|||
|
margin-left: 8px;
|
|||
|
font-size: 105%;
|
|||
|
}
|
|||
|
h5, h6 {
|
|||
|
border-bottom: 1px solid #ccc;
|
|||
|
font-size: 105%;
|
|||
|
}
|
|||
|
a {
|
|||
|
color: #0033dd;
|
|||
|
text-decoration: none;
|
|||
|
}
|
|||
|
a:hover {
|
|||
|
color: #6666ff; }
|
|||
|
a:visited {
|
|||
|
color: #800080; }
|
|||
|
a:visited:hover {
|
|||
|
color: #BB00BB; }
|
|||
|
a[href^="http:"] {
|
|||
|
text-decoration: underline; }
|
|||
|
a[href^="https:"] {
|
|||
|
text-decoration: underline; }
|
|||
|
|
|||
|
code > span.kw { color: #555; font-weight: bold; }
|
|||
|
code > span.dt { color: #902000; }
|
|||
|
code > span.dv { color: #40a070; }
|
|||
|
code > span.bn { color: #d14; }
|
|||
|
code > span.fl { color: #d14; }
|
|||
|
code > span.ch { color: #d14; }
|
|||
|
code > span.st { color: #d14; }
|
|||
|
code > span.co { color: #888888; font-style: italic; }
|
|||
|
code > span.ot { color: #007020; }
|
|||
|
code > span.al { color: #ff0000; font-weight: bold; }
|
|||
|
code > span.fu { color: #900; font-weight: bold; }
|
|||
|
code > span.er { color: #a61717; background-color: #e3d2d2; }
|
|||
|
</style>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</head>
|
|||
|
|
|||
|
<body>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<h1 class="title toc-ignore">Introduction to dendextend</h1>
|
|||
|
<h4 class="author">Tal Galili</h4>
|
|||
|
<h4 class="date">2024-11-15</h4>
|
|||
|
|
|||
|
|
|||
|
<div id="TOC">
|
|||
|
<ul>
|
|||
|
<li><a href="#introduction" id="toc-introduction">Introduction</a></li>
|
|||
|
<li><a href="#prerequisites" id="toc-prerequisites">Prerequisites</a>
|
|||
|
<ul>
|
|||
|
<li><a href="#acknowledgement" id="toc-acknowledgement">Acknowledgement</a></li>
|
|||
|
<li><a href="#chaining" id="toc-chaining">Chaining</a></li>
|
|||
|
<li><a href="#a-dendrogram-is-a-nested-list-of-lists-with-attributes" id="toc-a-dendrogram-is-a-nested-list-of-lists-with-attributes">A
|
|||
|
dendrogram is a nested list of lists with attributes</a></li>
|
|||
|
<li><a href="#installation" id="toc-installation">Installation</a></li>
|
|||
|
</ul></li>
|
|||
|
<li><a href="#how-to-explore-a-dendrograms-parameters" id="toc-how-to-explore-a-dendrograms-parameters">How to explore a
|
|||
|
dendrogram’s parameters</a>
|
|||
|
<ul>
|
|||
|
<li><a href="#taking-a-first-look-at-a-dendrogram" id="toc-taking-a-first-look-at-a-dendrogram">Taking a first look at a
|
|||
|
dendrogram</a></li>
|
|||
|
<li><a href="#getting-nodes-attributes-in-a-depth-first-search" id="toc-getting-nodes-attributes-in-a-depth-first-search">Getting nodes
|
|||
|
attributes in a depth-first search</a></li>
|
|||
|
</ul></li>
|
|||
|
<li><a href="#how-to-change-a-dendrogram" id="toc-how-to-change-a-dendrogram">How to change a dendrogram</a>
|
|||
|
<ul>
|
|||
|
<li><a href="#the-set-function" id="toc-the-set-function">The “set”
|
|||
|
function</a></li>
|
|||
|
<li><a href="#two-simple-trees-to-play-with" id="toc-two-simple-trees-to-play-with">Two simple trees to play
|
|||
|
with</a></li>
|
|||
|
<li><a href="#setting-a-dendrograms-labels" id="toc-setting-a-dendrograms-labels">Setting a dendrogram’s
|
|||
|
labels</a></li>
|
|||
|
<li><a href="#setting-a-dendrograms-nodesleaves-points" id="toc-setting-a-dendrograms-nodesleaves-points">Setting a dendrogram’s
|
|||
|
nodes/leaves (points)</a></li>
|
|||
|
<li><a href="#setting-a-dendrograms-branches" id="toc-setting-a-dendrograms-branches">Setting a dendrogram’s
|
|||
|
branches</a></li>
|
|||
|
<li><a href="#changing-a-dendrograms-structure" id="toc-changing-a-dendrograms-structure">Changing a dendrogram’s
|
|||
|
structure</a></li>
|
|||
|
<li><a href="#adding-extra-bars-and-rectangles" id="toc-adding-extra-bars-and-rectangles">Adding extra bars and
|
|||
|
rectangles</a></li>
|
|||
|
</ul></li>
|
|||
|
<li><a href="#ggplot2-integration" id="toc-ggplot2-integration">ggplot2
|
|||
|
integration</a></li>
|
|||
|
<li><a href="#enhancing-other-packages" id="toc-enhancing-other-packages">Enhancing other packages</a>
|
|||
|
<ul>
|
|||
|
<li><a href="#dendser" id="toc-dendser">DendSer</a></li>
|
|||
|
<li><a href="#gplots" id="toc-gplots">gplots</a></li>
|
|||
|
<li><a href="#nmf" id="toc-nmf">NMF</a></li>
|
|||
|
<li><a href="#heatmaply" id="toc-heatmaply">heatmaply</a></li>
|
|||
|
<li><a href="#dynamictreecut" id="toc-dynamictreecut">dynamicTreeCut</a></li>
|
|||
|
<li><a href="#pvclust" id="toc-pvclust">pvclust</a></li>
|
|||
|
<li><a href="#circlize" id="toc-circlize">circlize</a></li>
|
|||
|
</ul></li>
|
|||
|
<li><a href="#comparing-two-dendrograms" id="toc-comparing-two-dendrograms">Comparing two dendrograms</a>
|
|||
|
<ul>
|
|||
|
<li><a href="#dendlist" id="toc-dendlist">dendlist</a></li>
|
|||
|
<li><a href="#dend_diff" id="toc-dend_diff">dend_diff</a></li>
|
|||
|
<li><a href="#tanglegram" id="toc-tanglegram">tanglegram</a></li>
|
|||
|
<li><a href="#correlation-measures" id="toc-correlation-measures">Correlation measures</a></li>
|
|||
|
<li><a href="#the-fowlkes-mallows-index-and-the-bk-plot" id="toc-the-fowlkes-mallows-index-and-the-bk-plot">The Fowlkes-Mallows
|
|||
|
Index and the Bk plot</a></li>
|
|||
|
</ul></li>
|
|||
|
<li><a href="#session-info" id="toc-session-info">Session info</a></li>
|
|||
|
</ul>
|
|||
|
</div>
|
|||
|
|
|||
|
<!--
|
|||
|
%\VignetteEngine{knitr::rmarkdown}
|
|||
|
%\VignetteIndexEntry{Introduction to dendextend}
|
|||
|
-->
|
|||
|
<p><strong>Author</strong>: Tal Galili (homepage: r-statistics.com,
|
|||
|
e-mail: <a href="mailto:Tal.Galili@gmail.com" class="email">Tal.Galili@gmail.com</a> )</p>
|
|||
|
<p><strong>tl;dr</strong>: the <a href="https://cran.r-project.org/package=dendextend"><em>dendextend
|
|||
|
package</em></a> let’s you create figures like this:</p>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAg0AAAINCAYAAAC9GEyUAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygG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D4z8u4PDAOhSsF6myOmhrLzMnP61FR+LRCRTw46ivc9cILOSmC++RjgQ3jx2Pxs
|
|||
|
<div id="introduction" class="section level2">
|
|||
|
<h2>Introduction</h2>
|
|||
|
<p>The <a href="https://cran.r-project.org/package=dendextend"><strong><em>dendextend
|
|||
|
package</em></strong></a> offers a set of functions for extending
|
|||
|
dendrogram objects in R, letting you <strong>visualize</strong> and
|
|||
|
<strong>compare</strong> trees of hierarchical clusterings, you can:</p>
|
|||
|
<ul>
|
|||
|
<li><strong>Adjust a tree’s graphical parameters</strong> - the color,
|
|||
|
size, type, etc of its branches, nodes and labels.</li>
|
|||
|
<li>Visually and statistically <strong>compare different
|
|||
|
dendrograms</strong> to one another.</li>
|
|||
|
</ul>
|
|||
|
<p>The goal of this document is to introduce you to the basic functions
|
|||
|
that dendextend provides, and show how they may be applied. We will make
|
|||
|
extensive use of “chaining” (explained next).</p>
|
|||
|
</div>
|
|||
|
<div id="prerequisites" class="section level2">
|
|||
|
<h2>Prerequisites</h2>
|
|||
|
<div id="acknowledgement" class="section level3">
|
|||
|
<h3>Acknowledgement</h3>
|
|||
|
<p>This package was made possible by the the support of my thesis
|
|||
|
adviser <a href="http://www.math.tau.ac.il/~ybenja/">Yoav Benjamini</a>,
|
|||
|
as well as code contributions from many R users. They are:</p>
|
|||
|
<pre><code>#> [1] "Tal Galili <tal.galili@gmail.com> [aut, cre, cph] (https://www.r-statistics.com)"
|
|||
|
#> [2] "Gavin Simpson [ctb]"
|
|||
|
#> [3] "Gregory Jefferis <jefferis@gmail.com> [ctb] (imported code from his dendroextras package)"
|
|||
|
#> [4] "Marco Gallotta [ctb] (a.k.a: marcog)"
|
|||
|
#> [5] "Johan Renaudie [ctb] (https://github.com/plannapus)"
|
|||
|
#> [6] "R core team [ctb] (Thanks for the Infastructure, and code in the examples)"
|
|||
|
#> [7] "Kurt Hornik [ctb]"
|
|||
|
#> [8] "Uwe Ligges [ctb]"
|
|||
|
#> [9] "Andrej-Nikolai Spiess [ctb]"
|
|||
|
#> [10] "Steve Horvath <SHorvath@mednet.ucla.edu> [ctb]"
|
|||
|
#> [11] "Peter Langfelder <Peter.Langfelder@gmail.com> [ctb]"
|
|||
|
#> [12] "skullkey [ctb]"
|
|||
|
#> [13] "Mark Van Der Loo <mark.vanderloo@gmail.com> [ctb] (https://github.com/markvanderloo d3dendrogram)"
|
|||
|
#> [14] "Yoav Benjamini [ths]"</code></pre>
|
|||
|
<p>The <strong>design</strong> of the dendextend package (and this
|
|||
|
manual!) is heavily inspired by <a href="https://hadley.nz/">Hadley
|
|||
|
Wickham’s</a> work. Especially his text on <a href="https://r-pkgs.org/">writing an R package</a>, the <a href="https://cran.r-project.org/package=devtools">devtools package</a>,
|
|||
|
and the dplyr package (specifically the use of chaining, and the <a href="https://CRAN.R-project.org/package=dplyr/vignettes/dplyr.html">Introduction
|
|||
|
text to dplyr</a>).</p>
|
|||
|
</div>
|
|||
|
<div id="chaining" class="section level3">
|
|||
|
<h3>Chaining</h3>
|
|||
|
<p>Function calls in dendextend often get a dendrogram and returns a
|
|||
|
(modified) dendrogram. This doesn’t lead to particularly elegant code if
|
|||
|
you want to do many operations at once. The same is true even in the
|
|||
|
first stage of creating a dendrogram.</p>
|
|||
|
<p>In order to construct a dendrogram, you will (often) need to go
|
|||
|
through several steps. You can either do so while keeping the
|
|||
|
intermediate results:</p>
|
|||
|
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" tabindex="-1"></a>d1 <span class="ot"><-</span> <span class="fu">c</span>(<span class="dv">1</span><span class="sc">:</span><span class="dv">5</span>) <span class="co"># some data</span></span>
|
|||
|
<span id="cb2-2"><a href="#cb2-2" tabindex="-1"></a>d2 <span class="ot"><-</span> <span class="fu">dist</span>(d1)</span>
|
|||
|
<span id="cb2-3"><a href="#cb2-3" tabindex="-1"></a>d3 <span class="ot"><-</span> <span class="fu">hclust</span>(d2, <span class="at">method =</span> <span class="st">"average"</span>)</span>
|
|||
|
<span id="cb2-4"><a href="#cb2-4" tabindex="-1"></a>dend <span class="ot"><-</span> <span class="fu">as.dendrogram</span>(d3)</span></code></pre></div>
|
|||
|
<p>Or, you can also wrap the function calls inside each other:</p>
|
|||
|
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" tabindex="-1"></a>dend <span class="ot"><-</span> <span class="fu">as.dendrogram</span>(<span class="fu">hclust</span>(<span class="fu">dist</span>(<span class="fu">c</span>(<span class="dv">1</span><span class="sc">:</span><span class="dv">5</span>)), <span class="at">method =</span> <span class="st">"average"</span>))</span></code></pre></div>
|
|||
|
<p>However, both solutions are not ideal: the first solution includes
|
|||
|
redundant intermediate objects, while the second is difficult to read
|
|||
|
(since the order of the operations is from inside to out, while the
|
|||
|
arguments are a long way away from the function).</p>
|
|||
|
<p>To get around this problem, dendextend encourages the use of the
|
|||
|
<code>%>%</code> (“pipe” or “chaining”) operator (imported from the
|
|||
|
magrittr package). This turns <code>x %>% f(y)</code> into
|
|||
|
<code>f(x, y)</code> so you can use it to rewrite (“chain”) multiple
|
|||
|
operations such that they can be read from left-to-right,
|
|||
|
top-to-bottom.</p>
|
|||
|
<p>For example, the following will be written as it would be
|
|||
|
explained:</p>
|
|||
|
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" tabindex="-1"></a>dend <span class="ot"><-</span> <span class="fu">c</span>(<span class="dv">1</span><span class="sc">:</span><span class="dv">5</span>) <span class="sc">%>%</span> <span class="co"># take the a vector from 1 to 5</span></span>
|
|||
|
<span id="cb4-2"><a href="#cb4-2" tabindex="-1"></a> dist <span class="sc">%>%</span> <span class="co"># calculate a distance matrix, </span></span>
|
|||
|
<span id="cb4-3"><a href="#cb4-3" tabindex="-1"></a> <span class="fu">hclust</span>(<span class="at">method =</span> <span class="st">"average"</span>) <span class="sc">%>%</span> <span class="co"># on it compute hierarchical clustering using the "average" method, </span></span>
|
|||
|
<span id="cb4-4"><a href="#cb4-4" tabindex="-1"></a> as.dendrogram <span class="co"># and lastly, turn that object into a dendrogram.</span></span></code></pre></div>
|
|||
|
<p>For more details, you may look at:</p>
|
|||
|
<ul>
|
|||
|
<li><a href="https://cran.r-project.org/package=magrittr">magrittr on
|
|||
|
CRAN</a></li>
|
|||
|
<li><a href="https://CRAN.R-project.org/package=magrittr/vignettes/magrittr.html">Introduction
|
|||
|
to the magrittr package</a></li>
|
|||
|
<li><a href="https://www.r-statistics.com/2014/08/simpler-r-coding-with-pipes-the-present-and-future-of-the-magrittr-package/">Simpler
|
|||
|
R coding with pipes > the present and future of the magrittr
|
|||
|
package</a></li>
|
|||
|
</ul>
|
|||
|
</div>
|
|||
|
<div id="a-dendrogram-is-a-nested-list-of-lists-with-attributes" class="section level3">
|
|||
|
<h3>A dendrogram is a nested list of lists with attributes</h3>
|
|||
|
<p>The first step is working with dendrograms, is to understand that
|
|||
|
they are just a <strong>nested list of lists with attributes</strong>.
|
|||
|
Let us explore this for the following (tiny) tree:</p>
|
|||
|
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1" tabindex="-1"></a><span class="co"># Create a dend:</span></span>
|
|||
|
<span id="cb5-2"><a href="#cb5-2" tabindex="-1"></a>dend <span class="ot"><-</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">2</span> <span class="sc">%>%</span> dist <span class="sc">%>%</span> hclust <span class="sc">%>%</span> as.dendrogram</span>
|
|||
|
<span id="cb5-3"><a href="#cb5-3" tabindex="-1"></a><span class="co"># and plot it:</span></span>
|
|||
|
<span id="cb5-4"><a href="#cb5-4" tabindex="-1"></a>dend <span class="sc">%>%</span> plot</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAADhCAYAAAByfIirAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUP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X22kTFxcXBx3UGDx4saWlpte/i3wggEEUCzhw4WlBQIEuXLq0XVqYX/fv3lzlz5sj58+ejqDVsKgII1BVwJrDM5wf3798ffCSnbpFVVVXBYQo8u6orw3UEokvAmV1C81nBK1euSHJysgwYMEASExOD17BMWJldQnM81qhRo6KrO2wtAgiECDgTWC1btgyOcl+2bFnwLqH5epmYmJjghKDmPIMmyLgggEB0CzgTWDVtMLt97PrVaPAbAQRqCzjzGlbtovg3AgggEE6AwAqnwm0IIOCkAIHlZFsoCgEEwgkQWOFUuA0BBJwUILCcbAtFIYBAOAHn3iUMV+TP3ma++K+ho+KfP3/+sw/JeAQQcECgSQaW+foY8+V/kS7m2025IICAfwJNMrDMF/iZn0iXTZs2RbqL2xFAwGEBXsNyuDmUhgACoQIEVqgH1xBAwGEBAsvh5lAaAgiEChBYoR5cQwABhwUILIebQ2kIIBAqQGCFenANAQQcFnA+sM6ePSuvXr1ymJDSEECgsQScOQ7LnB3nzZs39bZ7yZIlsmHDBunTp4907NhROKdgPSJuQCBqBJwJrLVr18rWrVvFfPPoP//898Tv48ePMm3atOC2ffv2ifkqZS4IIBCdAs4E1saNG4Owys/PF3PKrx49egQdSU9Pl127don5zQUBBKJb4L+nMsoO5vN9Ztdv3bp1MmHCB
|
|||
|
<p>And here is its structure (a nested list of lists with
|
|||
|
attributes):</p>
|
|||
|
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" tabindex="-1"></a>dend <span class="sc">%>%</span> unclass <span class="sc">%>%</span> str</span></code></pre></div>
|
|||
|
<pre><code>#> List of 2
|
|||
|
#> $ : int 1
|
|||
|
#> ..- attr(*, "label")= int 1
|
|||
|
#> ..- attr(*, "members")= int 1
|
|||
|
#> ..- attr(*, "height")= num 0
|
|||
|
#> ..- attr(*, "leaf")= logi TRUE
|
|||
|
#> $ : int 2
|
|||
|
#> ..- attr(*, "label")= int 2
|
|||
|
#> ..- attr(*, "members")= int 1
|
|||
|
#> ..- attr(*, "height")= num 0
|
|||
|
#> ..- attr(*, "leaf")= logi TRUE
|
|||
|
#> - attr(*, "members")= int 2
|
|||
|
#> - attr(*, "midpoint")= num 0.5
|
|||
|
#> - attr(*, "height")= num 1</code></pre>
|
|||
|
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" tabindex="-1"></a>dend <span class="sc">%>%</span> class</span></code></pre></div>
|
|||
|
<pre><code>#> [1] "dendrogram"</code></pre>
|
|||
|
</div>
|
|||
|
<div id="installation" class="section level3">
|
|||
|
<h3>Installation</h3>
|
|||
|
<p>To install the stable version on CRAN use:</p>
|
|||
|
<div class="sourceCode" id="cb10"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1" tabindex="-1"></a><span class="fu">install.packages</span>(<span class="st">'dendextend'</span>)</span></code></pre></div>
|
|||
|
<p>To install the GitHub version:</p>
|
|||
|
<div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" tabindex="-1"></a>require2 <span class="ot"><-</span> <span class="cf">function</span> (package, ...) {</span>
|
|||
|
<span id="cb11-2"><a href="#cb11-2" tabindex="-1"></a> <span class="cf">if</span> (<span class="sc">!</span><span class="fu">require</span>(package)) <span class="fu">install.packages</span>(package); <span class="fu">library</span>(package)</span>
|
|||
|
<span id="cb11-3"><a href="#cb11-3" tabindex="-1"></a>}</span>
|
|||
|
<span id="cb11-4"><a href="#cb11-4" tabindex="-1"></a></span>
|
|||
|
<span id="cb11-5"><a href="#cb11-5" tabindex="-1"></a><span class="do">## require2('installr')</span></span>
|
|||
|
<span id="cb11-6"><a href="#cb11-6" tabindex="-1"></a><span class="do">## install.Rtools() # run this if you are using Windows and don't have Rtools installed</span></span>
|
|||
|
<span id="cb11-7"><a href="#cb11-7" tabindex="-1"></a></span>
|
|||
|
<span id="cb11-8"><a href="#cb11-8" tabindex="-1"></a><span class="co"># Load devtools:</span></span>
|
|||
|
<span id="cb11-9"><a href="#cb11-9" tabindex="-1"></a><span class="fu">require2</span>(<span class="st">"devtools"</span>)</span>
|
|||
|
<span id="cb11-10"><a href="#cb11-10" tabindex="-1"></a>devtools<span class="sc">::</span><span class="fu">install_github</span>(<span class="st">'talgalili/dendextend'</span>)</span>
|
|||
|
<span id="cb11-11"><a href="#cb11-11" tabindex="-1"></a><span class="sc"><!--</span> <span class="fu">require2</span>(<span class="st">"Rcpp"</span>) <span class="sc">-</span><span class="ot">-></span></span>
|
|||
|
<span id="cb11-12"><a href="#cb11-12" tabindex="-1"></a></span>
|
|||
|
<span id="cb11-13"><a href="#cb11-13" tabindex="-1"></a><span class="co"># Having colorspace is also useful, since it is used</span></span>
|
|||
|
<span id="cb11-14"><a href="#cb11-14" tabindex="-1"></a><span class="co"># In various examples in the vignettes</span></span>
|
|||
|
<span id="cb11-15"><a href="#cb11-15" tabindex="-1"></a><span class="fu">require2</span>(<span class="st">"colorspace"</span>)</span></code></pre></div>
|
|||
|
<p>And then you may load the package using:</p>
|
|||
|
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1" tabindex="-1"></a><span class="fu">library</span>(dendextend)</span></code></pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div id="how-to-explore-a-dendrograms-parameters" class="section level2">
|
|||
|
<h2>How to explore a dendrogram’s parameters</h2>
|
|||
|
<div id="taking-a-first-look-at-a-dendrogram" class="section level3">
|
|||
|
<h3>Taking a first look at a dendrogram</h3>
|
|||
|
<p>For the following simple tree:</p>
|
|||
|
<div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" tabindex="-1"></a><span class="co"># Create a dend:</span></span>
|
|||
|
<span id="cb13-2"><a href="#cb13-2" tabindex="-1"></a>dend <span class="ot"><-</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">5</span> <span class="sc">%>%</span> dist <span class="sc">%>%</span> hclust <span class="sc">%>%</span> as.dendrogram</span>
|
|||
|
<span id="cb13-3"><a href="#cb13-3" tabindex="-1"></a><span class="co"># Plot it:</span></span>
|
|||
|
<span id="cb13-4"><a href="#cb13-4" tabindex="-1"></a>dend <span class="sc">%>%</span> plot</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAADhCAYAAAByfIirAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBgE0SQIA9pfFtgo6cKGuhooeilaKH41eDs38Ip+f4At1Rq/sjr6NEwQqb/I/DQqsLvaFUjvAx+eWirddAJZnAj1DFJL0mSg/gcIpPkMBkhoyCSJ8lTZIxk0TpKDjXHliJzZPO50dR5ASNSnzeL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IAgSQCBFYSFDYhgICbAk4H1u+//y5Lly6V9evXu6lHVQggkFMBpwJr1qxZ0RTAEydOlO3bt0ufPn3krrvukhEjRkh9fX1OYTgYAgi4J+DMjKOvv/56dDX1wgsviP48ZMgQeeSRR2TmzJny008/yciRI6PZSHWCv3TLF198IW+++WbK3fT+WBBAwD8BZwLrk08+icJp/PjxcuWVV0bzgU+ePFl0HnOdblcn8/v222/leAJL97/mmmtSdkMfZrIggIB/As4E1tChQ2XFihVy/fXXS+fOnaMpkvUTdHTRT87RKZPnzp17XML6cWD6lWo55ZRTUt3EdgQQcFjAmeewrrvuOvnxxx9l9OjREddll10mHTp0kObmZunXr5/06NFDBg0a5DAlpSGAQHsLOHOF1aVLF/nwww9l27ZtcWPW+d3feustGTZsWNx2VhBAoPAEnLnCitGfe+65sR+j7/oBFIRVHAkrCBSsgHOBVbCdYOAIIJBWgMBKS8QOCCDgigCB5UonqAMBBNIKEFhpidgBAQRcESCwXOkEdSCAQFoBAistETsggIArAgSWK52gDgQQSCtAYKUlYgcEEHBFgMBypRPUgQACaQUIrLRE7IAAAq4IEFiudII6EEAgrQCBlZaIHRBAwBUB5wJLZ2vYunXrMT46r/vu3buP2c4GBBAoHAFnAuvQoUMyduzYaGrkiooKuemmm+TgwYOtnXj00UdFZyVlQQCBwhVwZj6s9957T0pKSmTXrl2yd+9emT59utTW1sqyZcukY8eOGXVo06ZNbYab3j+LmwJ6Huic/G3NGJvtyjdu3CiLFi2S3r17Z/uuU97fDz/8IE8//XTK27khuYAzV1gffPCB3HDDDVJeXi59+/aNPkRCp0quq6uTI0eOJK+ereYENKw2b96c03HpTLa5njZ7yZIlOR2jlYM5c4Wln4rzxhtvRKFVXFws+tXY2ChXXXWVTJs2T
|
|||
|
<p>Here are some basic parameters we can get:</p>
|
|||
|
<div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1" tabindex="-1"></a>dend <span class="sc">%>%</span> labels <span class="co"># get the labels of the tree</span></span></code></pre></div>
|
|||
|
<pre><code>#> [1] 1 2 5 3 4</code></pre>
|
|||
|
<div class="sourceCode" id="cb16"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb16-1"><a href="#cb16-1" tabindex="-1"></a>dend <span class="sc">%>%</span> nleaves <span class="co"># get the number of leaves of the tree</span></span></code></pre></div>
|
|||
|
<pre><code>#> [1] 5</code></pre>
|
|||
|
<div class="sourceCode" id="cb18"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb18-1"><a href="#cb18-1" tabindex="-1"></a>dend <span class="sc">%>%</span> nnodes <span class="co"># get the number of nodes in the tree (including leaves)</span></span></code></pre></div>
|
|||
|
<pre><code>#> [1] 9</code></pre>
|
|||
|
<div class="sourceCode" id="cb20"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb20-1"><a href="#cb20-1" tabindex="-1"></a>dend <span class="sc">%>%</span> head <span class="co"># A combination of "str" with "head"</span></span></code></pre></div>
|
|||
|
<pre><code>#> --[dendrogram w/ 2 branches and 5 members at h = 4]
|
|||
|
#> |--[dendrogram w/ 2 branches and 2 members at h = 1]
|
|||
|
#> | |--leaf 1
|
|||
|
#> | `--leaf 2
|
|||
|
#> `--[dendrogram w/ 2 branches and 3 members at h = 2]
|
|||
|
#> |--leaf 5
|
|||
|
#> `--[dendrogram w/ 2 branches and 2 members at h = 1]
|
|||
|
#> |--leaf 3
|
|||
|
#> `--leaf 4
|
|||
|
#> etc...</code></pre>
|
|||
|
<p>Next let us look at more sophisticated outputs.</p>
|
|||
|
</div>
|
|||
|
<div id="getting-nodes-attributes-in-a-depth-first-search" class="section level3">
|
|||
|
<h3>Getting nodes attributes in a depth-first search</h3>
|
|||
|
<p>When extracting (or inserting) attributes from a dendrogram’s nodes,
|
|||
|
it is often in a “depth-first search”. <a href="https://en.wikipedia.org/wiki/Depth-first_search">Depth-first
|
|||
|
search</a> is when an algorithm for traversing or searching tree or
|
|||
|
graph data structures. One starts at the root and explores as far as
|
|||
|
possible along each branch before backtracking.</p>
|
|||
|
<p>Here is a plot of a tree, illustrating the order in which you should
|
|||
|
read the “nodes attributes”:</p>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAF3CAYAAAA2H0uDAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBgE0SQIA9pfFtgo6cKGuhooeilaKH41eDs38Ip+f4At1Rq/sjr6NEwQqb/I/DQqsLvaFUjvAx+eWirddAJZnAj1DFJL0mSg/gcIpPkMBkhoyCSJ8lTZIxk0TpKDjXHliJzZPO50dR5ASNSnzeLvIvod0HG/mdkmOC0z8VKnzcQ2M/Yz2vKldduXjp9bleLu0ZWn7vWc+l0JGcaai10yNrUnXLP/8Jf59ewX+c3Wgz+B34Df+vb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NOfPnzdUb0HHmYrQVFLLly/XaaAAkQcUHoL5sB00aJChenQG8pg2bZoBZecp4OGOPPBgVkNx+pobbrhBx+GBjmAqQtUz0mlQRwRvyGwqQiis7du3G+AFOZyD6nFrmT799FPjxIkTtpcEyK56Vzal/Mgjj+hLTUUINlCMCKYyNBXUo48+qvNE+yGoHrpRsmRJIzIy0kAbIUD5oIxx48bp4/j4eH0ecceOHdNxzv9kRRGi/fPnz2/MnDnTUL04XXcoQSh0BE+KMCNZduzYoWVFmj179jjkg7hNmzbpOP4TXgQ4NKrufgbfE8AwHYbefv/9d1EPaocCMYSGuR4MO3br1k2fq1KlinTp0kV/V71IvLDJrl279LF6WOtPDJe1b99ef8c/6gEpSgHoY/XwFKXsZM6cOfp4y5Yt+tPMH8Y7qnenh8MgU4kSJfR553+UgpCffvpJRyslqg0zUO6dd96p4yCbfejdu7dOg+FBb8ls5g/rWwwZq16uWwMRlI2AoVRYVKL866+/XsetWrVK1EuG/m6m0wfqnzZt2mjrSxyrXpeONoecTW579+7VPDEEjCHntLQ0UUpZpzX/ue666/RXsMTwNoLq/evPrPwDee0D2gpD4xiGVspXHn74YVG9Xf3dPp27755kUYpQJ69fv74eBsZBu3btbPK6y4txoU8gb+hXkTW0AgE8GN955x1RPQEZNWqUg0h4qCLgAWsf1NCVPsTDEAoJfwiqN6I/8Y+ZBt9hRWj+qZ6I7eFuKk7kgzmypUuX6nkh1aOQ3bt3y9tvv62VhKf5IbPcokWLohgdzHKRp33A3KUZvCWzmZ993mac/aca3pQKFSrIjz/+qOfpcO61117T9V22bJngD
|
|||
|
<p>We can get several nodes attributes using <code>get_nodes_attr</code>
|
|||
|
(notice the order corresponds with what is shown in the above
|
|||
|
figure):</p>
|
|||
|
<div class="sourceCode" id="cb22"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb22-1"><a href="#cb22-1" tabindex="-1"></a><span class="co"># Create a dend:</span></span>
|
|||
|
<span id="cb22-2"><a href="#cb22-2" tabindex="-1"></a>dend <span class="ot"><-</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">5</span> <span class="sc">%>%</span> dist <span class="sc">%>%</span> hclust <span class="sc">%>%</span> as.dendrogram</span>
|
|||
|
<span id="cb22-3"><a href="#cb22-3" tabindex="-1"></a><span class="co"># Get various attributes</span></span>
|
|||
|
<span id="cb22-4"><a href="#cb22-4" tabindex="-1"></a>dend <span class="sc">%>%</span> <span class="fu">get_nodes_attr</span>(<span class="st">"height"</span>) <span class="co"># node's height</span></span></code></pre></div>
|
|||
|
<pre><code>#> [1] 4 1 0 0 2 0 1 0 0</code></pre>
|
|||
|
<div class="sourceCode" id="cb24"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb24-1"><a href="#cb24-1" tabindex="-1"></a>dend <span class="sc">%>%</span> hang.dendrogram <span class="sc">%>%</span> <span class="fu">get_nodes_attr</span>(<span class="st">"height"</span>) <span class="co"># node's height (after raising the leaves)</span></span></code></pre></div>
|
|||
|
<pre><code>#> [1] 4.0 1.0 0.6 0.6 2.0 1.6 1.0 0.6 0.6</code></pre>
|
|||
|
<div class="sourceCode" id="cb26"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb26-1"><a href="#cb26-1" tabindex="-1"></a>dend <span class="sc">%>%</span> <span class="fu">get_nodes_attr</span>(<span class="st">"members"</span>) <span class="co"># number of members (leaves) under that node</span></span></code></pre></div>
|
|||
|
<pre><code>#> [1] 5 2 1 1 3 1 2 1 1</code></pre>
|
|||
|
<div class="sourceCode" id="cb28"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb28-1"><a href="#cb28-1" tabindex="-1"></a>dend <span class="sc">%>%</span> <span class="fu">get_nodes_attr</span>(<span class="st">"members"</span>, <span class="at">id =</span> <span class="fu">c</span>(<span class="dv">2</span>,<span class="dv">5</span>)) <span class="co"># number of members for nodes 2 and 5</span></span></code></pre></div>
|
|||
|
<pre><code>#> [1] 2 3</code></pre>
|
|||
|
<div class="sourceCode" id="cb30"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb30-1"><a href="#cb30-1" tabindex="-1"></a>dend <span class="sc">%>%</span> <span class="fu">get_nodes_attr</span>(<span class="st">"midpoint"</span>) <span class="co"># how much "left" is this node from its left-most child's location</span></span></code></pre></div>
|
|||
|
<pre><code>#> [1] 1.625 0.500 NA NA 0.750 NA 0.500 NA NA</code></pre>
|
|||
|
<div class="sourceCode" id="cb32"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb32-1"><a href="#cb32-1" tabindex="-1"></a>dend <span class="sc">%>%</span> <span class="fu">get_nodes_attr</span>(<span class="st">"leaf"</span>) <span class="co"># is this node a leaf</span></span></code></pre></div>
|
|||
|
<pre><code>#> [1] NA NA TRUE TRUE NA TRUE NA TRUE TRUE</code></pre>
|
|||
|
<div class="sourceCode" id="cb34"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb34-1"><a href="#cb34-1" tabindex="-1"></a>dend <span class="sc">%>%</span> <span class="fu">get_nodes_attr</span>(<span class="st">"label"</span>) <span class="co"># what is the label on this node</span></span></code></pre></div>
|
|||
|
<pre><code>#> [1] NA NA 1 2 NA 5 NA 3 4</code></pre>
|
|||
|
<div class="sourceCode" id="cb36"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb36-1"><a href="#cb36-1" tabindex="-1"></a>dend <span class="sc">%>%</span> <span class="fu">get_nodes_attr</span>(<span class="st">"nodePar"</span>) <span class="co"># empty (for now...)</span></span></code></pre></div>
|
|||
|
<pre><code>#> [1] NA NA NA NA NA NA NA NA NA</code></pre>
|
|||
|
<div class="sourceCode" id="cb38"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb38-1"><a href="#cb38-1" tabindex="-1"></a>dend <span class="sc">%>%</span> <span class="fu">get_nodes_attr</span>(<span class="st">"edgePar"</span>) <span class="co"># empty (for now...)</span></span></code></pre></div>
|
|||
|
<pre><code>#> [1] NA NA NA NA NA NA NA NA NA</code></pre>
|
|||
|
<p>A similar function for leaves only is
|
|||
|
<code>get_leaves_attr</code></p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div id="how-to-change-a-dendrogram" class="section level2">
|
|||
|
<h2>How to change a dendrogram</h2>
|
|||
|
<div id="the-set-function" class="section level3">
|
|||
|
<h3>The “set” function</h3>
|
|||
|
<p>The fastest way to start changing parameters with dendextend is by
|
|||
|
using the <code>set</code> function. It is written as:
|
|||
|
<code>set(object, what, value)</code>, and accepts the following
|
|||
|
parameters:</p>
|
|||
|
<ol style="list-style-type: decimal">
|
|||
|
<li><strong>object</strong>: a dendrogram object,</li>
|
|||
|
<li><strong>what</strong>: a character indicating what is the property
|
|||
|
of the tree that should be set/updated</li>
|
|||
|
<li><strong>value</strong>: a vector with the value to set in the tree
|
|||
|
(the type of the value depends on the “what”). Many times, vectors which
|
|||
|
are too short are recycled.</li>
|
|||
|
</ol>
|
|||
|
<p>The <strong>what</strong> parameter accepts many options, each uses
|
|||
|
some general function in the background. These options deal with labels,
|
|||
|
nodes and branches. They are:</p>
|
|||
|
<ul>
|
|||
|
<li>labels - set the labels (using
|
|||
|
<code>labels<-.dendrogram</code>)</li>
|
|||
|
<li>labels_colors - set the labels’ colors (using
|
|||
|
<code>color_labels</code>)</li>
|
|||
|
<li>labels_cex - set the labels’ size (using
|
|||
|
<code>assign_values_to_leaves_nodePar</code>)</li>
|
|||
|
<li>labels_to_character - set the labels’ to be characters</li>
|
|||
|
<li>leaves_pch - set the leaves’ point type (using
|
|||
|
<code>assign_values_to_leaves_nodePar</code>)</li>
|
|||
|
<li>leaves_cex - set the leaves’ point size (using
|
|||
|
<code>assign_values_to_leaves_nodePar</code>)</li>
|
|||
|
<li>leaves_col - set the leaves’ point color (using
|
|||
|
<code>assign_values_to_leaves_nodePar</code>)</li>
|
|||
|
<li>leaves_bg - set the leaves’ point background color (available only
|
|||
|
for pch 21-25, using <code>assign_values_to_nodes_nodePar</code>)</li>
|
|||
|
<li>nodes_pch - set the nodes’ point type (using
|
|||
|
<code>assign_values_to_nodes_nodePar</code>)</li>
|
|||
|
<li>nodes_cex - set the nodes’ point size (using
|
|||
|
<code>assign_values_to_nodes_nodePar</code>)</li>
|
|||
|
<li>nodes_col - set the nodes’ point color (using
|
|||
|
<code>assign_values_to_nodes_nodePar</code>)</li>
|
|||
|
<li>nodes_bg - set the nodes’ point background color (available only for
|
|||
|
pch 21-25, using <code>assign_values_to_nodes_nodePar</code>)</li>
|
|||
|
<li>hang_leaves - hang the leaves (using
|
|||
|
<code>hang.dendrogram</code>)</li>
|
|||
|
<li>branches_k_color - color the branches (using
|
|||
|
<code>color_branches</code>)</li>
|
|||
|
<li>branches_col - set the color of branches (using
|
|||
|
<code>assign_values_to_branches_edgePar</code>)</li>
|
|||
|
<li>branches_lwd - set the line width of branches (using
|
|||
|
<code>assign_values_to_branches_edgePar</code>)</li>
|
|||
|
<li>branches_lty - set the line type of branches (using
|
|||
|
<code>assign_values_to_branches_edgePar</code>)</li>
|
|||
|
<li>by_labels_branches_col - set the color of branches with specific
|
|||
|
labels (using <code>branches_attr_by_labels</code>)</li>
|
|||
|
<li>by_labels_branches_lwd - set the line width of branches with
|
|||
|
specific labels (using <code>branches_attr_by_labels</code>)</li>
|
|||
|
<li>by_labels_branches_lty - set the line type of branches with specific
|
|||
|
labels (using <code>branches_attr_by_labels</code>)</li>
|
|||
|
<li>clear_branches - clear branches’ attributes (using
|
|||
|
<code>remove_branches_edgePar</code>)</li>
|
|||
|
<li>clear_leaves - clear leaves’ attributes (using
|
|||
|
<code>remove_branches_edgePar</code>)</li>
|
|||
|
</ul>
|
|||
|
</div>
|
|||
|
<div id="two-simple-trees-to-play-with" class="section level3">
|
|||
|
<h3>Two simple trees to play with</h3>
|
|||
|
<p>For illustration purposes, we will create several small tree, and
|
|||
|
demonstrate these functions on them.</p>
|
|||
|
<div class="sourceCode" id="cb40"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb40-1"><a href="#cb40-1" tabindex="-1"></a>dend13 <span class="ot"><-</span> <span class="fu">c</span>(<span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>) <span class="sc">%>%</span> <span class="co"># take some data</span></span>
|
|||
|
<span id="cb40-2"><a href="#cb40-2" tabindex="-1"></a> dist <span class="sc">%>%</span> <span class="co"># calculate a distance matrix, </span></span>
|
|||
|
<span id="cb40-3"><a href="#cb40-3" tabindex="-1"></a> <span class="fu">hclust</span>(<span class="at">method =</span> <span class="st">"average"</span>) <span class="sc">%>%</span> <span class="co"># on it compute hierarchical clustering using the "average" method, </span></span>
|
|||
|
<span id="cb40-4"><a href="#cb40-4" tabindex="-1"></a> as.dendrogram <span class="co"># and lastly, turn that object into a dendrogram.</span></span>
|
|||
|
<span id="cb40-5"><a href="#cb40-5" tabindex="-1"></a><span class="co"># same, but for 5 leaves:</span></span>
|
|||
|
<span id="cb40-6"><a href="#cb40-6" tabindex="-1"></a>dend15 <span class="ot"><-</span> <span class="fu">c</span>(<span class="dv">1</span><span class="sc">:</span><span class="dv">5</span>) <span class="sc">%>%</span> dist <span class="sc">%>%</span> <span class="fu">hclust</span>(<span class="at">method =</span> <span class="st">"average"</span>) <span class="sc">%>%</span> as.dendrogram</span>
|
|||
|
<span id="cb40-7"><a href="#cb40-7" tabindex="-1"></a></span>
|
|||
|
<span id="cb40-8"><a href="#cb40-8" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">2</span>))</span>
|
|||
|
<span id="cb40-9"><a href="#cb40-9" tabindex="-1"></a>dend13 <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main=</span><span class="st">"dend13"</span>)</span>
|
|||
|
<span id="cb40-10"><a href="#cb40-10" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main=</span><span class="st">"dend15"</span>)</span>
|
|||
|
<span id="cb40-11"><a href="#cb40-11" tabindex="-1"></a><span class="co"># we could have also used plot(dend)</span></span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAADhCAY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XyUOEfr/qzPVT8D/hWVWHDx4cOUu629+85vV3pwYQ6DjDcaPHy8TJ04Uv4MQHaSpu7+rTtdcc415qeMLWrVqZZ5//vnnmvTLu+++a14PGzbM/NXd5pdffrl5frL/ZGZmipb7zDPPiJ5VqIcjOZPwZBVZH4FoCUStv/rWt74lu3btEj05R8eLPvfcc+Lv3Td919/+9rdo4ROtEWAwCh+EegskkhIdG5CYNHmqOiWWHTx4UD788EOzSM/g04cmOlWnZs2aVb48/fTTK5/rWITEeKlEebrQPzxZuU59n+gZhDrpJRyGDx9uxjRs2bJFXnnlFTNOrL7lsB4CCERLIIr9VV5eXjVkHauqZz/7e/mrzedFNATYgxWNdrIiSr0+i07+GKbKeIqLiyuf65PEHq0rr7xSli1bZh7+OCvxDx1KQUFBtXX1+lm1TZpUJQatr1u3rnKVF154ofJ5fZ784Ac/MANGp0+fblbXvVg7d+40zzXhYkIAgfgKRK2/mj9/vrRr10784RWVjaKXbdDJP1xYOY8nERKI/1FQahiUwPvvv+/5e6HMuIBbb73Vu+222zx/z5N5nRiD5R8iNK91MLx/eNDzkxzz2t+D5X355ZcmlMQYLH9XeGVoOojd/9p4OtBTp1mzZpnXuq5/YVGvd+/eleO06jsGyz/V2ZThH170NN4uXbqY13379vX8PVuV2+YJAgjETyBq/ZWORdX+Tge460k5Ol5U+8SuXbvGr3EcqRGD3
|
|||
|
</div>
|
|||
|
<div id="setting-a-dendrograms-labels" class="section level3">
|
|||
|
<h3>Setting a dendrogram’s labels</h3>
|
|||
|
<p>We can get a vector with the tree’s labels:</p>
|
|||
|
<div class="sourceCode" id="cb41"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb41-1"><a href="#cb41-1" tabindex="-1"></a><span class="co"># get the labels:</span></span>
|
|||
|
<span id="cb41-2"><a href="#cb41-2" tabindex="-1"></a>dend15 <span class="sc">%>%</span> labels</span></code></pre></div>
|
|||
|
<pre><code>#> [1] 1 2 5 3 4</code></pre>
|
|||
|
<div class="sourceCode" id="cb43"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb43-1"><a href="#cb43-1" tabindex="-1"></a><span class="co"># this is just like labels(dend)</span></span></code></pre></div>
|
|||
|
<p>Notice how the tree’s labels are not 1 to 5 by order, since the tree
|
|||
|
happened to place them in a different order. We can change the names of
|
|||
|
the labels:</p>
|
|||
|
<div class="sourceCode" id="cb44"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb44-1"><a href="#cb44-1" tabindex="-1"></a><span class="co"># change the labels, and then print them:</span></span>
|
|||
|
<span id="cb44-2"><a href="#cb44-2" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"labels"</span>, <span class="fu">c</span>(<span class="dv">111</span><span class="sc">:</span><span class="dv">115</span>)) <span class="sc">%>%</span> labels</span></code></pre></div>
|
|||
|
<pre><code>#> [1] 111 112 113 114 115</code></pre>
|
|||
|
<div class="sourceCode" id="cb46"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb46-1"><a href="#cb46-1" tabindex="-1"></a><span class="co"># could also be done using:</span></span>
|
|||
|
<span id="cb46-2"><a href="#cb46-2" tabindex="-1"></a><span class="co"># labels(dend) <- c(111:115)</span></span></code></pre></div>
|
|||
|
<p>We can change the type of labels to be characters. Not doing so may
|
|||
|
be a source of various bugs and problems in many functions.</p>
|
|||
|
<div class="sourceCode" id="cb47"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb47-1"><a href="#cb47-1" tabindex="-1"></a>dend15 <span class="sc">%>%</span> labels</span></code></pre></div>
|
|||
|
<pre><code>#> [1] 1 2 5 3 4</code></pre>
|
|||
|
<div class="sourceCode" id="cb49"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb49-1"><a href="#cb49-1" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"labels_to_char"</span>) <span class="sc">%>%</span> labels</span></code></pre></div>
|
|||
|
<pre><code>#> [1] "1" "2" "5" "3" "4"</code></pre>
|
|||
|
<p>We may also change their color and size:</p>
|
|||
|
<div class="sourceCode" id="cb51"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb51-1"><a href="#cb51-1" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">2</span>))</span>
|
|||
|
<span id="cb51-2"><a href="#cb51-2" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"labels_col"</span>, <span class="st">"blue"</span>) <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Change label's color"</span>) <span class="co"># change color </span></span>
|
|||
|
<span id="cb51-3"><a href="#cb51-3" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"labels_cex"</span>, <span class="dv">2</span>) <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Change label's size"</span>) <span class="co"># change color </span></span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAADhCAYAAAAUPMtIAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKx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rqqWwPrrr++Pr7vuutWe5yAEIFA8gYsvvtjef/9923TTTU32Sr3xCxYsMAkthfPOO89/8i8+AqEN69ixY3yJ5qS0yy67+Id8/Q4R4iOAwIqPZVEpqQv99ddft3bt2tmYMWOsefPm/roddtjBrrjiCrvkkkts6623rpLW9ddfb5tttpm1b9/ejjjiCPv888+jOBoC22+//UzdyhtssIF/ipw7d250fqeddjINS82ePdv0RVp99dX9sOMTTzwRxdHG+PHjbZNNNvHpDBs2zG655Rb/pKpyhuGGG26wnj172qqrrmoq8z333BOeKurztddes2OOOcbns+aaa9qOO+5oEyZMqHKtDPbPfvYzPwSx5ZZbmuqYG1544QXbbbfdfF1U5t///vfeQOTGCbdVXnWxi18Y9COgodlWrVrZOuusY4ceemglpmG83M8HHnjAl1f8VPezzjrLvvzyyyjKV199Zb/61a+sd+/evlz9+vWze++9NzpfaONvf/ub77nUcMvmm29u5557ri1fvtxHX7FihW8D1fWaa66xtdZayxo6/FCoHByHQG0EdD9effXVPtqll15qnTp18tuyZ1dddZW//4877rgqydRkv2qzCeeff77/Dui7pIdSPSh16dLFlH9uKMZ+1cVu5KYdbmt0Qd972VTZQNmWk08+2eRLmxsU75xzzjEJI/3JLuTGqWs5NMqxyiqreJulfKZNm+ZtkMogeyRb8+STT+YWodL2e++9Z0OGDPG2Tjave/fu/vcmjDRjxgzP+JBDDvGH/vrXv/p95Zv7J7eWMDT0tyBMp0l/OidFQgkJXHbZZYG7oQI3FFhrrg899JCP67puA2fIAnfzB05g+WMjRozw17/yyiuB+8IE7kvmz2+11Vb+vBMPUfo65wRG4ARY4ERL4H7EfZz11lsvcD1qPp77kffHVDb3Yx44IxY4vzB/zPW4+TjuB97v6/i+++4btG3b1u/fd999UV75G2F5582bFzijEzhB5a9xQwmBEwqB6qY83XCpv/TnP/+533dd1sHGG28cOCHj9xXH+R/4OM6pNsrbCcZAddX5X/ziF1H2ufnqoBNCgRMt/rwTSj7+dtttFzjDFzhj6fePPvro6Pr8DWfQonK44d3A+Z34/TPOOMNH/frrr4Pdd9/dH2vdunXgDG8U3xkrH+eRRx7xx7bZZpso+SuvvDKK54R1xEN8FMRMdXNDMIET476dncCOrmcDAqUk4HxEo/v1s88+qzHrYuxXMTbBCTafp+yYe1AM9tlnn6gMoU0oxn4VYzfyK5RvRy6//HKfd48ePby9dS4efv83v/mNv9SNP
|
|||
|
<p>The function recycles, from left to right, the vector of values we
|
|||
|
give it. We can use this to create more complex patterns:</p>
|
|||
|
<div class="sourceCode" id="cb52"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb52-1"><a href="#cb52-1" tabindex="-1"></a><span class="co"># Produce a more complex dendrogram:</span></span>
|
|||
|
<span id="cb52-2"><a href="#cb52-2" tabindex="-1"></a>dend15_2 <span class="ot"><-</span> dend15 <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb52-3"><a href="#cb52-3" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"labels"</span>, <span class="fu">c</span>(<span class="dv">111</span><span class="sc">:</span><span class="dv">115</span>)) <span class="sc">%>%</span> <span class="co"># change labels</span></span>
|
|||
|
<span id="cb52-4"><a href="#cb52-4" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"labels_col"</span>, <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">2</span>,<span class="dv">3</span>)) <span class="sc">%>%</span> <span class="co"># change color </span></span>
|
|||
|
<span id="cb52-5"><a href="#cb52-5" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"labels_cex"</span>, <span class="fu">c</span>(<span class="dv">2</span>,<span class="dv">1</span>)) <span class="co"># change size</span></span>
|
|||
|
<span id="cb52-6"><a href="#cb52-6" tabindex="-1"></a></span>
|
|||
|
<span id="cb52-7"><a href="#cb52-7" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">2</span>))</span>
|
|||
|
<span id="cb52-8"><a href="#cb52-8" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Before"</span>)</span>
|
|||
|
<span id="cb52-9"><a href="#cb52-9" tabindex="-1"></a>dend15_2 <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"After"</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAADhCAYAAAAUPMtIAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBgE0SQIA9pfFtgo6cKGuhooeilaKH41eDs38Ip+f4At1Rq/sjr6NEwQqb/I/DQqsLvaFUjvAx+eWirddAJZnAj1DFJL0mSg/gcIpPkMBkhoyCSJ8lTZIxk0TpKDjXHliJzZPO50dR5ASNSnzeLvIvod0HG/mdkmOC0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z/7mRQUFIg6za+CLJWX+pWZn58vV155pXz55Zdy/fXXV3aQ+mD+QQABBCwBNUThiy++0D/GVF9yzTXXaJeqZ7FUH6X6JbWoPkv1U2pIhHfxeDyi/tRSV3+ntvvqt9Q2FpcJWF8KFgQaLJCSkqJ6k1r/HnnkEY8VEOk0P/zwQ71PcnKyxxrMrtfdfvvtet3s2bP1ZyuI0p+vvfbaynLccMMNep0VKOnjiouLPSNHjtTrJk6cqPe78cYb9WdrTITex7oLUa+3zpLp9e+9957+/O9//1t/vvzyyyvT5w0CCCCgBKZOnar7B+sslAb5y1/+oj9bN914SkpK9Dr1j/WjUa+3znZVrrPOkut1H330kV5Xn/7OV79VmShvXCMQ5bJ4keqEWOCJJ57QZ5XUuKvDhw9LZmamPPbYY/osk/oFqH4ZqqVJkybywAMP6Pfey3zqEmBti/pluHLlSr3JCsb0r0X1i1GdkleX+latWlXtMHW2TG1Xd/bs379fDh48qLeru3zeeustUXcpqsVbFv2BfxBAIOwFSktL9VlyBZGeni4rVqzQ47BUf3LkyBH529/+Jrfccku9nbx9TH36u6r9Vr0zYEdHCRBgOaq5zCusutR39dVXVxZMXaIbOnSovoV57ty5+nS62qiCHO8gUTVWa9SoUbpDqzzwnDfe0+/Nmzev3KKOU4sajFp1SUxMrPxYdeoINejee1pf5acWday6VMmCAAIIqCllVCCllkcffVS/Vv1H/UhsSIClLh+qpT79XdV+q2qevHePAAGWe9rSiJrk5OTocnjHVnnHM6igRo29Usv777+vOzU1+Ly2RR2rtqlfk+oXZI8ePfRu3uP79u1b7bCqAZN1KVKfUVPTRDz88MP6rkY1eam6q1ENiK+6b7VE+IAAAmEn4B3cfoU1aL1qv6IGqr/66qu6r9q5c6eehqY2HO/4Ue8Pw
|
|||
|
<p>Notice how these “labels parameters” are nested within the nodePar
|
|||
|
attribute:</p>
|
|||
|
<div class="sourceCode" id="cb53"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb53-1"><a href="#cb53-1" tabindex="-1"></a><span class="co"># looking at only the left-most node of the "after tree":</span></span>
|
|||
|
<span id="cb53-2"><a href="#cb53-2" tabindex="-1"></a>dend15_2[[<span class="dv">1</span>]][[<span class="dv">1</span>]] <span class="sc">%>%</span> unclass <span class="sc">%>%</span> str </span></code></pre></div>
|
|||
|
<pre><code>#> int 1
|
|||
|
#> - attr(*, "label")= int 111
|
|||
|
#> - attr(*, "members")= int 1
|
|||
|
#> - attr(*, "height")= num 0
|
|||
|
#> - attr(*, "leaf")= logi TRUE
|
|||
|
#> - attr(*, "nodePar")=List of 3
|
|||
|
#> ..$ lab.col: num 1
|
|||
|
#> ..$ pch : logi NA
|
|||
|
#> ..$ lab.cex: num 2</code></pre>
|
|||
|
<div class="sourceCode" id="cb55"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb55-1"><a href="#cb55-1" tabindex="-1"></a><span class="co"># looking at only the nodePar attributes in this sub-tree:</span></span>
|
|||
|
<span id="cb55-2"><a href="#cb55-2" tabindex="-1"></a>dend15_2[[<span class="dv">1</span>]][[<span class="dv">1</span>]] <span class="sc">%>%</span> <span class="fu">get_nodes_attr</span>(<span class="st">"nodePar"</span>) </span></code></pre></div>
|
|||
|
<pre><code>#> [,1]
|
|||
|
#> lab.col 1
|
|||
|
#> pch NA
|
|||
|
#> lab.cex 2</code></pre>
|
|||
|
<p>When it comes to color, we can also set the parameter “k”, which will
|
|||
|
cut the tree into k clusters, and assign a different color to each label
|
|||
|
(based on its cluster):</p>
|
|||
|
<div class="sourceCode" id="cb57"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb57-1"><a href="#cb57-1" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">2</span>))</span>
|
|||
|
<span id="cb57-2"><a href="#cb57-2" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"labels_cex"</span>, <span class="dv">2</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"labels_col"</span>, <span class="at">value =</span> <span class="fu">c</span>(<span class="dv">3</span>,<span class="dv">4</span>)) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb57-3"><a href="#cb57-3" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Recycles color </span><span class="sc">\n</span><span class="st">from left to right"</span>)</span>
|
|||
|
<span id="cb57-4"><a href="#cb57-4" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"labels_cex"</span>, <span class="dv">2</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"labels_col"</span>, <span class="at">value =</span> <span class="fu">c</span>(<span class="dv">3</span>,<span class="dv">4</span>), <span class="at">k=</span><span class="dv">2</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb57-5"><a href="#cb57-5" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Color labels </span><span class="sc">\n</span><span class="st">per cluster"</span>)</span>
|
|||
|
<span id="cb57-6"><a href="#cb57-6" tabindex="-1"></a><span class="fu">abline</span>(<span class="at">h =</span> <span class="dv">2</span>, <span class="at">lty =</span> <span class="dv">2</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAADhCAYAAAAUPMtIAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448Na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AAEAAAAaAAAAAAACoAIABAAAAAEAAAJYoAMABAAAAAEAAADhAAAAANxLa8wAADrLSURBVHgB7Z0JfFTV9cdPCCQkYd/DviuLtIDKIli3orhRVERFVKwVa0Ut+FFa14/WVtGKC0LdRQUFXHBtoYqKCgpI/wLKIptsYQtrAoQl87+/g2+cGea9zEsmb95kfgeSee/d/fvmnZx377n3pgWMCIUESIAESIAESIAESCBuBCrFLSdmRAIkQAIkQAIkQAIkoARoYPGLQAIkQAIkQAIkQAJxJkADK85AmR0JkAAJkAAJkAAJ0MDid4AESIAESIAESIAE4kyABlacgTI7EiABEiABEiABEqCBxe8ACZAACZAACZAACcSZAA2sOANldiRAAiRAAiRAAiRAA4vfARIgARIgARIgARKIMwEaWHEGyuxIgARIgARIgARIgAYWvwMkQAIkQAIkQAIkEGcCNLDiDJTZkQAJkAAJkAAJkAANLH4HSIAESIAESIAESCDOBGhgxRkosyMBEiABEiABEiABGlj8DpAACZAACZAACZBAnAnQwIozUGZHAiRAAiRAAiRAAjSw+B0gARIgARLwJYGioiJZs2aNHD582Jf1Y6VIwIkADSwnOj4O+/LLLyUtLS3sJz09XWrVqiWnnHKKLFy40He1r1evntZ39erVvqtbaIU+/fRTrWf37t1DL/OYBEjAIwJff/21nHTSSVKtWjVp3bq1ZGdny8CBA+Wnn35yVYPyfpbd6rQ33nhDdcu5557rqh2Rkf/4xz9qPg8//HBkEM99RIAGlo9uRmmqUqlSJWnevLk0a9ZMcnNzZd++fTJnzhzp27evbNiwoTRZMg0JkAAJJIzAO++8I3369JEFCxZIgwYNpEuXLnLo0CGZPn269OvXT44cOZKwurFgEnBDgAaWG1o+jFuzZk19q1u3bp0aVMuXL9deLBhas2bN8mGNWSUSIAESiE4AQ4G33367GlHXXXedQK9999138s0330hGRoasWLFCXn/99eiJeZUEfEaABpbPbkhZq9OqVSs54YQTNJudO3cGs1u8eLGceeaZAoOsffv2cuedd+pboRUBb4j333+/HH/88VK7dm258MILZdKkSRo8depUfYu85pprrOj6iS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msaDsPRMjCfffZZvQbDDPWylDLq+8ADDwTMW3Bg9+7dETXkKQmQgBMBS1ddeeWVTtE0LJbnMvJZxosgXhbxnJoeaM0HOhAvqrj23nvvuXqWI3Xaf//738Df/va3wPbt2zVvS09A70AsAwtlrV27Vq+hHjhHvVA/i4GdvkaiSAML9cfLHfS26eEPfP/99wEYV5s3b9Yy+CsxBDhEaL7ZySzoDsZw33nnnafNQLf0lClT5Oqrrw42Cz4MENNzJMZYkZEjR+qQHLqpzYOoP+gWR7dymzZtNO4ll1wixvARzFaBDBs2TD/NA6yfb775pn5eddVV+olhN
|
|||
|
</div>
|
|||
|
<div id="setting-a-dendrograms-nodesleaves-points" class="section level3">
|
|||
|
<h3>Setting a dendrogram’s nodes/leaves (points)</h3>
|
|||
|
<p>Each node in a tree can be represented and controlled using the
|
|||
|
<code>assign_values_to_nodes_nodePar</code>, and for the special case of
|
|||
|
the nodes of leaves, the <code>assign_values_to_leaves_nodePar</code>
|
|||
|
function is more appropriate (and faster) to use. We can control the
|
|||
|
following properties: pch (point type), cex (point size), and col (point
|
|||
|
color). For pch we can additionally set bg (“background”, although it’s
|
|||
|
really a fill for the shape). When bg is set, the outline of the point
|
|||
|
is defined by col and the internal fill is determined by bg. For
|
|||
|
example:</p>
|
|||
|
<div class="sourceCode" id="cb58"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb58-1"><a href="#cb58-1" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">2</span>,<span class="dv">3</span>))</span>
|
|||
|
<span id="cb58-2"><a href="#cb58-2" tabindex="-1"></a>dend13 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"nodes_pch"</span>, <span class="dv">19</span>) <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"(1) Show the</span><span class="sc">\n</span><span class="st"> nodes (as a dot)"</span>) <span class="co">#1</span></span>
|
|||
|
<span id="cb58-3"><a href="#cb58-3" tabindex="-1"></a>dend13 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"nodes_pch"</span>, <span class="dv">19</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"nodes_cex"</span>, <span class="dv">2</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb58-4"><a href="#cb58-4" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"(2) Show (larger)</span><span class="sc">\n</span><span class="st"> nodes"</span>) <span class="co">#2</span></span>
|
|||
|
<span id="cb58-5"><a href="#cb58-5" tabindex="-1"></a>dend13 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"nodes_pch"</span>, <span class="dv">19</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"nodes_cex"</span>, <span class="dv">2</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"nodes_col"</span>, <span class="dv">3</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb58-6"><a href="#cb58-6" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"(3) Show (larger+colored)</span><span class="sc">\n</span><span class="st"> nodes"</span>) <span class="co">#3</span></span>
|
|||
|
<span id="cb58-7"><a href="#cb58-7" tabindex="-1"></a></span>
|
|||
|
<span id="cb58-8"><a href="#cb58-8" tabindex="-1"></a>dend13 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"leaves_pch"</span>, <span class="dv">21</span>) <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"(4) Show the leaves</span><span class="sc">\n</span><span class="st"> (as empty circles)"</span>) <span class="co">#4</span></span>
|
|||
|
<span id="cb58-9"><a href="#cb58-9" tabindex="-1"></a>dend13 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"leaves_pch"</span>, <span class="dv">21</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"leaves_cex"</span>, <span class="dv">2</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb58-10"><a href="#cb58-10" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"(5) Show (larger)</span><span class="sc">\n</span><span class="st"> leaf circles"</span>) <span class="co">#5</span></span>
|
|||
|
<span id="cb58-11"><a href="#cb58-11" tabindex="-1"></a>dend13 <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb58-12"><a href="#cb58-12" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"leaves_pch"</span>, <span class="dv">21</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb58-13"><a href="#cb58-13" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"leaves_bg"</span>, <span class="st">"gold"</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb58-14"><a href="#cb58-14" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"leaves_cex"</span>, <span class="dv">2</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb58-15"><a href="#cb58-15" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"leaves_col"</span>, <span class="st">"darkred"</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb58-16"><a href="#cb58-16" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"(6) Show (larger+colored+filled)</span><span class="sc">\n</span><span class="st"> leaves"</span>) <span class="co">#6</span></span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAu4AAAHCCAYAAACwm0waAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUE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GG21k999/v7/3t7/9ze69995K0UhON910U2vfvr2ttdZatvPOO1co8Hvuuaf93//9X6V3auNGmF51MPIp+7WR1vQw8lWPHHXUUfbnP//ZqtKB0tMS92sU95iUoJTv/fff31ZbbTV76623bJtttvG9/TD5nTt3tqZNm9o999wT3vKf6vlLQR80aJC3Ahx66KGmsBYtWpTi7+OPP06x3MmaIAvgwoULK/zJuiArnJw6EqG1Xj1/CU3o1PM9++yzvYU/alXU80zxRK2QYRh8QiBJBKZOnWrDhg2zI444wu677z57/fXXvQV97733tvPPP9/q1atnhxxyiJfV9HxLfqXUy6p055132ogRI+zdd99N8Sb5Sx9xk6IdlS35mTVrln9PI3Xfffed/65wv/nmm5TwoulNeeAuJNPvvPNORVgyFnz99dc+fZ988kmFZf7bb7/1lnrVB6ojQqd0KM7Qhc+/+uork0EiG4fQP58QqA0CauOkYP/pT3/y7dkzzzxjr7zyivXr18/OOeccH4WeSf7U2Y46Gb80Cvb999/7dvKjjz6yu+66K+rFt7GSh6iThVxtYDh6JTmQrMlJriRHeqaw9V2foYumN7wXfkoGP/zwwxSdQPWB5ElpCy3z2WRS7byehU5GAdUJkk21+6GTjiFGUacRCuUz3WiofEXlPvqOvis/6TpGpnjlL1qPheFIBwnzpXvZdKDQf6I+HRRcDAist956wRNPPOFT6pTzwFkEAtfoB4cddlhF6i+++OLANfAV1+EXZ5kP9L6zoAVOuMPbgaucgrXXXjv4/e9/HzRv3jxwnYHACWHgBC5wlsCgSZMmQYsWLYLLLrvMv9OrVy//jqvEAmeZCA4++GB/3wlM4Cq3inDdKEDghCRwnYxgzJgxWeN5++23AzcKEKy77rrBVlttFbz//vsVYfAFAkkicMcddwSSQznXwAVuON1/HzBgQLD++uv77y+99JKXOT2POvlxI2bBcccdF7zwwguB5E/Odcq9nLmRuKBLly6BG40LHnvsMf/siiuu8NeuoQ123HHHwE2zCy666KJg66239s/32WefwFnxvbyfcsopgcKIumh6n3rqKR+P66gHTz75pE/jJptsErjORvDwww8HTnnxzyXLDRs2DFxjH5x66qle/tu0aRNsttlmgTMY+OAVV8uWLb3Muw6Lv3fCCScEG264YdCgQYNAec3GIZo+vkNgVQm4jqL/3TrluSIotUGSlz/84Q/+npveEbhRoODNN9+s8KMvaoslb86YFriOeOAMWhXPJWObb765D0e/aWfE8s+cxTmQPOpPv3fJ6osvvujDd53s4Nprr/XpcdNzggcffND7c8p8RbjR9DoF1/t1FvjAKdzBb37zG99mN2rUKDjjjDP8O26EzrevaouV3mwyOXz48MCNGniZPOCAAwLxUJ6aNWsWSH5Vb7lOQKD4JfOjRo3y31UPKQ9uFN/rEdIVJk6cGDhl2nMRN4XRu3dvfy9aj2TTMdLjzaYjuNGRQHkVZ9WfikMumw7kHyboP/V6cCVOQI28h
|
|||
|
<p>And with recycling we can produce more complex outputs:</p>
|
|||
|
<div class="sourceCode" id="cb59"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb59-1"><a href="#cb59-1" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">2</span>))</span>
|
|||
|
<span id="cb59-2"><a href="#cb59-2" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"nodes_pch"</span>, <span class="fu">c</span>(<span class="dv">19</span>,<span class="dv">1</span>,<span class="dv">4</span>)) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"nodes_cex"</span>, <span class="fu">c</span>(<span class="dv">2</span>,<span class="dv">1</span>,<span class="dv">2</span>)) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"nodes_col"</span>, <span class="fu">c</span>(<span class="dv">3</span>,<span class="dv">4</span>)) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb59-3"><a href="#cb59-3" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Adjust nodes"</span>)</span>
|
|||
|
<span id="cb59-4"><a href="#cb59-4" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"leaves_pch"</span>, <span class="fu">c</span>(<span class="dv">19</span>,<span class="dv">1</span>,<span class="dv">4</span>)) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"leaves_cex"</span>, <span class="fu">c</span>(<span class="dv">2</span>,<span class="dv">1</span>,<span class="dv">2</span>)) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"leaves_col"</span>, <span class="fu">c</span>(<span class="dv">3</span>,<span class="dv">4</span>)) <span class="sc">%>%</span></span>
|
|||
|
<span id="cb59-5"><a href="#cb59-5" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Adjust nodes</span><span class="sc">\n</span><span class="st">(but only for leaves)"</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAAEsCAYAAAAfPc2WAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx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rXH0cH2mjRActLSpUudt/b1yiuvtK+XXHKJ3V/zMOO+xIy3sj1WWnatlw6C10uReplRA1dNescmKcYCsRveRc5+ETC/mdmBj+a3n4C5IyaiY
|
|||
|
<p>Notice how recycling works in a depth-first order (which is just left
|
|||
|
to right, when we only adjust the leaves). Here are the node’s
|
|||
|
parameters after adjustment:</p>
|
|||
|
<div class="sourceCode" id="cb60"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb60-1"><a href="#cb60-1" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"nodes_pch"</span>, <span class="fu">c</span>(<span class="dv">19</span>,<span class="dv">1</span>,<span class="dv">4</span>)) <span class="sc">%>%</span></span>
|
|||
|
<span id="cb60-2"><a href="#cb60-2" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"nodes_cex"</span>, <span class="fu">c</span>(<span class="dv">2</span>,<span class="dv">1</span>,<span class="dv">2</span>)) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"nodes_col"</span>, <span class="fu">c</span>(<span class="dv">3</span>,<span class="dv">4</span>)) <span class="sc">%>%</span> <span class="fu">get_nodes_attr</span>(<span class="st">"nodePar"</span>)</span></code></pre></div>
|
|||
|
<pre><code>#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
|
|||
|
#> pch 19 1 4 19 1 4 19 1 4
|
|||
|
#> cex 2 1 2 2 1 2 2 1 2
|
|||
|
#> col 3 4 3 4 3 4 3 4 3</code></pre>
|
|||
|
<p>We can also change the height of of the leaves by using the
|
|||
|
<code>hang.dendrogram</code> function:</p>
|
|||
|
<div class="sourceCode" id="cb62"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb62-1"><a href="#cb62-1" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">3</span>))</span>
|
|||
|
<span id="cb62-2"><a href="#cb62-2" tabindex="-1"></a>dend13 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"leaves_pch"</span>, <span class="dv">19</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"leaves_cex"</span>, <span class="dv">2</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"leaves_col"</span>, <span class="dv">2</span>) <span class="sc">%>%</span> <span class="co"># adjust the leaves</span></span>
|
|||
|
<span id="cb62-3"><a href="#cb62-3" tabindex="-1"></a> hang.dendrogram <span class="sc">%>%</span> <span class="co"># hang the leaves</span></span>
|
|||
|
<span id="cb62-4"><a href="#cb62-4" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Hanging a tree"</span>)</span>
|
|||
|
<span id="cb62-5"><a href="#cb62-5" tabindex="-1"></a>dend13 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"leaves_pch"</span>, <span class="dv">19</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"leaves_cex"</span>, <span class="dv">2</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"leaves_col"</span>, <span class="dv">2</span>) <span class="sc">%>%</span> <span class="co"># adjust the leaves</span></span>
|
|||
|
<span id="cb62-6"><a href="#cb62-6" tabindex="-1"></a> <span class="fu">hang.dendrogram</span>(<span class="at">hang_height =</span> .<span class="dv">6</span>) <span class="sc">%>%</span> <span class="co"># hang the leaves (at some height)</span></span>
|
|||
|
<span id="cb62-7"><a href="#cb62-7" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Hanging a tree (but lower)"</span>)</span>
|
|||
|
<span id="cb62-8"><a href="#cb62-8" tabindex="-1"></a>dend13 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"leaves_pch"</span>, <span class="dv">19</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"leaves_cex"</span>, <span class="dv">2</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"leaves_col"</span>, <span class="dv">2</span>) <span class="sc">%>%</span> <span class="co"># adjust the leaves</span></span>
|
|||
|
<span id="cb62-9"><a href="#cb62-9" tabindex="-1"></a> hang.dendrogram <span class="sc">%>%</span> <span class="co"># hang the leaves</span></span>
|
|||
|
<span id="cb62-10"><a href="#cb62-10" tabindex="-1"></a> <span class="fu">hang.dendrogram</span>(<span class="at">hang =</span> <span class="sc">-</span><span class="dv">1</span>) <span class="sc">%>%</span> <span class="co"># un-hanging the leaves</span></span>
|
|||
|
<span id="cb62-11"><a href="#cb62-11" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Not hanging a tree"</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAu4AAADhCAYAAACX1DA2AAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5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IvZHVyQxvi
|
|||
|
<p>An example of what this function does to the leaves heights:</p>
|
|||
|
<div class="sourceCode" id="cb63"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb63-1"><a href="#cb63-1" tabindex="-1"></a>dend13 <span class="sc">%>%</span> <span class="fu">get_leaves_attr</span>(<span class="st">"height"</span>)</span></code></pre></div>
|
|||
|
<pre><code>#> [1] 0 0 0</code></pre>
|
|||
|
<div class="sourceCode" id="cb65"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb65-1"><a href="#cb65-1" tabindex="-1"></a>dend13 <span class="sc">%>%</span> hang.dendrogram <span class="sc">%>%</span> <span class="fu">get_leaves_attr</span>(<span class="st">"height"</span>)</span></code></pre></div>
|
|||
|
<pre><code>#> [1] 1.35 0.85 0.85</code></pre>
|
|||
|
<p>We can also control the general heights of nodes using
|
|||
|
<code>raise.dendrogram</code>:</p>
|
|||
|
<div class="sourceCode" id="cb67"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb67-1"><a href="#cb67-1" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">3</span>))</span>
|
|||
|
<span id="cb67-2"><a href="#cb67-2" tabindex="-1"></a>dend13 <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"First tree"</span>, <span class="at">ylim =</span> <span class="fu">c</span>(<span class="dv">0</span>,<span class="dv">3</span>))</span>
|
|||
|
<span id="cb67-3"><a href="#cb67-3" tabindex="-1"></a>dend13 <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb67-4"><a href="#cb67-4" tabindex="-1"></a> <span class="fu">raise.dendrogram</span> (<span class="sc">-</span><span class="dv">1</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb67-5"><a href="#cb67-5" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"One point lower"</span>, <span class="at">ylim =</span> <span class="fu">c</span>(<span class="dv">0</span>,<span class="dv">3</span>))</span>
|
|||
|
<span id="cb67-6"><a href="#cb67-6" tabindex="-1"></a>dend13 <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb67-7"><a href="#cb67-7" tabindex="-1"></a> <span class="fu">raise.dendrogram</span> (<span class="dv">1</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb67-8"><a href="#cb67-8" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"One point higher"</span>, <span class="at">ylim =</span> <span class="fu">c</span>(<span class="dv">0</span>,<span class="dv">3</span>))</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAu4AAADhCAYAAACX1DA2AAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBg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Z1Up8bxrbGtMR6+6tya+P7Sl75kr
|
|||
|
<p>If you wish to make the branches under the root have the same height,
|
|||
|
you can use the <code>flatten.dendrogram</code> function.</p>
|
|||
|
</div>
|
|||
|
<div id="setting-a-dendrograms-branches" class="section level3">
|
|||
|
<h3>Setting a dendrogram’s branches</h3>
|
|||
|
<div id="adjusting-all-branches" class="section level4">
|
|||
|
<h4>Adjusting all branches</h4>
|
|||
|
<p>Similar to adjusting nodes, we can also control line width (lwd),
|
|||
|
line type (lty), and color (col) for branches:</p>
|
|||
|
<div class="sourceCode" id="cb68"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb68-1"><a href="#cb68-1" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">3</span>))</span>
|
|||
|
<span id="cb68-2"><a href="#cb68-2" tabindex="-1"></a>dend13 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"branches_lwd"</span>, <span class="dv">4</span>) <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Thick branches"</span>)</span>
|
|||
|
<span id="cb68-3"><a href="#cb68-3" tabindex="-1"></a>dend13 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"branches_lty"</span>, <span class="dv">3</span>) <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Dashed branches"</span>)</span>
|
|||
|
<span id="cb68-4"><a href="#cb68-4" tabindex="-1"></a>dend13 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"branches_col"</span>, <span class="dv">2</span>) <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Red branches"</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAu4AAADhCAYAAACX1DA2AAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqa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1n/swzz4zk5+dHvvvd75p1x40bZ/qTd5Yt4k25Mf3O+3IcWblyZaRbt26RY489NqL9Ufcfmm666SbTV3W/of1q+PDh5vXoP/T9qAT/I+C/gDcgZ45/b7zxRsQLqiPR5wsXLjSZ//jHPzbHYO3Hv/zlL81rXpBt+q7uB/r27WvW97601yjsKaecEjn11FPNPkT3Jb/73e/M+/q67hc0lnj++efNNnW/cfzxx5tjsvdlPbJo0SITTwwYMCBy3HHHmf2Kvu4F8pGLL77YxBO6Td2XaKorDpkzZ07EmwJr9kG6nvflI7Jq1SpzTNf9X4sWLSLTpk0z2+Cf1Agw4p7c9520r6Vz4rwAXLwOLvptvXrSuewPPPCAPProo+YbtJ5Sj3771W/NXmcSL4iXn/3sZ9VXiz3+v//7PzMSuH79evF2JOZ1Hb33OqToCIGOnj/88MMmfy/wlr/97W+xdXXevY72jR49WoqKiszrkyZNEi/gMN/Wb7vttlhZ9E0v6BcdMdRv98uWLRNvp2LW15HIn//853LzzTebUYbFixebU4ma70MPPVRjXl8scx4gYJmAdxA2/UnPUnkHaXnxxRdNf/a+FMvLL78s3pdcM9r+ve99T5566im55ZZbYlPZdKRLz
|
|||
|
<p>We may also use recycling to create more complex patterns:</p>
|
|||
|
<div class="sourceCode" id="cb69"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb69-1"><a href="#cb69-1" tabindex="-1"></a><span class="co"># Produce a more complex dendrogram:</span></span>
|
|||
|
<span id="cb69-2"><a href="#cb69-2" tabindex="-1"></a>dend15 <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb69-3"><a href="#cb69-3" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"branches_lwd"</span>, <span class="fu">c</span>(<span class="dv">4</span>,<span class="dv">1</span>)) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb69-4"><a href="#cb69-4" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"branches_lty"</span>, <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">1</span>,<span class="dv">3</span>)) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb69-5"><a href="#cb69-5" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"branches_col"</span>, <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">2</span>,<span class="dv">3</span>)) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb69-6"><a href="#cb69-6" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Complex branches"</span>, <span class="at">edge.root =</span> <span class="cn">TRUE</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAADhCAYAAAByfIirAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBgE0SQIA9pfFtgo6cKGuhooeilaK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LFLi/E3LN
|
|||
|
<p>Notice how the first branch (the root) is considered when going
|
|||
|
through and creating the tree, but it is <strong>ignored</strong> in the
|
|||
|
actual plotting (this is actually a “missing feature” in
|
|||
|
<code>plot.dendrogram</code>).</p>
|
|||
|
</div>
|
|||
|
<div id="coloring-branches-based-on-clustering" class="section level4">
|
|||
|
<h4>Coloring branches based on clustering</h4>
|
|||
|
<p>We may also control the colors of the branches based on using
|
|||
|
clustering:</p>
|
|||
|
<div class="sourceCode" id="cb70"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb70-1"><a href="#cb70-1" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">2</span>))</span>
|
|||
|
<span id="cb70-2"><a href="#cb70-2" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"branches_k_color"</span>, <span class="at">k =</span> <span class="dv">3</span>) <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Nice defaults"</span>)</span>
|
|||
|
<span id="cb70-3"><a href="#cb70-3" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"branches_k_color"</span>, <span class="at">value =</span> <span class="dv">3</span><span class="sc">:</span><span class="dv">1</span>, <span class="at">k =</span> <span class="dv">3</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb70-4"><a href="#cb70-4" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Controlling branches' colors</span><span class="sc">\n</span><span class="st">(via clustering)"</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAADhCAYAAAAUPMtIAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBq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I+6Q+GrZsqX/acTt3NIEAmJPio4AAis6lpQEAQhAoFkJ/Pa3v7WPP/7YtthiC3vzzTe96Jk/f74XWqr4wgsvjLx+zTZ8//33kZdbqMA99tjDvv32W3v++ecLZeF8xAQ22GADX+J6660XccnVXRwCq7r7n9ZDAAIVQmDlypV2/fXXe2svv/xy6969uz/WEtJ1111nZ555pp1wwgm1WnPrrbfa4MGD/XLi1ltvbRdccIGtWLEim2eXXXYxLcXNnj3bJGzWWmst22mnneyZZ57xeTR79fvf/94fa4kwLNudfvrpfibtjjvu8GJvs802s9dff93nK1ZntvICBzNnzvRl/+xnP/M5ZsyY4d+fe+65duONN/rlULX58MMPNy2XhvTFF1/YL37xC9My1+abb2433HCDnXjiif5ezfDVlyRSDzroIM9p2223NS2ZhVSorRKdv/71r00M11hjDevdu7edfPLJtnz5cn9rqXbPmzfPfvrTn1q3bt38kq/68NVXXw3VZ1+1TLv77rv7JeH+/fvbCy+8kL2mgz/84Q/eBtmy884727333lvrusT3JptsYm3btrV1113XjjjiCBMzJdm+2mqr2ZZbblnrntw3pdjZmL7XZ09L3hJ566+/vh122GH2/vvvZ6suxP+jjz7yedUWtalXr1529dVXZ+9LxIFzlCRBAAIQgEDCCbgvnYz70vA///73v4ta+7vf/S6bf/vtt8+4ZTf/3i0lZu91girjvlgzzjcm4wRGxokwn8d90WXcEmTGfWFmnGDx55yoyagcpUMPPdSfa9euXcZ9oWecP1jmm2++yZRSpxM9/t7LLrvMl5X//rHHHvPXd9hhB3/94Ycf9u9lq5thyTgx4usTi1NOOcXn0a8DDzzQ51t99dUzQ4YMybRq1SrTvn17f86JkWy+3IPQDrc0lnEiMeOEic+vsp988kmfNeTJb+uVV17p82611VYZJwaznM4++2x/Xyl2f/XVVxknLHw5PXr0yDix5o9ly7Jly3w5a6+9tj/XoUOHzNChQzNuidi/d/53GSfyfB4nJv05tVcclFdteOCBB/z1hx56yL/fcccdM06IZ+s57rjj/HX9+vrrrzNOfGff5x6UYmcpfd+5c2dvxzvvvOOLd6Lcf/Zkq9oTPmv6PH344Yc+TyH+xx9/vC9L7EeNGpVx/3D4905Y5poe67HFWjuVQwACEIBASQSeeOIJ/wXSpk2bovn1hSiBoS+u++67z+d3Ow69GNK5u+++25+TaNH7MWPG+PfOxyvTokULf84tRfpzv/nNb/z7kSNH+vf6Fb703IxWxi3nZST4Sq0zX1Dlvy8ksNTu9957z9swfvx4b5MEidLcuXP9e7Xl7bff9udCOTo3a9Ysfy7/V2iHmxHKihWJDt0jwakU8uS2VecfeeSRzCWXXJJZtGiR3mZuuummWvcFgVWf3W7Gxd/jZg29oFU5I0aM8HUGm4PAuuaaa3S5FudPPvnEnwvC5NFHH/XvJazUhsDn5z//uX+vPpRQl3hzM5IZCZxSUjE7S+37fIElxrJTYkmfI9l1wAEH+HNHH320N60Qfwl753+YmTJlSsbNxGX+8Y9/ZCSuFixYUEqTypKHJULXuyQIQAACSSegHVhKWoJaunRpveZqiU9+TFp22X///X3eDTfc0Pbdd19//Oyzz9a6f++99/bv3Ze5XybTm1LCP7gZF
|
|||
|
<div class="sourceCode" id="cb71"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb71-1"><a href="#cb71-1" tabindex="-1"></a><span class="co"># This is like using the `color_branches` function</span></span></code></pre></div>
|
|||
|
</div>
|
|||
|
<div id="adjusting-branches-based-on-labels" class="section level4">
|
|||
|
<h4>Adjusting branches based on labels</h4>
|
|||
|
<p>The most powerful way to control branches is through the
|
|||
|
<code>branches_attr_by_labels</code> function (with variations through
|
|||
|
the <code>set</code> function). The function allows you to change
|
|||
|
col/lwd/lty of branches if they match some “labels condition”. Follow
|
|||
|
carefully:</p>
|
|||
|
<div class="sourceCode" id="cb72"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb72-1"><a href="#cb72-1" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">2</span>))</span>
|
|||
|
<span id="cb72-2"><a href="#cb72-2" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"by_labels_branches_col"</span>, <span class="at">value =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">4</span>)) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb72-3"><a href="#cb72-3" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Adjust the branch</span><span class="sc">\n</span><span class="st"> if ALL (default) of its</span><span class="sc">\n</span><span class="st"> labels are in the list"</span>)</span>
|
|||
|
<span id="cb72-4"><a href="#cb72-4" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"by_labels_branches_col"</span>, <span class="at">value =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">4</span>), <span class="at">type =</span> <span class="st">"any"</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb72-5"><a href="#cb72-5" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Adjust the branch</span><span class="sc">\n</span><span class="st"> if ANY of its</span><span class="sc">\n</span><span class="st"> labels are in the list"</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAADhCAYAAAAUPMtIAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg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4HjDgZ8ZtNgwprn5uIZAPRBAXiGv6uF9Wus2omDVmniJ9QVjUX25S9HRl3o4DuGTTz5xfibGSpK9kYKfSbFX/ZPCUKqC5X95xs/lKxK///3vzTbogAMOsDyzZ882RSHYg8UPNuOic+fO8dOhD1L0pFQqyKZJSp3+dFyFlB+/ZBg/U+giV1GUciUlVSE3Prdepc2YMcNJSZVtmjYUXHfddc7Peikpbovd+H9S+kIIeXT/2WefWbQUr/WF3PpDv4NCt75nSYdA2gggr5BXaXtPpqE9KFhpGIW8NsgQ3dsFWeyZZ57pL
|
|||
|
<p>We can use this to change the size/type/color of the branches:</p>
|
|||
|
<div class="sourceCode" id="cb73"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb73-1"><a href="#cb73-1" tabindex="-1"></a><span class="co"># Using "Inf" in "TF_values" means to let the parameters stay as they are.</span></span>
|
|||
|
<span id="cb73-2"><a href="#cb73-2" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">3</span>))</span>
|
|||
|
<span id="cb73-3"><a href="#cb73-3" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"by_labels_branches_col"</span>, <span class="at">value =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">4</span>), <span class="at">TF_values =</span> <span class="fu">c</span>(<span class="dv">3</span>,<span class="cn">Inf</span>)) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb73-4"><a href="#cb73-4" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Change colors"</span>)</span>
|
|||
|
<span id="cb73-5"><a href="#cb73-5" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"by_labels_branches_lwd"</span>, <span class="at">value =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">4</span>), <span class="at">TF_values =</span> <span class="fu">c</span>(<span class="dv">8</span>,<span class="dv">1</span>)) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb73-6"><a href="#cb73-6" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Change line width"</span>)</span>
|
|||
|
<span id="cb73-7"><a href="#cb73-7" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"by_labels_branches_lty"</span>, <span class="at">value =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">4</span>), <span class="at">TF_values =</span> <span class="fu">c</span>(<span class="dv">3</span>,<span class="cn">Inf</span>)) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb73-8"><a href="#cb73-8" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Change line type"</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAu4AAADhCAYAAACX1DA2AAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9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R4p5se/GXv/zFJNB6gO72splkIbYhli5dapJut6fNHLjrTlp39HqQoZ+P3Q7oNkuXrcnMuHHjzDZGt1uPPvqo6XTQciOJu
|
|||
|
</div>
|
|||
|
<div id="highlighting-branches-different-heights-using-line-width-and-color" class="section level4">
|
|||
|
<h4>Highlighting branches’ different heights using line width and
|
|||
|
color</h4>
|
|||
|
<p>The <code>highlight_branches</code> function helps to more easily see
|
|||
|
the topological structure of a tree, by adjusting branches appearence
|
|||
|
(color and line width) based on their height in the tree. For
|
|||
|
example:</p>
|
|||
|
<div class="sourceCode" id="cb74"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb74-1"><a href="#cb74-1" tabindex="-1"></a>dat <span class="ot"><-</span> iris[<span class="dv">1</span><span class="sc">:</span><span class="dv">20</span>,<span class="sc">-</span><span class="dv">5</span>]</span>
|
|||
|
<span id="cb74-2"><a href="#cb74-2" tabindex="-1"></a>hca <span class="ot"><-</span> <span class="fu">hclust</span>(<span class="fu">dist</span>(dat))</span>
|
|||
|
<span id="cb74-3"><a href="#cb74-3" tabindex="-1"></a>hca2 <span class="ot"><-</span> <span class="fu">hclust</span>(<span class="fu">dist</span>(dat), <span class="at">method =</span> <span class="st">"single"</span>)</span>
|
|||
|
<span id="cb74-4"><a href="#cb74-4" tabindex="-1"></a>dend <span class="ot"><-</span> <span class="fu">as.dendrogram</span>(hca)</span>
|
|||
|
<span id="cb74-5"><a href="#cb74-5" tabindex="-1"></a>dend2 <span class="ot"><-</span> <span class="fu">as.dendrogram</span>(hca2)</span>
|
|||
|
<span id="cb74-6"><a href="#cb74-6" tabindex="-1"></a></span>
|
|||
|
<span id="cb74-7"><a href="#cb74-7" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">3</span>))</span>
|
|||
|
<span id="cb74-8"><a href="#cb74-8" tabindex="-1"></a>dend <span class="sc">%>%</span> highlight_branches_col <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Coloring branches"</span>)</span>
|
|||
|
<span id="cb74-9"><a href="#cb74-9" tabindex="-1"></a>dend <span class="sc">%>%</span> highlight_branches_lwd <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Emphasizing line-width"</span>)</span>
|
|||
|
<span id="cb74-10"><a href="#cb74-10" tabindex="-1"></a>dend <span class="sc">%>%</span> highlight_branches <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Emphasizing color</span><span class="sc">\n</span><span class="st"> and line-width"</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAADhCAYAAAAUPMtIAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZ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vPBprR441QbKqohY5ua27YpbV5fU
|
|||
|
<p>Tanglegrams are even easier to compare when using</p>
|
|||
|
<div class="sourceCode" id="cb75"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb75-1"><a href="#cb75-1" tabindex="-1"></a><span class="fu">library</span>(viridis)</span>
|
|||
|
<span id="cb75-2"><a href="#cb75-2" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">3</span>))</span>
|
|||
|
<span id="cb75-3"><a href="#cb75-3" tabindex="-1"></a>dend <span class="sc">%>%</span> highlight_branches_col <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Coloring branches </span><span class="sc">\n</span><span class="st"> (default is reversed viridis)"</span>)</span>
|
|||
|
<span id="cb75-4"><a href="#cb75-4" tabindex="-1"></a>dend <span class="sc">%>%</span> <span class="fu">highlight_branches_col</span>(<span class="fu">viridis</span>(<span class="dv">100</span>)) <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"It is better to use </span><span class="sc">\n</span><span class="st"> lighter colors in the leaves"</span>)</span>
|
|||
|
<span id="cb75-5"><a href="#cb75-5" tabindex="-1"></a>dend <span class="sc">%>%</span> <span class="fu">highlight_branches_col</span>(<span class="fu">rev</span>(<span class="fu">magma</span>(<span class="dv">1000</span>))) <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"The magma color pallatte</span><span class="sc">\n</span><span class="st"> is also good"</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAAEsCAYAAAAfPc2WAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSF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sSmKP6mKIFTTz1V39vM7CkDWtezGq0wdt99d90+zPv7L37xC30PRvu86aabzCgdv7iHjx492sC9Fvf4M8880xg0aJCW969//Us/bw4++GB9r8e9dc8999Rx0Z6GDh2q2xTio70rA8z4yU9+onXJvMefeOKJWg9xH7/88st1XOSjrKxMpwOZyjjryA8OlGGl84RnA3To2Wef1dfd2r6pxwjkFMZNvxAezzLodP/+/bWuIf9weK7g+YBruH/85z//MaBTKCd07I033tDH6mXLMSyeoeY94KmnngrRY7dnk044Cf+xB0vVFN4w1Q1elBKoMxFlEIlqgPoYQ3qqAesenyeffFIwNGh/E7/44ovlxz/+se7hUcaI7g3TkdV/sOIhH/Hs7uijj9ZvJ8qQknfeeUeHffjhh0UZW/otGuPfqk3Yo+lz9LbhrQhvP6+88kpHGKXEuvdLKZm27KdNmybIE+SbrqSkRMtXBqBMmTJFe48fP16UMaffONTDMuStWxln+i0J+fnkk0/k1Vdf1fGRvjI0RSmSlvHWW2+JevDKrbfeqsOoG4yZJH99SABt7
|
|||
|
<div class="sourceCode" id="cb76"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb76-1"><a href="#cb76-1" tabindex="-1"></a>dl <span class="ot"><-</span> <span class="fu">dendlist</span>(dend, dend2)</span>
|
|||
|
<span id="cb76-2"><a href="#cb76-2" tabindex="-1"></a><span class="fu">tanglegram</span>(dl, <span class="at">sort =</span> <span class="cn">TRUE</span>, <span class="at">common_subtrees_color_lines =</span> <span class="cn">FALSE</span>, <span class="at">highlight_distinct_edges =</span> <span class="cn">FALSE</span>, <span class="at">highlight_branches_lwd =</span> <span class="cn">FALSE</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAAEsCAYAAAAfPc2WAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRp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EBX3nllYO//Mu/7L1///2///fBj/3Yjw3+5E/+ZECp+Id/+IfhNVz/y1/+cnnZSV1DuIJ0/bf/9t+ScA3R2ppvPvrRjw7+5m/+ptzcd3/3d/d+kwzuL3vZywbf+MY3Bocffvia9v0BsGz/L9d0MnckAgtC4I477mi9UhKsVlhyZyIwGgEK0vve977BNddcUwagt771raMPnvITCsHOO+9cXpqg5n3ta18rZAvh+ru/+7thy9I1X/nKV8rLToQr0om2yFpThRuenG82HQJf/epXB/EL3XeRitpHnHTSScNmHvnIRw68qKdS1BmJQCIwOQJJsCbHLM9IBAZ8WYscfAyiXg996EML+jxaQbioXLXRGeEy8ytmfyFXP/ADP1BIF5UL4ao9Zfk4Nw8C1MsPf/jDww5TOeeZHk5yNYQ63yQCEyOQBGtiyPKEROCbCGzk4BPpUylUQdEKwkXhonhF/Mu//Ev5zOfCgByEi8L1/d///Um4Aqwl3956661DMr3DDjsMHvzgBy95j7N7icDqIpAEa4mf/RlnnDFQb8lguIrx6U9/uvg8cpr4+k+fGZkx2Uv8/d///dC/hXAp9xDxr//6r+UzypdAuJCsSCv+j//xPwZmR2YsFwLSwHfeeWfpFN8VH2BGI
|
|||
|
<div class="sourceCode" id="cb77"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb77-1"><a href="#cb77-1" tabindex="-1"></a><span class="fu">tanglegram</span>(dl)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAAEsCAYAAAAfPc2WAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f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D6mePZSeCfEYt8CONWDw8FXTxrPqx/r9Vt4biXeANh8vV7/+/16ffMD1N8AuKD/A/8leAvFY9bLAAAAOGVYSWZNTQAqAAAACAABh2kABAAAAAEAAAAaAAAAAAACoAIABAAAAAEAAAJYoAMABAAAAAEAAAEsAAAAAAaSlAMAAEAASURBVHgB7J0H3BTV1cYvvYPSEQQENYoaCxbs2MWKJXaDGiXRqJ+K3cReYtTYW6xJrLFGxa5gC3ZFETUKitJEOkgv3/4v3JfZ2Ta7O7M7u/ucH8u0O7c8M+/MM+ece0695QkxEiEgBISAEBACQkAICIHQEKgfWk2qSAgIASEgBISAEBACQsAiIIKlG0EICAEhIASEgBAQAiEjIIIVMqCqTggIASEgBISAEBACIli6B4SAEBACQkAICAEhEDICIlghA6rqhIAQEAJCQAgIASEggqV7QAgIASEgBISAEBACISMgghUyoKpOCAgBISAEhIAQEAIiWLoHhIAQEAJCQAgIASEQMgIiWCEDquqEgBAQAkJACAgBISCCpXtACAgBISAEhIAQEAIhIyCCFTKgqk4ICAEhIASEgBAQAiJYugeEgBAQAkJACAgBIRAyAiJYIQOq6oSAEBACQkAICAEhIIKle0AICAEhIASEgBAQAiEjIIIVMqCqTggIASEgBISAEBACIli6B4SAEBACQkAICAEhEDICIlghA6rqhIAQEAJCQAgIASEggqV7QAgIASEgBISAEBACISMgghUyoKpOCAgBISAEhIAQEAIiWLoHhIAQEAJCQAgIASEQMgIiWCEDquqEgBAQAkJACAgBISCCpXtACAgBISAEhIAQEAIhIyCCFTKgqk4ICAEhIASEgBAQAiJYugeEgBAQAkJACAgBIRAyAiJYIQOq6oSAEBACQkAICAEhIIKle0AICAEhIASEgBAQAiEjIIIVMqCqTggIASEgBISAEBACIli6B4SAEBACQkAICAEhEDICIlghA6rqhIAQEAJCQAgIASEggqV7QAgIASEgBISAEBACISMgghUyoKpOCAgBISAEhIAQEAIiWLoHhIAQEAJCQAgIASEQMgIiWCEDquqEgBAQAkJACAgBISCCpXtACAgBISAEhIAQEAIhIy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Tt3rtlnn31M/fpK+hEcvcJLrr766uaTTz4xO+64oznhhBOS3B4I/Ep0fSddu3Z1q1rGFAERrJheGHUr3gjg94WD+yabbGJQ1UuEQDUhQJBRfBohVmQs4CcpDQJdunQxaKdOPfXUpI9K/K68BKs0vVErxSAgglUMejq3JhEg0vWRRx5pzjzzTHPWWWeZG2+80fTu3TtULJYtXGLmfjUt1DpVWXUi0HK9dqZ+k3Af5b/5zW9Mz549zSuvvGIwz0uEgBDIH4Fw/yrzb19nCIGiESDy9H//+9+i68lUwdZbb50U9I/QcXfddZeNdn3vvfdGko9wzudTzCcHPJapS9ovBOoQ2PSp35g2m4frjwO5evvtt82f//xnc/rpp9e15Vb4GyDKuyQaBAjHoBCV0WBbylpFsEqJttqKBIG11lrLPPHEE5HUTaVbbbVVko8Xp
|
|||
|
<div class="sourceCode" id="cb78"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb78-1"><a href="#cb78-1" tabindex="-1"></a><span class="fu">tanglegram</span>(dl, <span class="at">fast =</span> <span class="cn">TRUE</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAAEsCAYAAAAfPc2WAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSI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ASURBVHgB7Z0HvBTV2YePvWEIIr0oShEjWEBaQKkiiIAdkWYJftagRBSNGmOMQWOLUTSKXWJvUQEBQVFARKWqKFVAQDQCggUlfj7HnJu5e/fund2d2Z3Z/Z/fb+7Mzs6cOeeZvTv/fc973ne7H38qRkUEREAEREAEREAERCAwAtsHVpMqEgEREAEREAEREAERsAQksPRBEAEREAEREAEREIGACUhgBQxU1YmACIiACIiACIiABJY+AyIgAiIgAiIgAiIQMAEJrICBqjoREAEREAEREAERkMDSZ0AEREAEREAEREAEAiYggRUwUFUnAiIgAiIgAiIgAhJY+gyIgAiIgAiIgAiIQMAEJLACBqrqREAEREAEREAEREACS58BERABERABERABEQiYgARWwEBVnQiIgAiIgAiIgAhIYOkzIAIiIAIiIAIiIAIBE5DAChioqhMBERABERABERABCSx9BkRABERABERABEQgYAISWAEDVXUiIAIiIAIiIAIiIIGlz4AIiIAIiIAIiIAIBExAAitgoKpOBERABERABERABCSw9BkQAREQAREQAREQgYAJSGAFDFTViYAIiIAIiIAIiIAElj4DIiACIiACIiACIhAwAQmsgIGqOhEQAREQAREQARGQwNJnQAREQAREQAREQAQCJiCBFTBQVScCIiACIiACIiACElj6DIiACIiACIiACIhAwAQksAIGqupEQAREQAREQAREQAJLnwEREAEREAEREAERCJiABFbAQFWdCIiACIiACIiACEhg6TMgAiIgAiIgAiIgAgETkMAKGKiqEwEREAEREAEREAEJLH0GREAEREAEREAERCBgAhJYAQNVdSIgAiIgAiIgAiIggaXPgAiIgAiIgAiIgAgETEACK2Cgqk4EREAEREAEREAEJLD0GRABERABERABERCBgAlIYAUMVNWJgAiIQKEQ6N+/v1mwYEGhdEf9EIGcEpDAyiluXayQCCxdutT07du3kLqkvohACYExY8aYDz74wHz//fcl+7QhAiLgn8CO/g/VkSIgAo7Atm3bzDXXXGM2bdrkdgW63rx5s5k7d26gdaqywiRw8MEHm0qVKgXaucWLF5uFCxea7t27B1qvKhOBYiIggVVMd7tA+9q1a1fTsGHD0Hr397//3ey4Y+l/lVGjRplzzjnHXH311aFcF4HFA05FBCoisP/++wcqsPjxcOmll5qbbrrJ3HLLLWbDhg1lmvDDDz+Y888/v8x+7QiGAD+upkyZYnbddddgKlQteSFQ+qmRlybooiKQHYH169fbh0F2tZR/9g477FDqzVmzZpnPP//cirqtW7eaLVu2mD322KPUMdm+2G677bKtQucXCYGgPyt8nmvWrGluvPFGM2PGDLNu3TrTqVOnUjT5n+AHhko4BM4888xwKlatOSUggZVT3LpYGAR22203wzBJrgri6rvvvrPWqyVLlph//etfpl+/foFevlq1auakk04KtE5VVpgEKleuHGjHfvGLX5g77rjD1nnZZZeZU045pUz9iLpc/s+VaUCB72DIN2jhXODIItm97X78qUSyZWqUCPgk0KZNGzNz5kyfRwd7GD4qEyZMCLZS1SYCIlDUBDp27Gi/V3bZZZei5hD3zmsWYdzvoNqfVwISV3nFr4uLgAiIQGQJSGBF9taoYSIgAiIgAiIgAnEloCHCuN65Imn3xIkTzaBBg8w+++xTbo/fe+896xNV7gF6QwREQARiRAAfrAMOOKDM7GW68PHHH9v4ZNWrV49Rj4qzqXJyL877Hpte16pVy/Tq1cvcc8895bYZHywVERABESgUAi1btizXBwu/T4VviMed1hBhPO6TWikCIiACOSPwn//8x7z66qvmhRdeMGyriIAIpE9AAit9ZjpDBMy///1v889//tOa6oVDBAqNAEFGCXa5bNkym7Gg0Pqn/ohALghoiDAXlHWNgiJApOvTTjvN/O53vzOXXHKJue222wzRtIMsXAMRpyICFRHYa6+9TGIw3IrOqeh9YrDtu+++Bh/I5557rqLD9b4IiEASAhJYSaBoV7wIEHl6+vTpoTW6bdu2pYL+EToOnzCiXd93332h5CMkOj3DMyoiUBGB3r17289iRcel8z7i6o033jBXXnmlueiii8qcyv8AUd5VwiGwceNGoxCV4bDNZa0SWLmkrWuFQqBBgwbm6aefDqVuKm3dunUpCwF5CevWrWv+8Ic/mNWrV5saNWqEdm1VLAL5IIDAb9++vRVRfP4To7njlxXm/1w++hyla2KV3H57efBE6Z5k0hYJrEyo6ZxIEci1pYdEtyRjRmCNHz/ejB492lx77bWBMtlzzz3NIYccEmidqqwwCfBZCbr88Y9/NH369DFVqlSxQ4WJ9TMkiZ+WigiIQPkEJLDKZ6N3RCApgW+++cbmHnzggQfM5MmTDWktgi4kj27VqlXQ1ao+EfBF4LrrrjOPPPKInUF49913+zpHB4mACJQmIIFVmodeiUCFBLAY3Hjjj
|
|||
|
<div class="sourceCode" id="cb79"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb79-1"><a href="#cb79-1" tabindex="-1"></a>dl <span class="ot"><-</span> <span class="fu">dendlist</span>(<span class="fu">highlight_branches</span>(dend), <span class="fu">highlight_branches</span>(dend2))</span>
|
|||
|
<span id="cb79-2"><a href="#cb79-2" tabindex="-1"></a><span class="fu">tanglegram</span>(dl, <span class="at">sort =</span> <span class="cn">TRUE</span>, <span class="at">common_subtrees_color_lines =</span> <span class="cn">FALSE</span>, <span class="at">highlight_distinct_edges =</span> <span class="cn">FALSE</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAAEsCAYAAAAfPc2WAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu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ZV5RKlhcdSEfPpiaBw0aZF+MBUVLCBcKF4qXRENDg/2O7wkeyEK4ULi22GILJVwCVpFvp06dmiDT/fr1MzvssEORj1iHpwhULgKaIiziez/qxe+aRu+/So1je80wqxr3M5fv9qdKhSDj6167dm3CvwXhotxDWEC4IFmSVtxyyy1t+jPseN1fGATmzp2bmM2H74pJFh06dCjMYLRXRUARSCCgKcIEFKXzpkNNB7OmYY35/nanmtrq2tIZeFwjbRhnDtmstcE2rubLu
|
|||
|
<div class="sourceCode" id="cb80"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb80-1"><a href="#cb80-1" tabindex="-1"></a><span class="co"># dend %>% set("highlight_branches_col") %>% plot</span></span>
|
|||
|
<span id="cb80-2"><a href="#cb80-2" tabindex="-1"></a></span>
|
|||
|
<span id="cb80-3"><a href="#cb80-3" tabindex="-1"></a>dl <span class="ot"><-</span> <span class="fu">dendlist</span>(dend, dend2) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"highlight_branches_col"</span>)</span>
|
|||
|
<span id="cb80-4"><a href="#cb80-4" tabindex="-1"></a><span class="fu">tanglegram</span>(dl, <span class="at">sort =</span> <span class="cn">TRUE</span>, <span class="at">common_subtrees_color_lines =</span> <span class="cn">FALSE</span>, <span class="at">highlight_distinct_edges =</span> <span class="cn">FALSE</span>)</span></code></pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div id="changing-a-dendrograms-structure" class="section level3">
|
|||
|
<h3>Changing a dendrogram’s structure</h3>
|
|||
|
<div id="rotation" class="section level4">
|
|||
|
<h4>Rotation</h4>
|
|||
|
<p>A dendrogram is an object which can be rotated on its hinges without
|
|||
|
changing its topology. Rotating a dendrogram in base R can be done using
|
|||
|
the <code>reorder</code> function. The problem with this function is
|
|||
|
that it is not very intuitive. For this reason the <code>rotate</code>
|
|||
|
function was written. It has two main arguments: the “object” (a
|
|||
|
dendrogram), and the “order” we wish to rotate it by. The “order”
|
|||
|
parameter can be either a numeric vector, used in a similar way we would
|
|||
|
order a simple character vector. Or, the order parameter can also be a
|
|||
|
character vector of the labels of the tree, given in the new desired
|
|||
|
order of the tree. It is also worth noting that some order are
|
|||
|
impossible to achieve for a given tree’s topology. In such cases, the
|
|||
|
function will do its “best” to get as close as possible to the requested
|
|||
|
rotation.</p>
|
|||
|
<div class="sourceCode" id="cb81"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb81-1"><a href="#cb81-1" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">3</span>))</span>
|
|||
|
<span id="cb81-2"><a href="#cb81-2" tabindex="-1"></a>dend15 <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb81-3"><a href="#cb81-3" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"labels_colors"</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb81-4"><a href="#cb81-4" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"branches_k_color"</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb81-5"><a href="#cb81-5" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"First tree"</span>)</span>
|
|||
|
<span id="cb81-6"><a href="#cb81-6" tabindex="-1"></a>dend15 <span class="sc">%>%</span></span>
|
|||
|
<span id="cb81-7"><a href="#cb81-7" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"labels_colors"</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb81-8"><a href="#cb81-8" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"branches_k_color"</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb81-9"><a href="#cb81-9" tabindex="-1"></a> <span class="fu">rotate</span>(<span class="fu">as.character</span>(<span class="dv">5</span><span class="sc">:</span><span class="dv">1</span>)) <span class="sc">%>%</span> <span class="co">#rotate to match labels new order</span></span>
|
|||
|
<span id="cb81-10"><a href="#cb81-10" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Rotated tree</span><span class="sc">\n</span><span class="st"> based on labels"</span>)</span>
|
|||
|
<span id="cb81-11"><a href="#cb81-11" tabindex="-1"></a>dend15 <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb81-12"><a href="#cb81-12" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"labels_colors"</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb81-13"><a href="#cb81-13" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"branches_k_color"</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb81-14"><a href="#cb81-14" tabindex="-1"></a> <span class="fu">rotate</span>(<span class="dv">5</span><span class="sc">:</span><span class="dv">1</span>) <span class="sc">%>%</span> <span class="co"># the fifth label to go first is "4"</span></span>
|
|||
|
<span id="cb81-15"><a href="#cb81-15" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Rotated tree</span><span class="sc">\n</span><span class="st"> based on order"</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAu4AAADhCAYAAACX1DA2AAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFc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MXXnjB0YR7yZIldvn6y5g99o45f95Zt26ds3btWrvue++95/zgBz9wzj//fMec3+5MnTr1mMRdNz58+HDnhhtusOVo4q4/EMzedGf//v3Od77zHWfUqFGO2etvf1RcffXVTkNl2Q3wHwIpKkCcp2jHx6nZXJwar0MXbAcBBBCIk8Dbb78tZg+23HHHHaLnupu92qLnm5s94nL66afbUvr06SP//Oc/5cYbb6xTqknY5cknnxSThItJ9KWysvKY9833h1x77bW129FTa9555x0555xz7MWoZo95nXUaemH2sNv66fv/+te/xCTwYvbu28W1nlqXSGU1tD3mI5BKAsR5KvV2/NpK4h4/S0+3tGfPHjl69GidOrRr104qKirEHGK3o1PUeZMXCCDgW4GWLVvKuHHjRL/YzakmMmDAANFk+oEHHpCXX35ZzCkwsnr1arnvvvtqR33R5NvsoZdf/epX9pz4gQMHytNPP23Pew+NTKPLaEKvk54Xr58Rf/7zn6Vfv34ydOhQ+etf/2rPcX/mmWci2uh29EJX/VzRSS+eDU1aR93+okWL5He/+52cdtpp0rt3b/t2/bJC6/CIQCoLEOep3PsxtD1Oe+7ZjMcCF154oT20bf4Uah/1EPYPf/hDe35rtNUzF5bZQ971l29ofv3leI0AAk0XCB1C19NhdNJz1rt06WLPOTcXjjpmD7zTvHlzx+yFdyZNmuToPHOhqGOGbbSnv5iRZZzRo0fbc+DN3nPnpJNOcn76058es4wZhcbJzs62p7rceeedtqxPP/3UGTJkiD29Rs+f18+S8HPcdSFzcaqdr6fF6KkyF110kV1X/9Nz2rU8k8w7Jml3PvjgA/tepLJqV+IJAikoQJynYKfHsclpuq0Y8n5W9YnAoEGD7JjL06dPr61Rp06dZP369Xbkh0suuUTMxW6iv/B1VAo9xK17yzZs2CDmQjfRZXVECXNhm8yZM8cepu/cubPdVv35uldPR5Qw59javW/my9oup6NadOvWrXYPoM48dOiQHYHCJB92Gf5DAIHYBEJH1vT0mdCk40LrfI1JnfSUlRYtWoTeto/1l9EjcTqF7zXX17o3PTc3V59GnPTonn4G6DjzkabPP/9czLnvdd5qqKw6C/ECAQRqBYjzWgqe1BMgca8HkqwvNXHXL1tzIZttQtu2beXkk08WM/qDmF/38u6778oZZ5xhzzfVZH3+/Pnyk5/8RMzeO9m+fbtcfPHF8tvf/taeQ6sfGGZUCXnzzTfttkpLS+vM1zGjb731VvvlrGNO65BWI0eOlA8//FCaNWtmD9WbvX7yxBNP2PLNKBj28Pzs2bOPSSaS1Zt6I4AAAggggAACiRZgHPdEi
|
|||
|
<p>A new convenience S3 function for <code>sort</code>
|
|||
|
(<code>sort.dendrogram</code>) was added:</p>
|
|||
|
<div class="sourceCode" id="cb82"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb82-1"><a href="#cb82-1" tabindex="-1"></a>dend110 <span class="ot"><-</span> <span class="fu">c</span>(<span class="dv">1</span>, <span class="dv">3</span><span class="sc">:</span><span class="dv">5</span>, <span class="dv">7</span>,<span class="dv">9</span>,<span class="dv">10</span>) <span class="sc">%>%</span> dist <span class="sc">%>%</span> <span class="fu">hclust</span>(<span class="at">method =</span> <span class="st">"average"</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb82-2"><a href="#cb82-2" tabindex="-1"></a> as.dendrogram <span class="sc">%>%</span> color_labels <span class="sc">%>%</span> color_branches</span>
|
|||
|
<span id="cb82-3"><a href="#cb82-3" tabindex="-1"></a></span>
|
|||
|
<span id="cb82-4"><a href="#cb82-4" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">3</span>))</span>
|
|||
|
<span id="cb82-5"><a href="#cb82-5" tabindex="-1"></a>dend110 <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Original tree"</span>)</span>
|
|||
|
<span id="cb82-6"><a href="#cb82-6" tabindex="-1"></a>dend110 <span class="sc">%>%</span> sort <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"labels sort"</span>)</span>
|
|||
|
<span id="cb82-7"><a href="#cb82-7" tabindex="-1"></a>dend110 <span class="sc">%>%</span> <span class="fu">sort</span>(<span class="at">type =</span> <span class="st">"nodes"</span>) <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"nodes (ladderize) sort"</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA4QAAAHCCAYAAAC30AdjAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBgE0SQIA9pfFtgo6cKGuhooeilaKH41eDs38Ip+f4At1Rq/sjr6NEwQqb/I/DQqsLvaFUjvAx+eWirddAJZnAj1DFJL0mSg/gcIpPkMBkhoyCSJ8lTZIxk0TpKDjXHliJzZPO50dR5ASNSnzeLvIvod0HG/mdkmOC0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BAQCD0HiBAgAABAgQIECBAgECLCgiELdrxDpsAAQIECBAgQIAAAQICofcAAQIECBAgQIAAAQIEWlRAIGzRjnfYBAgQIECAAAECBAgQEAi9B7YQePHFF+PRRx+NNWvWbPFaxxXz58/f6jZr166NtE2pVOq42zY9/mtlb1MhNiJAoGUE/tp4s3Hjxmw8Wrdu3TaZrFixIhYvXrxN29qIAAECq1atioULF243xGOPPRYrV66MJUuWxPLly7epvPXr12fj24YNGzbbvqv1m23U6Ul3519prvjII490KsXTRhMQCButx2rY3hQE3/zmN8fw4cNj7733jmHDhsVXvvKVijWmwWr06NHx85//vOLraeVtt92WbfPCCy90uU2lF7oq+6mnnooPfvCDlXaxjgCBFhf4a+NNmuSkMeuOO+7YJqnPf/7z8ZrXvGabtt3ejS6++OK49tprt7cY+xMgUEeBb3zjG/HSl750u1rw7LPPZuPODjvsEK9//evjU5/61DaV99BDD2XjWwqTHZeu1nfcpuPjruZfHbfp/LitrS3e8IY3xMyZMzu/tF3PUxj+6Ec/Gk8//fR2lWPnbRMQCLfNqSW2+uQnPxm33nprfOtb38p+sT/2sY/F2WefHddff32ks04zZsyIFBoffvjh6Nu3b9xwww1x2GGHbbJ5/PHHs7Nac+bMybY7+OCDs20GDx6cnWl//vnns7Nd991332ZXFtMAdO+998aCBQs2ldX5Qar/61//ehZA04CZzt6nQSKdjZs1a9amzdOA1PkMWTpr98wzz2zaxgMCBJpfYGvjShqjOl8pnDdvXjZudSWTXk+Tra7ueEhj0p///OdIVyo7LumE2JNPPtlxVaT6ly5dGg8++GCk8ewf//Ef44knnsjGz8029IQAgdwE0u92muekK15pPtM5iKT1KWB1HgOWLVtW8cpgpblHmp+kcSLNpSot//Iv/xLHH3989O/ff4uX00nxdCWu49iVyuvczrRjV+vTa53nSR3Ho/R6+9wunURLHu3/dbz62bGM3r17x8knnxzpJFqlpauxc/bs2dlVzfZ9Os/rfvnLX8Yll1yStTfd4WGpsUD5jW0hkAmMGzeuVL5CuEmjPOiUylcLS6ecckrpueeeS/d9liZPnlwqh8FS+Rc5e14+q10qT7xK5WBYKl9RzF7faaedSpdddlnpZz/7WbZN+barUnnCU9pzzz1L5SuPpaFDh5YOOOCAUnnAKt10002lgQMHlvbaa69SeVApXXPNNaXyoLCp7PbGpPpTvb169Sq98pWvLP3whz8slYNmKbX5wAMPLJUnV6VXv/rVpfIVgNJuu+2WvZ72/e53v1saNWpUaZdddimdcMIJpfIg3F6knwQINJFAx/Gm0rjSPoYdeuih2biRxoTbb789E/jIRz5S2nHHHbNxonwSLFt31llnlV72spdlj9/97neX9thjj9JLXvKSbBxL403HpXxlINv3kEMOycazP/3pT9nL5513Xql8pr80aNCgbNwqB8ps/ZQpU7KxMo2pb3zjG7PxrjwBLN14440di/WYAIEcBcrBLvtdPPzww0sTJ07Mfnd/8pOfZC0o34GQ/R6n3+U0Fvz0pz/N1l9xxRXZnCat23///UsjR47M1leae9x///3ZHOUVr3hFaciQIaVy2Nni6CZMmFAqB7JsfRpPyifms7nSq171qmzcGjFiRFZP2qB8cj2b74wZMyabg6XxpBxYu1zf1Typ43iUjjeVk+Z273jHO7J5WfkKYLbu9NNP73Ku9etf/zob+9K8ruNSaewsB+tSOfSWUrlpHnfSSSeV0rrO87o0/qa2JPPyibWOxXpcAwFXCMvvNktkZ8TSmeryALSJI90GUB7gsjPY7SvTWaB01qgc+tpXxS9+8YsoT4Cys0g//vGPY9GiRVucQUsbpyuAd999d3z729+OBx54INIVw/KkLLvqV57ARTkwZreZbiq4w4PygBef+9znYvz48XHXXXdlr6TbCcqDbpQHouyMVjoLn844lSdyccYZZ2TbnHvuufGFL3whu4r4xz/+Ma688
|
|||
|
</div>
|
|||
|
<div id="unbranching" class="section level4">
|
|||
|
<h4>Unbranching</h4>
|
|||
|
<p>We can unbranch a tree:</p>
|
|||
|
<div class="sourceCode" id="cb83"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb83-1"><a href="#cb83-1" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">3</span>))</span>
|
|||
|
<span id="cb83-2"><a href="#cb83-2" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"First tree"</span>, <span class="at">ylim =</span> <span class="fu">c</span>(<span class="dv">0</span>,<span class="dv">3</span>))</span>
|
|||
|
<span id="cb83-3"><a href="#cb83-3" tabindex="-1"></a>dend15 <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb83-4"><a href="#cb83-4" tabindex="-1"></a> unbranch <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb83-5"><a href="#cb83-5" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Unbranched tree"</span>, <span class="at">ylim =</span> <span class="fu">c</span>(<span class="dv">0</span>,<span class="dv">3</span>))</span>
|
|||
|
<span id="cb83-6"><a href="#cb83-6" tabindex="-1"></a>dend15 <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb83-7"><a href="#cb83-7" tabindex="-1"></a> <span class="fu">unbranch</span>(<span class="dv">2</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb83-8"><a href="#cb83-8" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Unbranched tree (2)"</span>, <span class="at">ylim =</span> <span class="fu">c</span>(<span class="dv">0</span>,<span class="dv">3</span>))</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAu4AAADhCAYAAACX1DA2AAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+P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F7p3724+MzWX/vnPf0bme3nhDqg57mCbc+aZZ5rc+vnPf2720djxwS3YzeevvkaPD3PmzHHcK10mBvcqu3PuueeaGF544QWznZ/+9KdOu3btzDFFjxk6uSf75jNba4AePXqY17oj72aZ/q+ystI55phjzHHpF7/4haPHpOhjT2PHh0T7imzUfTBixAhz7NJ57m09xs69pcgcY9wreDrbeeCBB5yrr77aPOZ/sQKMuMeexwT6mY5y6Rms/verX/0qYVvcg4a5b7ZLly6iZ+puMSF/+ctf5I477pBTTjnFnF2XlpbK8uXLI693kzpuvl4Kdwtz+cc//iHz5883I3I6KqiX92+77TbzWr289tBDD5nRAzfB5amnnopskwcIhEnAPRmOa270PL1MrKPa7gejLF26NLKujo699tpr8tJLL4l7QmxG2XWh3h+vV7L0VrjLLrvM5Kv7wW1G7
|
|||
|
</div>
|
|||
|
<div id="pruning" class="section level4">
|
|||
|
<h4>Pruning</h4>
|
|||
|
<p>We can prune a tree based on the labels:</p>
|
|||
|
<div class="sourceCode" id="cb84"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb84-1"><a href="#cb84-1" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">2</span>))</span>
|
|||
|
<span id="cb84-2"><a href="#cb84-2" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"labels_colors"</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb84-3"><a href="#cb84-3" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"First tree"</span>, <span class="at">ylim =</span> <span class="fu">c</span>(<span class="dv">0</span>,<span class="dv">3</span>))</span>
|
|||
|
<span id="cb84-4"><a href="#cb84-4" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"labels_colors"</span>) <span class="sc">%>%</span></span>
|
|||
|
<span id="cb84-5"><a href="#cb84-5" tabindex="-1"></a> <span class="fu">prune</span>(<span class="fu">c</span>(<span class="st">"1"</span>,<span class="st">"5"</span>)) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb84-6"><a href="#cb84-6" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Prunned tree"</span>, <span class="at">ylim =</span> <span class="fu">c</span>(<span class="dv">0</span>,<span class="dv">3</span>))</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAg0AAADhCAYAAABLAYZEAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBgE0SQIA9pfFtgo6cKGuhooeilaKH41eDs38Ip+f4At1Rq/sjr6NEwQqb/I/DQqsLvaFUjvAx+eWirddAJZnAj1DFJL0mSg/gcIpPkMBkho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1o+UePHg288847Zp4uq0qVKoHrr78+WL794sCBA4G0tDRTtnU6JHDNNdcEFi5cGLCCk+DydHpiYmJg1qxZgTfffNNM1/e9evUKlCtXzrz/97//bRcZsHZAZprVSxLo2rWreW3t1ALWziGYhxcI+FVAt2vd5qzAOdjEDRs2BJKTk830MWPGmOmhtumzZ88G+vfvb/JZQXrw8wMGDMj12d/85jfmvXXqI2AdDAR69uxp3utyFy9ebD7nJI/VExLchrt06RJo2LChKUeXZ6c777zTTNNtXV+XLl06YJ02NdNWrFhhZws+h9vvhGvvlfYXTuoYXDgvggIEDUGK6H9hBw26ged8WL0LwcaFCxp0B2EdBZiAQf9Q6+d1mnX0ErBOQwTmzp0bsM6dBk6fPm3Kso5ITB5rcFaw7MtffP/99yaP/mG3kx00aMCwbt068wdfl6sBii5zwYIFJqtdh5tvvtm81x2WztdgRvNrsnd4Y8eONe/5DwE/C9hBgwb4uk1pgG9v57pd7N692zTf/iOac5vWGQUJGnSfceHCBVPebbfdZpYzbtw4894OGvLLowcbWjc7wDl37pw5wChVqlRA/1ivX78+WPdNmzaZcufNmxecFipo0Eyh9juh2utkf3GlOppK8V8egThrxZJ8JmDtXKR58+bBVtWuXTv4OtwL7erXAZI6uMra2Yi1E5JVq1ZJ+/btxdo5ye233y46LsLaYYUrokDTrZ4HadGihfmMjrOwxz68//77YvWMBLsx16xZY/LYz1ZPhAwbNsxM03EbmtauXWue+Q+BkiBg/TE3Yxh0W9BTdXqK4oUXXjCvc7Y/5zadc3rO19ZfhJxvg6/1tII9WNrqJTDTT5w4EZyvL/LLY2+vVo+m6FUfmvRUp9VTKdbBgqm/TtP9lA6W1vSTn/xEypYtK1aviHlf0P9yttdefn77CztPuDrqYFNSXgGChrwmUT/F6t6X7t27F6gdOpjKTjrOQK+KsI4sZPbs2
|
|||
|
<p>For pruning two trees to have matching labels, we can use the
|
|||
|
<code>intersect_trees</code> function:</p>
|
|||
|
<div class="sourceCode" id="cb85"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb85-1"><a href="#cb85-1" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">2</span>))</span>
|
|||
|
<span id="cb85-2"><a href="#cb85-2" tabindex="-1"></a>dend_intersected <span class="ot"><-</span> <span class="fu">intersect_trees</span>(dend13, dend15)</span>
|
|||
|
<span id="cb85-3"><a href="#cb85-3" tabindex="-1"></a>dend_intersected[[<span class="dv">1</span>]] <span class="sc">%>%</span> plot</span>
|
|||
|
<span id="cb85-4"><a href="#cb85-4" tabindex="-1"></a>dend_intersected[[<span class="dv">2</span>]] <span class="sc">%>%</span> plot</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAg0AAADhCAYAAABLAYZEAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9X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AoJSA0lGKyEgECBAgQICA02AcIECBAgACBUgJCQykmKxEgQIAAAQJCg32AAAECBAgQKCUgNJRishIBAgQIECAgNNgHCBAgQIAAgVICQkMpJisRIECAAAECQoN9gAABAgQIECglIDSUYrISAQIECBAgIDTYBwgQIECAAIFSAkJDKSYrESBAgAABAkKDfYAAAQIECBAoJSA0lGKyEgECBAgQICA02AcIECBAgACBUgJCQykmKxEgQIAAAQJCg32AAAECBAgQKCUgNJRishIBAgQIECAgNNgHCBAgQIAAgVICQkMpJisRIECAAAECQoN9gAABAgQIECglIDSUYrISAQIECBAgIDTYBwgQIECAAIFSAkJDKSYrESBAgAABAkKDfYAAAQIECBAoJSA0lGKyEgECBAgQICA02AcIECBAgACBUgJCQykmKxEgQIAAAQJCg32AAAECBAgQKCUgNJRishIBAgQIECAgNNgHCBAgQIAAgVICQkMpJisRIECAAAECQoN9gAABAgQIECglIDSUYrISAQIECBAgIDTYBwgQIECAAIFSAkJDKSYrESBAgAABAkKDfYAAAQIECBAoJSA0lGKyEgECBAgQICA02AcIECBAgACBUgJCQykmKxEgQIAAAQJCg32AAAECBAgQKCUgNJRishIBAgQIECAgNNgHCBAgQIAAgVICQkMpJisRIECAAAECQoN9gAABAgQIECglIDSUYrISAQIECBAgIDTYBwgQIECAAIFSAkJDKSYrESBAgAABAkKDfYAAAQIECBAoJSA0lGKyEgECBAgQICA02AcIECBAgACBUgJCQykmKxEgQIAAAQJCg32AAAECBAgQKCUgNJRishIBAgQIECAgNNgHCBAgQIAAgVICQkMpJisRIECAAAECQoN9gAABAgQIECglIDSUYrISAQIECBAgIDTYBwgQIECAAIFSAkJDKSYrESBAgAABAkKDfYAAAQIECBAoJSA0lGKyEgECBAgQINCrEQkeeuihWL16dZtN27JlS2zevLnN5V294Lvf/W48/vjjccYZZ3T1pjr8+gcPHox9+/bF6NGjO/y79fiFHTt2xB//+Md6bMo2GlBg4cKFxf5dq2kvv/xyzJo1K5YuXVprcUPNmzp1aowcOTLLNr344ovFe+OAA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NNxyyy2xcuXK4hDhkCFD4
|
|||
|
</div>
|
|||
|
<div id="collapse-branches" class="section level4">
|
|||
|
<h4>Collapse branches</h4>
|
|||
|
<p>We can collapse branches under a tolerance level using the
|
|||
|
<code>collapse_branch</code> function:</p>
|
|||
|
<div class="sourceCode" id="cb86"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb86-1"><a href="#cb86-1" tabindex="-1"></a><span class="co"># ladderize is like sort(..., type = "node")</span></span>
|
|||
|
<span id="cb86-2"><a href="#cb86-2" tabindex="-1"></a>dend <span class="ot"><-</span> iris[<span class="dv">1</span><span class="sc">:</span><span class="dv">5</span>,<span class="sc">-</span><span class="dv">5</span>] <span class="sc">%>%</span> dist <span class="sc">%>%</span> hclust <span class="sc">%>%</span> as.dendrogram</span>
|
|||
|
<span id="cb86-3"><a href="#cb86-3" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">3</span>))</span>
|
|||
|
<span id="cb86-4"><a href="#cb86-4" tabindex="-1"></a>dend <span class="sc">%>%</span> ladderize <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">horiz =</span> <span class="cn">TRUE</span>); <span class="fu">abline</span>(<span class="at">v =</span> .<span class="dv">2</span>, <span class="at">col =</span> <span class="dv">2</span>, <span class="at">lty =</span> <span class="dv">2</span>)</span>
|
|||
|
<span id="cb86-5"><a href="#cb86-5" tabindex="-1"></a>dend <span class="sc">%>%</span> <span class="fu">collapse_branch</span>(<span class="at">tol =</span> <span class="fl">0.2</span>) <span class="sc">%>%</span> ladderize <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">horiz =</span> <span class="cn">TRUE</span>)</span>
|
|||
|
<span id="cb86-6"><a href="#cb86-6" tabindex="-1"></a>dend <span class="sc">%>%</span> <span class="fu">collapse_branch</span>(<span class="at">tol =</span> <span class="fl">0.2</span>) <span class="sc">%>%</span> ladderize <span class="sc">%>%</span> <span class="fu">hang.dendrogram</span>(<span class="at">hang =</span> <span class="dv">0</span>) <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">horiz =</span> <span class="cn">TRUE</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCCAYAAAB8GMlFAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBgE0SQIA9pfFtgo6cKGuhooeilaKH41eDs38Ip+f4At1Rq/sjr6NEwQqb/I/DQqsLvaFUjvAx+eWirddAJZnAj1DFJL0mSg/gcIpPkMBkhoyCSJ8lTZIxk0TpKDjXHliJzZPO50dR5ASNSnzeLvIvod0HG/mdkmOC0z8VKnzcQ2M/Yz2vKldduXjp9bleLu0ZWn7vWc+l0JGcaai10yNrUnX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QyBEYlzNuuEACDz30UHj11VfLKz711FPDpEmTCrR6S62XgH1VKcuj0iOGe14ajaELkdRw1VVXhbfeeqv8Z+fOnZFUpYxWF7CvKjvIo9IjhnueEcbQhSpreOKJJ8JTTz0VOjo6qjxj74cdd9xx4ZBDDuk74N///neYNm1aOPDAA8O8efPC5MmT+8ZSv/Hggw+Gbdu2eQY8Co22r3YjZvvqsMMOC7Nmzep7sMj/nfUhRHhDEEbWlE1LV4T/+p/Fg1Z19913h8ceeyyccMIJg47X8uCMGTMqgvDFF18MEydODGPHjg2f+tSnwl133RUOPfTQWi7ZssfefPPNYcyYMWHmzJktu4ZYCrevdnci21enn356RRAW+b+z3TLx3RKEkfWkVCrttaLsfzIHHXRQuOSSS/Z6zHAHjjnmmHD99deH/fbbL2zdujXcf//94YILLhju5VrqvOxf7SeffHLo6upqqbpbodii76upU6dWtKnIHhUQkd3xPcLIGtKscp5++ulw8cUXhy1btoTsmef8+fObVYp5ExKwryqbyaPSI5Z7gjCWTjS5jtmzZ5efAd54443huuuuCx/4wAeaXJHpUxCwryq7yKPSI5Z7XhqNpRP/v47ORQubVtEpp5wSsj++CIymgH1Vqcmj0iOGe54RxtCFfjVM6Bz5O0L7Xc5NAgQIEMgREIQ5QIYJECBAIG0BQZh2f62OAAECBHIEBGEOUKOHu1etafSU5iNAgEChBQRhZO3vWbs+soqUQ4AAgbQFBGHa/bU6AgQIEMgREIQ5QIYJECBAIG0BQRhZf9u65kRWkXIIECCQtoAgjKy/bQvmRlaRcggQIJC2gCBMu79WR4AAAQI5AoIwB8gwAQIECKQtIAgj62/Pug2RVaQcAgQIpC0gCCPrb/fK1ZFVpBwCBAikLSAI0+6v1REgQIBAj
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div id="adding-extra-bars-and-rectangles" class="section level3">
|
|||
|
<h3>Adding extra bars and rectangles</h3>
|
|||
|
<div id="adding-colored-rectangles" class="section level4">
|
|||
|
<h4>Adding colored rectangles</h4>
|
|||
|
<p>Earlier we have seen how to highlight clusters in a dendrogram by
|
|||
|
coloring branches. We can also draw rectangles around the branches of a
|
|||
|
dendrogram in order to highlight the corresponding clusters. First the
|
|||
|
dendrogram is cut at a certain level, then a rectangle is drawn around
|
|||
|
selected branches. This is done using the <code>rect.dendrogram</code>,
|
|||
|
which is modeled based on the <code>rect.hclust</code> function. One
|
|||
|
advantage of <code>rect.dendrogram</code> over <code>rect.hclust</code>,
|
|||
|
is that it also works on horizontally plotted trees:</p>
|
|||
|
<div class="sourceCode" id="cb87"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb87-1"><a href="#cb87-1" tabindex="-1"></a><span class="fu">layout</span>(<span class="fu">t</span>(<span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">1</span>,<span class="dv">1</span>,<span class="dv">2</span>,<span class="dv">2</span>)))</span>
|
|||
|
<span id="cb87-2"><a href="#cb87-2" tabindex="-1"></a></span>
|
|||
|
<span id="cb87-3"><a href="#cb87-3" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"branches_k_color"</span>) <span class="sc">%>%</span> plot</span>
|
|||
|
<span id="cb87-4"><a href="#cb87-4" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">rect.dendrogram</span>(<span class="at">k=</span><span class="dv">3</span>, </span>
|
|||
|
<span id="cb87-5"><a href="#cb87-5" tabindex="-1"></a> <span class="at">border =</span> <span class="dv">8</span>, <span class="at">lty =</span> <span class="dv">5</span>, <span class="at">lwd =</span> <span class="dv">2</span>)</span>
|
|||
|
<span id="cb87-6"><a href="#cb87-6" tabindex="-1"></a></span>
|
|||
|
<span id="cb87-7"><a href="#cb87-7" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"branches_k_color"</span>) <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">horiz =</span> <span class="cn">TRUE</span>)</span>
|
|||
|
<span id="cb87-8"><a href="#cb87-8" tabindex="-1"></a>dend15 <span class="sc">%>%</span> <span class="fu">rect.dendrogram</span>(<span class="at">k=</span><span class="dv">3</span>, <span class="at">horiz =</span> <span class="cn">TRUE</span>,</span>
|
|||
|
<span id="cb87-9"><a href="#cb87-9" tabindex="-1"></a> <span class="at">border =</span> <span class="dv">8</span>, <span class="at">lty =</span> <span class="dv">5</span>, <span class="at">lwd =</span> <span class="dv">2</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAADhCAYAAABbV7VpAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBgE0SQIA9pfFtgo6cKGuhooeilaKH41eDs38Ip+f4At1Rq/sjr6NEwQqb/I/DQqsLvaFUjvAx+eWirddAJZnAj1DFJL0mSg/gcIpPkMBkho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c89V9cFpyieffGJcN6Y0brzxxlD6119/XQ4ePBj6HOukU6dOkpubq5Jhrzpsi53RC9czVrm+GcJmzZrJCy+8IBUrVpSuXbvKhAkTpGfPnmmzICMWON4nARIggVQgcODAAbUor2bNmjHVKVCggFSvXj2ULjs7W5o2bSqnTp0KXYt2UqRIESlZsmQoSY0aNQS7AeyMUSiR5SQnJ8fySVTd+/fvz3Mt0oeCBQuKNX+5cuVU/nBvZSgPiyyPHDkSMtiRytTXfTOEAD5+/PjQm0bp0qXlvffec/TmopXkkQRIgARIwJ4AekjoodWrV88+QZSrMGzoIboVdHTw51YaNmzoNqtkZWVJmzZt8uVft26dMoT5bkS54Jsh1HWii6oFFp2r/TQNHkmABEggfgKtW7eOv5CAl+DbYpmAc2XzSYAESIAE0oQADWGaPCiqSQIkQAJ2BDC/Z7ci0y5tEK5hWg6ijyZtpiE0ocQ0JEACJJCiBCZOnCjvv/9+imrnn1rvvvuu/O53v8tXARYDde7cOc/CmnyJwi7QEIYB4UcSIAESSCcCx44dE/wFSeB28+9//7vt1ovChQvLxRdfLFiTYiq+L5YxVYTpSIAESIAE/CXw1bQdcmjHSSle6n+LGP2tMf7SL+pYTkqUzRusAVGN4G/4jTfeiL+CsyXQEHqCkYWQAAmQQOoT2LHmiBQvXVhKlMtrWFJZ80KF/zvnp3V87bXXlEMAbP2At7ITJ05IsWLF9G21J3Lt2rWqV2jdtRBKYHNCQ2gDhZdIgARIIBMJZJ1XRCo1yJZqLdIjKo7dM8AGevivnjdvnjp+/vnncvnll4eSwqsZ9qxjb2XlypVD16Od0BBGo8N7JEACJEACKUXg3nvvVfogdNwzzzyTxwjihvZyo48mypvPJpqUxjQkQAIkQAIkkAACiJ/68ssve1ITDaEnGFkICZAACZBAuhKgIUzXJ0e9SYAESIAEPCFAQ+gJRhZCAiRAAiSQrgR8XSyD1TyIdbVt2zYpW
|
|||
|
</div>
|
|||
|
<div id="adding-colored-bars" class="section level4">
|
|||
|
<h4>Adding colored bars</h4>
|
|||
|
<p>Adding colored bars to a dendrogram may be useful to show clusters or
|
|||
|
some outside categorization of the items. For example:</p>
|
|||
|
<div class="sourceCode" id="cb88"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb88-1"><a href="#cb88-1" tabindex="-1"></a>is_odd <span class="ot"><-</span> <span class="fu">ifelse</span>(<span class="fu">labels</span>(dend15) <span class="sc">%%</span> <span class="dv">2</span>, <span class="dv">2</span>,<span class="dv">3</span>)</span>
|
|||
|
<span id="cb88-2"><a href="#cb88-2" tabindex="-1"></a>is_345 <span class="ot"><-</span> <span class="fu">ifelse</span>(<span class="fu">labels</span>(dend15) <span class="sc">></span> <span class="dv">2</span>, <span class="dv">3</span>,<span class="dv">4</span>)</span>
|
|||
|
<span id="cb88-3"><a href="#cb88-3" tabindex="-1"></a>is_12 <span class="ot"><-</span> <span class="fu">ifelse</span>(<span class="fu">labels</span>(dend15) <span class="sc"><=</span> <span class="dv">2</span>, <span class="dv">3</span>,<span class="dv">4</span>)</span>
|
|||
|
<span id="cb88-4"><a href="#cb88-4" tabindex="-1"></a>k_3 <span class="ot"><-</span> <span class="fu">cutree</span>(dend15,<span class="at">k =</span> <span class="dv">3</span>, <span class="at">order_clusters_as_data =</span> <span class="cn">FALSE</span>) </span>
|
|||
|
<span id="cb88-5"><a href="#cb88-5" tabindex="-1"></a><span class="co"># The FALSE above makes sure we get the clusters in the order of the</span></span>
|
|||
|
<span id="cb88-6"><a href="#cb88-6" tabindex="-1"></a><span class="co"># dendrogram, and not in that of the original data. It is like:</span></span>
|
|||
|
<span id="cb88-7"><a href="#cb88-7" tabindex="-1"></a><span class="co"># cutree(dend15, k = 3)[order.dendrogram(dend15)]</span></span>
|
|||
|
<span id="cb88-8"><a href="#cb88-8" tabindex="-1"></a>the_bars <span class="ot"><-</span> <span class="fu">cbind</span>(is_odd, is_345, is_12, k_3)</span>
|
|||
|
<span id="cb88-9"><a href="#cb88-9" tabindex="-1"></a>the_bars[the_bars<span class="sc">==</span><span class="dv">2</span>] <span class="ot"><-</span> <span class="dv">8</span></span>
|
|||
|
<span id="cb88-10"><a href="#cb88-10" tabindex="-1"></a></span>
|
|||
|
<span id="cb88-11"><a href="#cb88-11" tabindex="-1"></a>dend15 <span class="sc">%>%</span> plot</span>
|
|||
|
<span id="cb88-12"><a href="#cb88-12" tabindex="-1"></a><span class="fu">colored_bars</span>(<span class="at">colors =</span> the_bars, <span class="at">dend =</span> dend15, <span class="at">sort_by_labels_order =</span> <span class="cn">FALSE</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAYAAAB5fY51AAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBgE0SQIA9pfFtgo6cKGuhooeilaKH41eDs38Ip+f4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4rNze3ZJ0FCEDAfwSsEawrV
|
|||
|
<div class="sourceCode" id="cb89"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb89-1"><a href="#cb89-1" tabindex="-1"></a><span class="co"># we use sort_by_labels_order = FALSE since "the_bars" were set based on the</span></span>
|
|||
|
<span id="cb89-2"><a href="#cb89-2" tabindex="-1"></a><span class="co"># labels order. The more common use case is when the bars are based on a second variable</span></span>
|
|||
|
<span id="cb89-3"><a href="#cb89-3" tabindex="-1"></a><span class="co"># from the same data.frame as dend was created from. Thus, the default </span></span>
|
|||
|
<span id="cb89-4"><a href="#cb89-4" tabindex="-1"></a><span class="co"># sort_by_labels_order = TRUE would make more sense.</span></span></code></pre></div>
|
|||
|
<p>Another example, based on mtcars (in which the default of
|
|||
|
<code>sort_by_labels_order = TRUE</code> makes sense):</p>
|
|||
|
<div class="sourceCode" id="cb90"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb90-1"><a href="#cb90-1" tabindex="-1"></a>dend_mtcars <span class="ot"><-</span> mtcars[, <span class="fu">c</span>(<span class="st">"mpg"</span>, <span class="st">"disp"</span>)] <span class="sc">%>%</span> dist <span class="sc">%>%</span> <span class="fu">hclust</span>(<span class="at">method =</span> <span class="st">"average"</span>) <span class="sc">%>%</span> as.dendrogram</span>
|
|||
|
<span id="cb90-2"><a href="#cb90-2" tabindex="-1"></a></span>
|
|||
|
<span id="cb90-3"><a href="#cb90-3" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mar =</span> <span class="fu">c</span>(<span class="dv">10</span>,<span class="dv">2</span>,<span class="dv">1</span>,<span class="dv">1</span>))</span>
|
|||
|
<span id="cb90-4"><a href="#cb90-4" tabindex="-1"></a><span class="fu">plot</span>(dend_mtcars)</span>
|
|||
|
<span id="cb90-5"><a href="#cb90-5" tabindex="-1"></a>the_bars <span class="ot"><-</span> <span class="fu">ifelse</span>(mtcars<span class="sc">$</span>am, <span class="st">"grey"</span>, <span class="st">"gold"</span>)</span>
|
|||
|
<span id="cb90-6"><a href="#cb90-6" tabindex="-1"></a><span class="fu">colored_bars</span>(<span class="at">colors =</span> the_bars, <span class="at">dend =</span> dend_mtcars, <span class="at">rowLabels =</span> <span class="st">"am"</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCCAYAAAB8GMlFAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBgE0SQIA9pfFtgo6cKGuhooeilaKH41eDs38Ip+f4At1Rq/sjr6NEwQqb/I/DQqsLvaFUjvAx+eWirddAJZnAj1DFJL0mSg/gcIpPkMBkhoyCSJ8lTZIxk0TpKDjXHliJzZPO50dR5ASNSnzeLvIvod0HG/mdkmOC0z8VKnzcQ2M/Yz2vKldduXjp9b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ASEgBISAEJhrBMQI5/r16+GFgBAQAkJAjFB9QAgIASEgBOYaATHCuX79enghIASEgBAQI1QfEAJCQAgIgblGQIxwrl+/Hl4ICAEhIATECNUHhIAQEAJCYK4RWHeun37KHn777bcPd7/73cNaa601ZS2fjuauWbMmbLfddtPR2Cls5fe///1w9dVXT2HL1eRZR0CMcIre8GabbRY+85nPhHXWWWeKWq2mCoFfIbDPPvsICiGwKhGQaXRVvhY1SggIASEgBCaFgBjhpJDWfYSAEBACQmBVIiBGuCpfixolBISAEBACk0JAjHBSSOs+QkAICAEhsCoRECNcla9FjRICQkAICIFJISBGOCmkdR8hIASEgBBYlQiIEa7K16JGCQEhIASEwKQQECOcFNK6jxAQAkJACKxKBMQIV+VrUaOEgBAQAkJgUggUZ5a54oorAtNN3XDDDYHZTLbddtuw5ZZbamqvSb0V3UcICAEhIAQmhkCDEV533XXhwAMPDBdeeGHYaqutwkYbbRRuueWWcM0114Sdd945nHbaaWGXXXaZWON0IyEgBISAEBACy41AgxEedthhYccddwznnntu2GCDDYb3vuOOO8Ipp5wSDj744HDJJZcMz+tACAgBISAEhMC0I9DwEV588cXhxBNPbDBBHnDdddcNRx11VLj++uvjNu0PrfYLASEgBISAEHAEGoxwv/32i+bPwWDg/x/uzznnnGgm3XTTTYfndCAEhIAQEAJCYNoRaJhGTzrppHDIIYeEU089Neywww5hk002CTfffHO48sorw4033hjOPPPMsPbaDd457c+v9gsBISAEhMCcI9BghDvttFMMlMFEStToVVddFTbeeOOw9dZbhwMOOCCsv/76cw6XHl8ICAEhIARmDYEGI+ThWPSVlIlbb701+gY9fWK99dabtWfX8wgBISAEhIAQCA1GqPQJ9QghIASEgBCYNwQajHAp0yd+8pOfhF/+8pdFPG+//faw4YYbhrvc5S7F/+ukEBACQkAICIFJIbCWRYgOQ0Q333zz8I1vfCOUIkMpdp/73CfmEd7znvcc2b5nPOMZ4Uc/+lGx3Pe///3wqEc9Kpx88snF/+tkGYGHPvSh4TOf+Uw0X5dL6KwQWL0I7LPPPjEGYfW2UC2bVwQaGqGnTxxzzDELplOrTZ84/fTTWzFlhhqREBACQkAICIHVgECDESp9YjW8ErVBCAgBISAEJolAgxEqfWKS0OteQkAICAEhsBoQaDBCGkTCPCkUj370o2NCvTeS+UY/8pGPhMc97nF+SnshIASEgBAQAlOPQGOamIsuuiigFT7iEY+Iq0+8+c1vHj4geYWPf/zjh791IASEgBAQAkJgFhBoMMI3vvGN4fnPf3748Y9/HM4777yAz5BzIiEgBISAEBACs4pAwzR6wQUXhLe85S0xYvThD394DNV/yEMeEtMppA3OahfQcwkBISAE5huBBiPcd99941qET3va0yIq2223Xfz92Mc+Vrlr891P9PRCQAgIgZlFoGEaPeKII8LRRx8d2Dvtscce4eyzzw7Pfvaz/ZT2QkAICAEhIARmBoGGRviwhz0srjrxzW9+s/GAnL/00kvjKvWNf+iHEBACQkAICIEpR6ChEfIsrDKx2267LXisLbbYIgbPLPiHTggBISAEhIAQmGIEFjDCKX4WNV0ICAEhIASEQDUCYoTVkOkCISAEhIAQmCUExAhn6W3qWYSAEBACQqAaATHCash0gRAQAkJACMwSAmKEs/Q29SxCQAgIASFQjYAYYTVkukAICAEhIARmCQExwll6m3oWISAEhIAQqEZAjLAaMl0gBISAEBACs4SAGOEsvU09ixAQAkJACFQjIEZYDZkuEAJCQAgIgVlCQIxwlt6mnkUICAEhIASqERAjrIZMFwgBISAEhMAsISBGOEtvU88iBISAEBAC1QiIEVZDpguEgBAQAkJglhAQI5ylt6lnEQJCQAgIgWoExAirIdMFQkAICAEhMEsIiBHO0tvUswgBISAEhEA1A
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div id="ggplot2-integration" class="section level2">
|
|||
|
<h2>ggplot2 integration</h2>
|
|||
|
<p>The core process is to transform a dendrogram into a
|
|||
|
<code>ggdend</code> object using <code>as.ggdend</code>, and then plot
|
|||
|
it using <code>ggplot</code> (a new S3 <code>ggplot.ggdend</code>
|
|||
|
function is available). These two steps can be done in one command with
|
|||
|
either the function <code>ggplot</code> or <code>ggdend</code>.</p>
|
|||
|
<p>The reason we want to have <code>as.ggdend</code> (and not only
|
|||
|
<code>ggplot.dendrogram</code>), is (1) so that you could create your
|
|||
|
own mapping of <code>ggdend</code> and, (2) since <code>as.ggdend</code>
|
|||
|
might be slow for large trees, it is probably better to be able to run
|
|||
|
it only once for such cases.</p>
|
|||
|
<p>A <code>ggdend</code> class object is a list with 3 components:
|
|||
|
segments, labels, nodes. Each one contains the graphical parameters from
|
|||
|
the original dendrogram, but in a tabular form that can be used by
|
|||
|
<code>ggplot2+geom_segment+geom_text</code> to create a dendrogram
|
|||
|
plot.</p>
|
|||
|
<p>The function <code>prepare.ggdend</code> is used by
|
|||
|
<code>plot.ggdend</code> to take the ggdend object and prepare it for
|
|||
|
plotting. This is because the defaults of various parameters in
|
|||
|
dendrogram’s are not always stored in the object itself, but are
|
|||
|
built-in into the <code>plot.dendrogram</code> function. For example,
|
|||
|
the color of the labels is not (by default) specified in the dendrogram
|
|||
|
(only if we change it from black to something else). Hence, when taking
|
|||
|
the object into a different plotting engine (say ggplot2), we want to
|
|||
|
prepare the object by filling-in various defaults. This function is
|
|||
|
automatically invoked within the <code>plot.ggdend</code> function. You
|
|||
|
would probably use it only if you’d wish to build your own ggplot2
|
|||
|
mapping.</p>
|
|||
|
<div class="sourceCode" id="cb91"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb91-1"><a href="#cb91-1" tabindex="-1"></a><span class="co"># Create a complex dend:</span></span>
|
|||
|
<span id="cb91-2"><a href="#cb91-2" tabindex="-1"></a>dend <span class="ot"><-</span> iris[<span class="dv">1</span><span class="sc">:</span><span class="dv">30</span>,<span class="sc">-</span><span class="dv">5</span>] <span class="sc">%>%</span> dist <span class="sc">%>%</span> hclust <span class="sc">%>%</span> as.dendrogram <span class="sc">%>%</span></span>
|
|||
|
<span id="cb91-3"><a href="#cb91-3" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"branches_k_color"</span>, <span class="at">k=</span><span class="dv">3</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"branches_lwd"</span>, <span class="fu">c</span>(<span class="fl">1.5</span>,<span class="dv">1</span>,<span class="fl">1.5</span>)) <span class="sc">%>%</span></span>
|
|||
|
<span id="cb91-4"><a href="#cb91-4" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"branches_lty"</span>, <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">1</span>,<span class="dv">3</span>,<span class="dv">1</span>,<span class="dv">1</span>,<span class="dv">2</span>)) <span class="sc">%>%</span></span>
|
|||
|
<span id="cb91-5"><a href="#cb91-5" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"labels_colors"</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"labels_cex"</span>, <span class="fu">c</span>(.<span class="dv">9</span>,<span class="fl">1.2</span>)) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb91-6"><a href="#cb91-6" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"nodes_pch"</span>, <span class="dv">19</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"nodes_col"</span>, <span class="fu">c</span>(<span class="st">"orange"</span>, <span class="st">"black"</span>, <span class="st">"plum"</span>, <span class="cn">NA</span>))</span>
|
|||
|
<span id="cb91-7"><a href="#cb91-7" tabindex="-1"></a><span class="co"># plot the dend in usual "base" plotting engine:</span></span>
|
|||
|
<span id="cb91-8"><a href="#cb91-8" tabindex="-1"></a><span class="fu">plot</span>(dend)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCCAYAAAB8GMlFAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73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0MOrl+aRgGoJqOaN8KKLLsK6deuQkJCAsWPHIioqSukjlE5QNo3Onz8fZ555pmpBUjHHENAExgE3l4i3ws2N0ydix0Gj9/z+UcfQoxQSIIGeEFCNI/T398fLL7+Me+65Rxk1mp6eDo1Gg8TEREycOFFxkD0xkNe4HwFl3mBiY8Oo+2lPjUmABNyNgGocYRM4ORjG2oCYZcuWYfLkycpUiqa8Hf3dv38/1q9f39FpxdE+/fTTHZ7nCRIgARIgAe8hoJo+wq6QL1q0SBlR2lU+eV7OR5Mj7zr6fPbZZ90RwzwkQAIkQAJeQEB1b4QdMd+yZUtHp9odHzx4MOSno/Tmm292dIrHSYAESIAEvIyA6t4IDx8+jEOHDrWrBjm9Ijc3t91xHiABEiABEiABewioxhHW19fjnHPOUUaMpqWl4aqrrrKYSrFw4UL8/PPP9tjKa0mABEiABEigHQHVOEI5kVin0yE7OxtyxGhNTQ3klIq6urp2SvMACZAACZAACTiKgGoc4ffff48rrrgCQUFB6NevHz755BMl6PacOXOU+YSOM
|
|||
|
<div class="sourceCode" id="cb92"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb92-1"><a href="#cb92-1" tabindex="-1"></a><span class="co"># Now let's do it in ggplot2 :)</span></span>
|
|||
|
<span id="cb92-2"><a href="#cb92-2" tabindex="-1"></a>ggd1 <span class="ot"><-</span> <span class="fu">as.ggdend</span>(dend)</span>
|
|||
|
<span id="cb92-3"><a href="#cb92-3" tabindex="-1"></a><span class="fu">library</span>(ggplot2)</span>
|
|||
|
<span id="cb92-4"><a href="#cb92-4" tabindex="-1"></a><span class="co"># the nodes are not implemented yet.</span></span>
|
|||
|
<span id="cb92-5"><a href="#cb92-5" tabindex="-1"></a><span class="fu">ggplot</span>(ggd1) <span class="co"># reproducing the above plot in ggplot2 :)</span></span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCCAYAAAB8GMlFAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR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ABPROgEKo9xpm+UiABEiABDQJUAg18TCQBEiABEhA7wQohHqvYZaPBEiABEhAkwCFUBMPA0mABEiABPROgEKo9xpm+UiABEiABDQJUAg18TCQBEiABEhA7wQohHqvYZaPBEiABEhAkwCFUBMPA0mABEiABPROgEKo9xpm+UiABEiABDQJUAg18TCQBEiABEhA7wQohHqvYZaPBEiABEhAkwCFUBMPA0mABEiABPROgEKo9xpm+UiABEiABDQJUAg18TCQBEiABEhA7wQohHqvYZaPBEiABEhAkwCFUBMPA0mABEiABPROgEKo9xpm+UiABEiABDQJUAg18TCQBEiABEhA7wQohHqvYZaPBEiABEhAkwCFUBMPA0mABEiABPROgEKo9xpm+UiABEiABDQJUAg18TCQBEiABEhA7wQohHqvYZaPBEiABEhAkwCFUBMPA0mABEiABPROgEKo9xpm+UiABEiABDQJUAg18TCQBEiABEhA7wQohHqvYZaPBEiABEhAkwCFUBMPA0mABEiABPROgEKo9xpm+UiABEiABDQJUAg18TCQBEiABEhA7wQohHqvYZaPBEiABEhAkwCFUBMPA0mABEiABPROgEKo9xpm+UiABEiABDQJUAg18TCQBEiABEhA7wQohHqvYZaPBEiABEhAkwCFU
|
|||
|
<div class="sourceCode" id="cb93"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb93-1"><a href="#cb93-1" tabindex="-1"></a><span class="fu">ggplot</span>(ggd1, <span class="at">horiz =</span> <span class="cn">TRUE</span>, <span class="at">theme =</span> <span class="cn">NULL</span>) <span class="co"># horiz plot (and let's remove theme) in ggplot2</span></span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCCAYAAAB8GMlFAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73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zBF/guex3EcCAzYSTUg6+DLW5Q0JkYD5tg2MV6nD5+4zoMBrZl4ns46muRxha/+NsTyLdK1P6wD6oRWVD0Sgq6jKHOMKiKcNy4ccLCmA0bNgiLZB588EFBIQ4ZMgRPPPEEysvL8eSTT4a6jlQeESACRCBsCXAlmLD+WoiNZZiotgtyOk/vh+j0p6ia+BGsPSYFVXZlPwUsxy3C1gl4rZmxsxGXuh++Y5OEFmT+41qohvof7tTvOA5HnRGxc0YEVbauyiyoipAPhzz//PPC8BWfD3SH+fPnC4rRe1jUfY2+iQARIALdlYDIXImkn2ZC5Gg6VskGL4UQu/MxVE98H3Zd/6Ah4tsidBdqYcw1CQpRLBLDbragZsm3EIkdyPrnDZBnJQQsz8JWi/KgHJAaMF2kXAyqInRX2lsJuuNICbpJ0DcRIAJdTeCtjdX48VCDTzH+Oz8DMYqWqyr3FpuwYIVLATS/8a6J8Zg1MKZ5tHB+w3+LUM82sLsDXzXK91MPTVXgxWGb4BRJ4FZ87jTub7GxBMqTX0M/9BF3VFC++cpM9
|
|||
|
<div class="sourceCode" id="cb94"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb94-1"><a href="#cb94-1" tabindex="-1"></a><span class="co"># Adding some extra spice to it...</span></span>
|
|||
|
<span id="cb94-2"><a href="#cb94-2" tabindex="-1"></a><span class="co"># creating a radial plot:</span></span>
|
|||
|
<span id="cb94-3"><a href="#cb94-3" tabindex="-1"></a><span class="co"># ggplot(ggd1) + scale_y_reverse(expand = c(0.2, 0)) + coord_polar(theta="x")</span></span>
|
|||
|
<span id="cb94-4"><a href="#cb94-4" tabindex="-1"></a><span class="co"># The text doesn't look so great, so let's remove it:</span></span>
|
|||
|
<span id="cb94-5"><a href="#cb94-5" tabindex="-1"></a><span class="fu">ggplot</span>(ggd1, <span class="at">labels =</span> <span class="cn">FALSE</span>) <span class="sc">+</span> <span class="fu">scale_y_reverse</span>(<span class="at">expand =</span> <span class="fu">c</span>(<span class="fl">0.2</span>, <span class="dv">0</span>)) <span class="sc">+</span> <span class="fu">coord_polar</span>(<span class="at">theta=</span><span class="st">"x"</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCCAYAAAB8GMlFAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBgE0SQIA9pfFtgo6cKGuhooeilaKH41eDs38Ip+f4At1Rq/sjr6NEwQqb/I/DQqsLvaFUjvAx+eWirddAJZnAj1DFJL0mSg/gcIpPkMBkhoyCSJ8lTZIxk0TpKDjXHliJzZPO50dR5ASNSnzeLvIvod0HG/mdkmOC0z8VKnzcQ2M/Yz2vKldduXjp9bleLu0ZWn7vWc+l0JGcaai10yNrUnXLP/8Jf59ewX+c3Wgz+B34Df+vb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fDyctzxeXlROSIaIhEc1l4ICugClAFoPqiBRq2Bj6/jfkV1uhagJgdQlQJ+4UD4QFqZOm7cbvZaMLsehIDjfss8CEQeqvsisHr1atx3330oLy9Hc3Mz/P39MWrUKHz00UcICAhwyMCy92bDx8vXZtsB3v4ozClEysAUm+W6mqmrOgrdH7cClYcBbRPg7QcExgBzP4AitF9Xm+V6jIBbIsCC0C2njZnuCQTWr1+Ps846C1qt1qy5nJwcTJkyBT/99BOio6PN8nriQRzLizNB29RRvu3atnJ1qjLoPhrRvkhtDnRfzgLO+AKK2LHt8zmFEeijCPA+SB+dWB6WbQRqamqwZMmSdkJQ1GppacH+/fvxzDPP2G6ki7mpg1PRrG22WbuZVmlxKXE2y3Q1U/frTdarNhRBt+EuSNum1ktxDiPQpxBgQdinppMHYy8C27Ztk7ZCrZUX54bfffedtexupQsBV+FTjiYNbUlaIG2LFs3xzVD6Ky3kdi9JrAZRvsd2I3V5QBVtmTIxAh6CAAtCD5loHqY5AhUVFairqzNPbPMkzgwdRecuOwfHq3JQ32TOQ3ldObIa9jvOfKKpSix5bQ+rRQ2IckyMgIcgwILQQyaah2mOQFxcHMLCwswT2zwFBga2Sem5R7HaW/DY2Sj1P4Z1B/7ExuN7sGbvr9AOVOGihy7suY7athRAZ55e3m1TzZ+9aSUaEGuexk+MQB9GgAVhH55cHpp1BMaNGyeZSVgroVQqsWjRImvZPZLu7e2N6aeMxmqVEncokrCnRoNp8yb2SNtWG1GS8I+fTNk2lHFCSGuUNUetQsgZfQ8BFoR9b055RHYgIFZ7L730ksWSXt6+SE5Oxl133WUx350ThbaqYsp/yFxCCdJdbT8UEoKKeR+yPWF7ZDilDyPAgrAPT
|
|||
|
<p><strong>Credit:</strong> These functions are <em>extended</em>
|
|||
|
versions of the functions <code>ggdendrogram</code>,
|
|||
|
<code>dendro_data</code> (and the hidden <code>dendrogram_data</code>)
|
|||
|
from Andrie de Vries’s <a href="https://cran.r-project.org/package=ggdendro">ggdendro</a> package.
|
|||
|
The motivation for this fork is the need to add more graphical
|
|||
|
parameters to the plotted tree. This required a strong mixture of
|
|||
|
functions from ggdendro and dendextend (to the point that it seemed
|
|||
|
better to just fork the code into its current form).</p>
|
|||
|
</div>
|
|||
|
<div id="enhancing-other-packages" class="section level2">
|
|||
|
<h2>Enhancing other packages</h2>
|
|||
|
<p>The dendextend package aims to extend and enhance features from the R
|
|||
|
ecosystem. Let us take a look at several examples.</p>
|
|||
|
<div id="dendser" class="section level3">
|
|||
|
<h3>DendSer</h3>
|
|||
|
<p>The DendSer package helps in re-arranging a dendrogram to optimize
|
|||
|
visualization-based cost functions. Until now it was only used for
|
|||
|
<code>hclust</code> objects, but it can easily be connected to
|
|||
|
<code>dendrogram</code> objects by trying to turn the dendrogram into
|
|||
|
hclust, on which it runs DendSer. This can be used to rotate the
|
|||
|
dendrogram easily by using the <code>rotate_DendSer</code> function:</p>
|
|||
|
<div class="sourceCode" id="cb95"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb95-1"><a href="#cb95-1" tabindex="-1"></a><span class="cf">if</span>(<span class="fu">require</span>(DendSer)) {</span>
|
|||
|
<span id="cb95-2"><a href="#cb95-2" tabindex="-1"></a> <span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">2</span>))</span>
|
|||
|
<span id="cb95-3"><a href="#cb95-3" tabindex="-1"></a> <span class="fu">DendSer.dendrogram</span>(dend15)</span>
|
|||
|
<span id="cb95-4"><a href="#cb95-4" tabindex="-1"></a> </span>
|
|||
|
<span id="cb95-5"><a href="#cb95-5" tabindex="-1"></a> dend15 <span class="sc">%>%</span> color_branches <span class="sc">%>%</span> plot</span>
|
|||
|
<span id="cb95-6"><a href="#cb95-6" tabindex="-1"></a> dend15 <span class="sc">%>%</span> color_branches <span class="sc">%>%</span> rotate_DendSer <span class="sc">%>%</span> plot</span>
|
|||
|
<span id="cb95-7"><a href="#cb95-7" tabindex="-1"></a>}</span></code></pre></div>
|
|||
|
<p><img role="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QAAggggAACBA0cAwgggAACCCDgSICgwRETCyGAAAIIIIAAQQPHAAIIIIAAAgg4EiBocMTEQggggAACCCBA0MAxgAACCCCAAAKOBAgaHDGxEAIIIIAAAggQNHAMIIAAAggggIAjAYIGR0wshAACCCCAAAIEDRwDCCCAAAIIIOBIgKDBERMLIYAAAggggABBA8cAAggggAACCDgSIGhwxMRCCCCAAAIIIEDQwDGAAAIIIIAAAo4ECBocMbEQAggggAACCBA0cAwggAACCCCAgCMBggZHTCyEAAIIIIAAAgQNHAMIIIAAAggg4EiAoMEREwshgAACCCCAAEEDxwACCCCAAAIIOBIgaHDExEIIIIAAAgggQNDAMYAAAggggAACjgQIGhwxsRACCCCAAAIIEDRwDCCAAAIIIICAIwGCBkdMLIQAAggggAACBA0cAwgggAACCCDgSICgwRETCyGAAAIIIIAAQQPHAAIIIIAAAgg4EiBocMTEQggggAACCCBA0MAxgAACCCCAAAKOBAgaHDGxEAIIIIAAAggQNHAMIIAAAggggIAjAYIGR0wshAACCCCAAAIEDRwDCCCAAAIIIOBIgKDBERMLIYAAAggggABBA8cAAggggAACCDgSIGhwxMRCCCCAAAIIIEDQwDGAAAIIIIAAAo4ECBocMbEQAggggAACCCT5keCDDz6Q2bNnh6za9u3bJS8vL+T8aMxYtmyZPP7445KTkxON4kuUuWXLFmnTpk2J6dGYsGPHDpk5c6Z07do1GsVTpo8ExowZI0ePHg1ao0OHDsnAgQNlwoQJQedHa+Ktt94qNWrUkMTExGhtguNyv/76a8nMzJRq1ao5XidaCx48eFAGDx4sY8eOjdYmxGS5vgwaunTpIi1atAi5Q+64446Q86I1IzU1VW688UZ54oknorUJxcrVE2vt2rWLTYvWH4899pgkJydHq3jK9ZHAk08+KZcuXQpaowULFoh+D72WLl++LFOmTJHq1at7bdNKbM+pU6ekSpUqMfF9ff311z25v0ugemyCL4OGtLQ00Z9QyYv/gCpXrmxOCtnZ2aE2u0Kne2U7tNJ61aI+JATKK1C3bt2QWWRkZIScF80Zer5q0KCBudsQze3wW9m1atWSlJQUv1Ur4vWhTUPEiSkAAQQQQAABfwgQNPhjP1ILBBBAAAEEIi5A0BBxYgpAAAEEEEDAHwIEDf7Yj9QCAQQQQACBiAsQNEScmAIQQAABBBDwhwBBgz/2I7VAAAEEEEAg4gKee+Xy5MmTkp+fL/v37zfv0GpnR/rDqzERPxYoAAFPC+zatUt27txpOmfKysoy5wV9FTEhIcHT283GIeAnAU8FDRMnTjQ9/2mPYvrO9JUrV+Tw4cNy/vx5mT59ugwbNsxP9tQFAQQcCGjPfUOHDpU1a9aI9h+ivSOeOXNG9u3bJ61bt5Y5c+ZIbm6ug5xYBAEEyivgmaBh7ty5smjRItm6das0bNiwWL02bdokPXr0kM6dO0vz5s2LzeMPBBDwt8CoUaOkZcuWsnjx4mKdtmnPjjNmzJDhw4d7rlt4f+8RahfPAp5p07Bu3ToZP358iYBBd067du1k5MiRsnz58njeV9QdgbgU2Lhxo0yePLlYwKAQSUlJZtwAvRupPyQEEIi8gGeChu7du8u8efPMbcerq33kyBFZuHAhdxmuhuFvBOJAoFu3buYRhGVZJWqrdyf1UYVXxkkpsYFMQMBnAp55PDFo0CBZuXKl1KtXT9q3b29OAtqmQQMGfTwxevRo6du3r8/4qQ4CCJQlMHXqVBkxYoTMmjXLDESnYwacPn1adu/eLceOHTMXG5Uqeeb6p6zqMB+BmBbwTNCgI6PpcNY6LK2+PaGtpLVVtLaO1lErNZggI
|
|||
|
</div>
|
|||
|
<div id="gplots" class="section level3">
|
|||
|
<h3>gplots</h3>
|
|||
|
<p>The gplots package brings us the <code>heatmap.2</code> function. In
|
|||
|
it, we can use our modified dendrograms to get more informative
|
|||
|
heat-maps:</p>
|
|||
|
<div class="sourceCode" id="cb96"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb96-1"><a href="#cb96-1" tabindex="-1"></a><span class="fu">library</span>(gplots)</span>
|
|||
|
<span id="cb96-2"><a href="#cb96-2" tabindex="-1"></a></span>
|
|||
|
<span id="cb96-3"><a href="#cb96-3" tabindex="-1"></a>x <span class="ot"><-</span> <span class="fu">as.matrix</span>(datasets<span class="sc">::</span>mtcars)</span>
|
|||
|
<span id="cb96-4"><a href="#cb96-4" tabindex="-1"></a></span>
|
|||
|
<span id="cb96-5"><a href="#cb96-5" tabindex="-1"></a><span class="fu">heatmap.2</span>(x)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAg0AAAINCAYAAAC9GEyUAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBgE0SQIA9pfFtgo6cKGuhooeilaKH41eDs38Ip+f4At1Rq/sjr6NEwQqb/I/DQqsLvaFUjvAx+eWirddAJZnAj1DFJL0mSg/gcIpPkMBkhoyCSJ8lTZIxk0TpKDjXHliJzZPO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IfGaOHEaCq+f/9+NPQIYyZarIBEiyiK6OzZs0tdRYsWjRYhoqa6YjlOlovlXVMZnzACSQ0B/v4mtSfmfuMVTuLRYgvX/QaWTEeUCvNyuiWSxDrEL3hsP6RNa3u35tatW9L5MKFp2VsvoX6s79++fZuE8WBRjCgLLMsh+qN///4W9/iCEUgqCICrBNtxLIyAUQTwdxCO4YgyY3E9Arbfkq7X61YasD0QnyBawR6xt549fZnXsTYYGjZsSFu2bKHChQtLh0jzunzOCDACjAAjwAi4CgE2GlyFrAv7hf8Foi4aNGgg/S9cqIq7ZgQYAUaAEWAETAiw0WCCIumccIha0nlWPFJGgBFgBJITAik2eiI5PUSeCyPACDACjAAjoAIBNhpeoAxGRnAiWOedwDXKzfkZwM2AMi2pFLJVhoWFqXherIMRYAQYAUaAEUg0BNhoeAE9CJ2QuRJkT+Zy4sQJWf7jjz+aipFcCnW3bt0qyypWrEivvfaa6b6tE1CdDh06VPoi2LrPZYwAI8AIMAKMgLsjwEaDE54Q6J+RoTI++fXXX2V+CG11Ir66fI8RYAQYAUaAEXBHBJKN0YCkUqBZBi1zu3btTL/omzVrRsOHD5dJoZCtEhTMT548kc8CKahfeuklmTVy+/bthp8PYoSXLl0q2wuiJ8kmiXEgMyUS8pw7d46+++47eR9JqS5cuCDzWiANN/JGlClThpCUSpPTp0/LrJe499VXX8kslkjdDY510F9/+OGHcp6gkEYCK0RRIEa5WrVqJAigZDcjRoyQcwabJHjrkRQL3A5oD9ps5MxgYQQYAUaAEWAE9CCQLIyGwMBAmS8CJEdIEY2X6f/+9z+JQ1BQEE2aNEkmm0Jeh8WLF5NgdiQkggEVM162H3/8seQ9iA+4MWPGyBc8XuSgoDYXGAbIDwGSqL59+8p01jAiwJuFl3O2bNmobt26sgmyXYIX4pVXXiEkoBo8eDBVrlxZ5
|
|||
|
<div class="sourceCode" id="cb97"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb97-1"><a href="#cb97-1" tabindex="-1"></a><span class="co"># now let's spice up the dendrograms a bit:</span></span>
|
|||
|
<span id="cb97-2"><a href="#cb97-2" tabindex="-1"></a>Rowv <span class="ot"><-</span> x <span class="sc">%>%</span> dist <span class="sc">%>%</span> hclust <span class="sc">%>%</span> as.dendrogram <span class="sc">%>%</span></span>
|
|||
|
<span id="cb97-3"><a href="#cb97-3" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"branches_k_color"</span>, <span class="at">k =</span> <span class="dv">3</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"branches_lwd"</span>, <span class="dv">4</span>) <span class="sc">%>%</span></span>
|
|||
|
<span id="cb97-4"><a href="#cb97-4" tabindex="-1"></a> ladderize</span>
|
|||
|
<span id="cb97-5"><a href="#cb97-5" tabindex="-1"></a><span class="co"># rotate_DendSer(ser_weight = dist(x))</span></span>
|
|||
|
<span id="cb97-6"><a href="#cb97-6" tabindex="-1"></a>Colv <span class="ot"><-</span> x <span class="sc">%>%</span> t <span class="sc">%>%</span> dist <span class="sc">%>%</span> hclust <span class="sc">%>%</span> as.dendrogram <span class="sc">%>%</span></span>
|
|||
|
<span id="cb97-7"><a href="#cb97-7" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"branches_k_color"</span>, <span class="at">k =</span> <span class="dv">2</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"branches_lwd"</span>, <span class="dv">4</span>) <span class="sc">%>%</span></span>
|
|||
|
<span id="cb97-8"><a href="#cb97-8" tabindex="-1"></a> ladderize</span>
|
|||
|
<span id="cb97-9"><a href="#cb97-9" tabindex="-1"></a><span class="co"># rotate_DendSer(ser_weight = dist(t(x)))</span></span>
|
|||
|
<span id="cb97-10"><a href="#cb97-10" tabindex="-1"></a></span>
|
|||
|
<span id="cb97-11"><a href="#cb97-11" tabindex="-1"></a><span class="fu">heatmap.2</span>(x, <span class="at">Rowv =</span> Rowv, <span class="at">Colv =</span> Colv)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANS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94OpqeeHlzp070vkwu6dgbb3s+jG/j1WQYsVMPYMRZdG9e3cZ/TFixAjzJnzNCDACdkTg3PTFdOWnNbLH0n075OmVBjvCkuNdGa80/PncCGpVPn2rOccHlo8HYPktmY8nbGlq2B7IShCtYI1YW8+avozrmBsMCLncunWrXIGAQyQLI8AIMAKMACOgBwJsNOiBsp11gP8BURfgl4D/BQsjwAgwAowAI6AHAmw06IGynXWABIqFEWAEGAFGgBHQG4EC6wipN9CsjxFgBBgBRoARyOsIsNHw8AmCkRGcCOZ5J3CNcmN+BnAzoExJKoVslfHx8Xn9u8DjZwQYAUaAEWAEskSAjYaH8IDQCXkhQPZkLCdOnJDl//vf/wzFSC6Futu2bZNlCLt8/vnnDfctnYBdEtwL8EVgYQQYAUaAEWAE8iICbDTY4amB/hnETFkJiKRA3KSsTmRVl+8xAowAI8AIMAK5EYF8YzQgqRRolkHLjIyPyi/6jh070rhx42RSKBAngYI5Li5OPgukoEaGyFq1atGOHTs0Px8kj1qxYoVsv3jxYskmiXE8/fTTkqQJDJJffvmlvI+kVGFhYTKvBdJwI29EjRo1JJGTMoAzZ87IrJe499lnn8nMmkjdvXfvXgL99TvvvCPnCQppJLBCFEVgYCA1atSItmzZIrsZP368nDPYJEuWLCnPwe2A9qDNRs4MFkaAEWAEGAFGQA0C+cJoOHnypMwXAZKjTz75ROZjAHsjBGmlv/nmG
|
|||
|
</div>
|
|||
|
<div id="nmf" class="section level3">
|
|||
|
<h3>NMF</h3>
|
|||
|
<p>The same as gplots, NMF offers a heatmap function called
|
|||
|
<code>aheatmap</code>. We can update it just as we would
|
|||
|
<code>heatmap.2</code>.</p>
|
|||
|
<p>Since NMF was removed from CRAN (it could still be installed from
|
|||
|
source), the example code is still available but not ran in this
|
|||
|
vignette.</p>
|
|||
|
<div class="sourceCode" id="cb98"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb98-1"><a href="#cb98-1" tabindex="-1"></a><span class="co"># library(NMF)</span></span>
|
|||
|
<span id="cb98-2"><a href="#cb98-2" tabindex="-1"></a><span class="co"># </span></span>
|
|||
|
<span id="cb98-3"><a href="#cb98-3" tabindex="-1"></a><span class="co"># x <- as.matrix(datasets::mtcars)</span></span>
|
|||
|
<span id="cb98-4"><a href="#cb98-4" tabindex="-1"></a><span class="co"># </span></span>
|
|||
|
<span id="cb98-5"><a href="#cb98-5" tabindex="-1"></a><span class="co"># # now let's spice up the dendrograms a bit:</span></span>
|
|||
|
<span id="cb98-6"><a href="#cb98-6" tabindex="-1"></a><span class="co"># Rowv <- x %>% dist %>% hclust %>% as.dendrogram %>%</span></span>
|
|||
|
<span id="cb98-7"><a href="#cb98-7" tabindex="-1"></a><span class="co"># set("branches_k_color", k = 3) %>% set("branches_lwd", 4) %>%</span></span>
|
|||
|
<span id="cb98-8"><a href="#cb98-8" tabindex="-1"></a><span class="co"># ladderize</span></span>
|
|||
|
<span id="cb98-9"><a href="#cb98-9" tabindex="-1"></a><span class="co"># # rotate_DendSer(ser_weight = dist(x))</span></span>
|
|||
|
<span id="cb98-10"><a href="#cb98-10" tabindex="-1"></a><span class="co"># Colv <- x %>% t %>% dist %>% hclust %>% as.dendrogram %>%</span></span>
|
|||
|
<span id="cb98-11"><a href="#cb98-11" tabindex="-1"></a><span class="co"># set("branches_k_color", k = 2) %>% set("branches_lwd", 4) %>%</span></span>
|
|||
|
<span id="cb98-12"><a href="#cb98-12" tabindex="-1"></a><span class="co"># ladderize</span></span>
|
|||
|
<span id="cb98-13"><a href="#cb98-13" tabindex="-1"></a><span class="co"># # rotate_DendSer(ser_weight = dist(t(x)))</span></span>
|
|||
|
<span id="cb98-14"><a href="#cb98-14" tabindex="-1"></a><span class="co"># </span></span>
|
|||
|
<span id="cb98-15"><a href="#cb98-15" tabindex="-1"></a><span class="co"># aheatmap(x, Rowv = Rowv, Colv = Colv)</span></span></code></pre></div>
|
|||
|
</div>
|
|||
|
<div id="heatmaply" class="section level3">
|
|||
|
<h3>heatmaply</h3>
|
|||
|
<p>The heatmaply package create interactive heat-maps that are usable
|
|||
|
from the R console, in the ‘RStudio’ viewer pane, in ‘R Markdown’
|
|||
|
documents, and in ‘Shiny’ apps. By hovering the mouse pointer over a
|
|||
|
cell or a dendrogram to show details, drag a rectangle to zoom.</p>
|
|||
|
<p>The use is very similar to what we’ve seen before, we just use
|
|||
|
<code>heatmaply</code> instead of <code>heatmap.2</code>:</p>
|
|||
|
<div class="sourceCode" id="cb99"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb99-1"><a href="#cb99-1" tabindex="-1"></a>x <span class="ot"><-</span> <span class="fu">as.matrix</span>(datasets<span class="sc">::</span>mtcars)</span>
|
|||
|
<span id="cb99-2"><a href="#cb99-2" tabindex="-1"></a><span class="co"># heatmaply(x)</span></span>
|
|||
|
<span id="cb99-3"><a href="#cb99-3" tabindex="-1"></a><span class="co"># now let's spice up the dendrograms a bit:</span></span>
|
|||
|
<span id="cb99-4"><a href="#cb99-4" tabindex="-1"></a>Rowv <span class="ot"><-</span> x <span class="sc">%>%</span> dist <span class="sc">%>%</span> hclust <span class="sc">%>%</span> as.dendrogram <span class="sc">%>%</span></span>
|
|||
|
<span id="cb99-5"><a href="#cb99-5" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"branches_k_color"</span>, <span class="at">k =</span> <span class="dv">3</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"branches_lwd"</span>, <span class="dv">4</span>) <span class="sc">%>%</span></span>
|
|||
|
<span id="cb99-6"><a href="#cb99-6" tabindex="-1"></a> ladderize</span>
|
|||
|
<span id="cb99-7"><a href="#cb99-7" tabindex="-1"></a><span class="co"># rotate_DendSer(ser_weight = dist(x))</span></span>
|
|||
|
<span id="cb99-8"><a href="#cb99-8" tabindex="-1"></a>Colv <span class="ot"><-</span> x <span class="sc">%>%</span> t <span class="sc">%>%</span> dist <span class="sc">%>%</span> hclust <span class="sc">%>%</span> as.dendrogram <span class="sc">%>%</span></span>
|
|||
|
<span id="cb99-9"><a href="#cb99-9" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"branches_k_color"</span>, <span class="at">k =</span> <span class="dv">2</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"branches_lwd"</span>, <span class="dv">4</span>) <span class="sc">%>%</span></span>
|
|||
|
<span id="cb99-10"><a href="#cb99-10" tabindex="-1"></a> ladderize</span>
|
|||
|
<span id="cb99-11"><a href="#cb99-11" tabindex="-1"></a><span class="co"># rotate_DendSer(ser_weight = dist(t(x)))</span></span></code></pre></div>
|
|||
|
<p>Here we need to use <code>cache=FALSe</code> in the markdown:</p>
|
|||
|
<div class="sourceCode" id="cb100"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb100-1"><a href="#cb100-1" tabindex="-1"></a><span class="fu">library</span>(heatmaply)</span>
|
|||
|
<span id="cb100-2"><a href="#cb100-2" tabindex="-1"></a><span class="fu">heatmaply</span>(x, <span class="at">Rowv =</span> Rowv, <span class="at">Colv =</span> Colv)</span></code></pre></div>
|
|||
|
<p>I avoided running the code from above due to space issues on CRAN.
|
|||
|
For live examples, please go to:</p>
|
|||
|
<ul>
|
|||
|
<li><a href="https://talgalili.github.io/heatmaply/articles/heatmaply.html" class="uri">https://talgalili.github.io/heatmaply/articles/heatmaply.html</a></li>
|
|||
|
</ul>
|
|||
|
</div>
|
|||
|
<div id="dynamictreecut" class="section level3">
|
|||
|
<h3>dynamicTreeCut</h3>
|
|||
|
<p>The <code>cutreeDynamic</code> function offers a wrapper for two
|
|||
|
methods of adaptive branch pruning of hierarchical clustering
|
|||
|
dendrograms. The results of which can now be visualized by both updating
|
|||
|
the branches, as well as using the <code>colored_bars</code> function
|
|||
|
(which was adjusted for use with plots of dendrograms):</p>
|
|||
|
<div class="sourceCode" id="cb101"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb101-1"><a href="#cb101-1" tabindex="-1"></a><span class="co"># let's get the clusters</span></span>
|
|||
|
<span id="cb101-2"><a href="#cb101-2" tabindex="-1"></a><span class="fu">library</span>(dynamicTreeCut)</span>
|
|||
|
<span id="cb101-3"><a href="#cb101-3" tabindex="-1"></a><span class="fu">data</span>(iris)</span>
|
|||
|
<span id="cb101-4"><a href="#cb101-4" tabindex="-1"></a>x <span class="ot"><-</span> iris[,<span class="sc">-</span><span class="dv">5</span>] <span class="sc">%>%</span> as.matrix</span>
|
|||
|
<span id="cb101-5"><a href="#cb101-5" tabindex="-1"></a>hc <span class="ot"><-</span> x <span class="sc">%>%</span> dist <span class="sc">%>%</span> hclust</span>
|
|||
|
<span id="cb101-6"><a href="#cb101-6" tabindex="-1"></a>dend <span class="ot"><-</span> hc <span class="sc">%>%</span> as.dendrogram </span>
|
|||
|
<span id="cb101-7"><a href="#cb101-7" tabindex="-1"></a></span>
|
|||
|
<span id="cb101-8"><a href="#cb101-8" tabindex="-1"></a><span class="co"># Find special clusters:</span></span>
|
|||
|
<span id="cb101-9"><a href="#cb101-9" tabindex="-1"></a>clusters <span class="ot"><-</span> <span class="fu">cutreeDynamic</span>(hc, <span class="at">distM =</span> <span class="fu">as.matrix</span>(<span class="fu">dist</span>(x)), <span class="at">method =</span> <span class="st">"tree"</span>)</span>
|
|||
|
<span id="cb101-10"><a href="#cb101-10" tabindex="-1"></a><span class="co"># we need to sort them to the order of the dendrogram:</span></span>
|
|||
|
<span id="cb101-11"><a href="#cb101-11" tabindex="-1"></a>clusters <span class="ot"><-</span> clusters[<span class="fu">order.dendrogram</span>(dend)]</span>
|
|||
|
<span id="cb101-12"><a href="#cb101-12" tabindex="-1"></a>clusters_numbers <span class="ot"><-</span> <span class="fu">unique</span>(clusters) <span class="sc">-</span> (<span class="dv">0</span> <span class="sc">%in%</span> clusters)</span>
|
|||
|
<span id="cb101-13"><a href="#cb101-13" tabindex="-1"></a>n_clusters <span class="ot"><-</span> <span class="fu">length</span>(clusters_numbers)</span>
|
|||
|
<span id="cb101-14"><a href="#cb101-14" tabindex="-1"></a></span>
|
|||
|
<span id="cb101-15"><a href="#cb101-15" tabindex="-1"></a><span class="fu">library</span>(colorspace)</span>
|
|||
|
<span id="cb101-16"><a href="#cb101-16" tabindex="-1"></a>cols <span class="ot"><-</span> <span class="fu">rainbow_hcl</span>(n_clusters)</span>
|
|||
|
<span id="cb101-17"><a href="#cb101-17" tabindex="-1"></a>true_species_cols <span class="ot"><-</span> <span class="fu">rainbow_hcl</span>(<span class="dv">3</span>)[<span class="fu">as.numeric</span>(iris[,][<span class="fu">order.dendrogram</span>(dend),<span class="dv">5</span>])]</span>
|
|||
|
<span id="cb101-18"><a href="#cb101-18" tabindex="-1"></a>dend2 <span class="ot"><-</span> dend <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb101-19"><a href="#cb101-19" tabindex="-1"></a> <span class="fu">branches_attr_by_clusters</span>(clusters, <span class="at">values =</span> cols) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb101-20"><a href="#cb101-20" tabindex="-1"></a> <span class="fu">color_labels</span>(<span class="at">col =</span> true_species_cols)</span>
|
|||
|
<span id="cb101-21"><a href="#cb101-21" tabindex="-1"></a><span class="fu">plot</span>(dend2)</span>
|
|||
|
<span id="cb101-22"><a href="#cb101-22" tabindex="-1"></a>clusters <span class="ot"><-</span> <span class="fu">factor</span>(clusters)</span>
|
|||
|
<span id="cb101-23"><a href="#cb101-23" tabindex="-1"></a><span class="fu">levels</span>(clusters)[<span class="sc">-</span><span class="dv">1</span>] <span class="ot"><-</span> cols[<span class="sc">-</span><span class="dv">5</span>][<span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">4</span>,<span class="dv">2</span>,<span class="dv">3</span>)] </span>
|
|||
|
<span id="cb101-24"><a href="#cb101-24" tabindex="-1"></a> <span class="co"># Get the clusters to have proper colors.</span></span>
|
|||
|
<span id="cb101-25"><a href="#cb101-25" tabindex="-1"></a> <span class="co"># fix the order of the colors to match the branches.</span></span>
|
|||
|
<span id="cb101-26"><a href="#cb101-26" tabindex="-1"></a><span class="fu">colored_bars</span>(clusters, dend, <span class="at">sort_by_labels_order =</span> <span class="cn">FALSE</span>)</span></code></p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/9m//JnfccYdphxkpreeee06+/e1v+zxN3VplZWU+j/MACZAACZBA+BAIKiFMTU2VH/3oR/LEE0/IN77xDfniF78on/zkJ2X9+vUyf/58mTRpkl81c91114n++QqrV6/2dYj7SYAESIAEwoxA0LhGB3K/9dZb5eDBg6Lu0rq6Ovnnf/5nyc3NlSeffHJgNG6TAAmQAAmQwKgJBJVFeHpp1q5dK/qnweVySXd39+lR+J0ESIAESIAERkUgaIRww4YN0tnZ6bMw7EHmEw0PkAAJkAAJjIJA0AjhsmXLRlEMnkoCJEACJEACZ0cgKNsIz64oPIsESIAESIAERk6AQjhyZjyDBEiABEgghAhQCEOoMlkUEiABEiCBkROgEI6cGc8gARIgARIIIQIUwhCqTBaFBEiABEhg5AQohCNnxjNIgARIgARCiACFMIQqk0UhARIgARIYOQEK4ciZ8QwSIAESIIEQIkAhDKHKZFFIgARIgARGToBCOHJmPIMESIAESCCECFAIQ6gyWRQSIAESIIGRE6AQjpwZzyABEiABEgghAhTCEKpMFoUESIAESGDkBCiEI2fGM0iABEiABEKIAIUwhCqTRSEBEiABEhg5AQrhyJnxDBIgARIggRAiQCEMocpkUUiABEiABEZOgEI4cmY8gwRIgARIIIQIUAhDqDJZFBIgARIggZEToBCOnBnPIAESIAESCCECFMIQqkwWhQRIgARIYOQEKIQjZ8YzSIAESIAEQogAhTCEKpNFIQESIAESGDkBCuHImfEMEiABEiCBECJAIQyhymRRSIAESIAERk6AQjhyZjyDBEiABEgghAhQCEOoMlkUEiABEiCBkROgE
|
|||
|
<div class="sourceCode" id="cb102"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb102-1"><a href="#cb102-1" tabindex="-1"></a><span class="co"># here we used sort_by_labels_order = FALSE since the clusters were already sorted based on the dendrogram's order</span></span></code></pre></div>
|
|||
|
</div>
|
|||
|
<div id="pvclust" class="section level3">
|
|||
|
<h3>pvclust</h3>
|
|||
|
<p>The pvclust library calculates “p-values”” for hierarchical
|
|||
|
clustering via multiscale bootstrap re-sampling. Hierarchical clustering
|
|||
|
is done for given data and p-values are computed for each of the
|
|||
|
clusters. The dendextend package let’s us reproduce the plot from
|
|||
|
pvclust, but with a dendrogram (instead of an hclust object), which also
|
|||
|
lets us extend the visualization.</p>
|
|||
|
<div class="sourceCode" id="cb103"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb103-1"><a href="#cb103-1" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">2</span>))</span>
|
|||
|
<span id="cb103-2"><a href="#cb103-2" tabindex="-1"></a></span>
|
|||
|
<span id="cb103-3"><a href="#cb103-3" tabindex="-1"></a><span class="fu">library</span>(pvclust)</span>
|
|||
|
<span id="cb103-4"><a href="#cb103-4" tabindex="-1"></a><span class="fu">data</span>(lung) <span class="co"># 916 genes for 73 subjects</span></span>
|
|||
|
<span id="cb103-5"><a href="#cb103-5" tabindex="-1"></a><span class="fu">set.seed</span>(<span class="dv">13134</span>)</span>
|
|||
|
<span id="cb103-6"><a href="#cb103-6" tabindex="-1"></a>result <span class="ot"><-</span> <span class="fu">pvclust</span>(lung[<span class="dv">1</span><span class="sc">:</span><span class="dv">100</span>, <span class="dv">1</span><span class="sc">:</span><span class="dv">10</span>], </span>
|
|||
|
<span id="cb103-7"><a href="#cb103-7" tabindex="-1"></a> <span class="at">method.dist=</span><span class="st">"cor"</span>, <span class="at">method.hclust=</span><span class="st">"average"</span>, <span class="at">nboot=</span><span class="dv">10</span>)</span>
|
|||
|
<span id="cb103-8"><a href="#cb103-8" tabindex="-1"></a></span>
|
|||
|
<span id="cb103-9"><a href="#cb103-9" tabindex="-1"></a><span class="co"># with pvrect</span></span>
|
|||
|
<span id="cb103-10"><a href="#cb103-10" tabindex="-1"></a><span class="fu">plot</span>(result)</span>
|
|||
|
<span id="cb103-11"><a href="#cb103-11" tabindex="-1"></a><span class="fu">pvrect</span>(result)</span>
|
|||
|
<span id="cb103-12"><a href="#cb103-12" tabindex="-1"></a></span>
|
|||
|
<span id="cb103-13"><a href="#cb103-13" tabindex="-1"></a><span class="co"># with a dendrogram of pvrect</span></span>
|
|||
|
<span id="cb103-14"><a href="#cb103-14" tabindex="-1"></a>dend <span class="ot"><-</span> <span class="fu">as.dendrogram</span>(result)</span>
|
|||
|
<span id="cb103-15"><a href="#cb103-15" tabindex="-1"></a>result <span class="sc">%>%</span> as.dendrogram <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb103-16"><a href="#cb103-16" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Cluster dendrogram with AU/BP values (%)</span><span class="sc">\n</span><span class="st"> reproduced plot with dendrogram"</span>)</span>
|
|||
|
<span id="cb103-17"><a href="#cb103-17" tabindex="-1"></a>result <span class="sc">%>%</span> text</span>
|
|||
|
<span id="cb103-18"><a href="#cb103-18" tabindex="-1"></a>result <span class="sc">%>%</span> pvrect</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqMAAAHCCAYAAADb38AKAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzm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iDGOA5BNqe2czCbTHfQOzh9dff51sNhuKCBtKioAioAgoAvUQAZY+4E1uY3V8haOfP3++tGV7OWnL6k/Z5w+D/dgffvhByk466SQpY6cEG3+kbKyatDHzY2Mmw8b2X7aWLVva0tPTbe+++67UYQzMENuY8ZXj+EMk/bAq1HbeeefZoqKiZB/9g5iZk32WeNlYwmJDu2+++UbqrP+x5
|
|||
|
<p>Let’s color and thicken the branches based on the p-values:</p>
|
|||
|
<div class="sourceCode" id="cb104"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb104-1"><a href="#cb104-1" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">2</span>,<span class="dv">2</span>))</span>
|
|||
|
<span id="cb104-2"><a href="#cb104-2" tabindex="-1"></a></span>
|
|||
|
<span id="cb104-3"><a href="#cb104-3" tabindex="-1"></a><span class="co"># with a modified dendrogram of pvrect</span></span>
|
|||
|
<span id="cb104-4"><a href="#cb104-4" tabindex="-1"></a>dend <span class="sc">%>%</span> <span class="fu">pvclust_show_signif</span>(result) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb104-5"><a href="#cb104-5" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Cluster dendrogram </span><span class="sc">\n</span><span class="st"> bp values are highlighted by signif"</span>)</span>
|
|||
|
<span id="cb104-6"><a href="#cb104-6" tabindex="-1"></a></span>
|
|||
|
<span id="cb104-7"><a href="#cb104-7" tabindex="-1"></a>dend <span class="sc">%>%</span> <span class="fu">pvclust_show_signif</span>(result, <span class="at">show_type =</span> <span class="st">"lwd"</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb104-8"><a href="#cb104-8" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Cluster dendrogram with AU/BP values (%)</span><span class="sc">\n</span><span class="st"> bp values are highlighted by signif"</span>)</span>
|
|||
|
<span id="cb104-9"><a href="#cb104-9" tabindex="-1"></a>result <span class="sc">%>%</span> text</span>
|
|||
|
<span id="cb104-10"><a href="#cb104-10" tabindex="-1"></a>result <span class="sc">%>%</span> <span class="fu">pvrect</span>(<span class="at">alpha=</span><span class="fl">0.95</span>)</span>
|
|||
|
<span id="cb104-11"><a href="#cb104-11" tabindex="-1"></a></span>
|
|||
|
<span id="cb104-12"><a href="#cb104-12" tabindex="-1"></a></span>
|
|||
|
<span id="cb104-13"><a href="#cb104-13" tabindex="-1"></a>dend <span class="sc">%>%</span> <span class="fu">pvclust_show_signif_gradient</span>(result) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb104-14"><a href="#cb104-14" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Cluster dendrogram with AU/BP values (%)</span><span class="sc">\n</span><span class="st"> bp values are colored by signif"</span>)</span>
|
|||
|
<span id="cb104-15"><a href="#cb104-15" tabindex="-1"></a></span>
|
|||
|
<span id="cb104-16"><a href="#cb104-16" tabindex="-1"></a>dend <span class="sc">%>%</span></span>
|
|||
|
<span id="cb104-17"><a href="#cb104-17" tabindex="-1"></a> <span class="fu">pvclust_show_signif_gradient</span>(result) <span class="sc">%>%</span></span>
|
|||
|
<span id="cb104-18"><a href="#cb104-18" tabindex="-1"></a> <span class="fu">pvclust_show_signif</span>(result) <span class="sc">%>%</span></span>
|
|||
|
<span id="cb104-19"><a href="#cb104-19" tabindex="-1"></a> <span class="fu">plot</span>(<span class="at">main =</span> <span class="st">"Cluster dendrogram with AU/BP values (%)</span><span class="sc">\n</span><span class="st"> bp values are colored+highlighted by signif"</span>)</span>
|
|||
|
<span id="cb104-20"><a href="#cb104-20" tabindex="-1"></a>result <span class="sc">%>%</span> text</span>
|
|||
|
<span id="cb104-21"><a href="#cb104-21" tabindex="-1"></a>result <span class="sc">%>%</span> <span class="fu">pvrect</span>(<span class="at">alpha=</span><span class="fl">0.95</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAl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888+6F4cyk3KV8vXvf/87YmNjQbmRnZ2tZRVlB3tFeG9QJjCwjSnLzVBWVoYXXnhBK05Tp07F8OHDzUN1fl999VXwBU8lYM6cOXj66act74M6iR1E8L1AuWodnnzySa04MY7y7/nnnwcVwYEDB1qSsYyUm5R7fKeQKbcjIiIsaSgn+ZHL+5eBdfvPf/6Dnj17ahnoqC0sGfyxUd9z4ehe51AfFUSWjeU65ZRT6tTVvBZ7mvl8seOiqKgIBw4c0D177N3j+4+B71321rF3zzrwHMr71atXY+jQodaHnG+rAkoIMALfffcdB4iNW265xWHJlJKl06jeLZ3mkUce0fvLly/X+0oI6H315WGo7lhDCQJD9YIZ6qvEUF8yhnqwdbozzzxTp2PcySefrOOUpq7jVM+WoZQMQylZhuotMn799Vcdr24+Q93MhlLSdHrr/9SDqtOoLlVD3biGUob0fnp6uqG+IHQZlEKlf1nHCy64QJ++e/dunU4JTYN/quta799///36uHr4dR0iIyMNpahY8n344Ycdluvmm2/WeSgBZfA81nHBggWW65GJmZ/qhtdpyZGhd+/eRqtWrfRxpWQZLF+3bt0M5jVixAiDcdxnIHPWRQkhQ3U/G8nJyfpaanhX75OVUlAN9VWp08t/oUHAnedUKd36eTIJqGF/fe+oXoMGPafOniV/PqfOnn9H5XL3ObWXn3rZe/w5NWWpUhx1syllSbfZN998Y6gRAEOZbxgTJ040rGWyMokwlOKi0
|
|||
|
</div>
|
|||
|
<div id="circlize" class="section level3">
|
|||
|
<h3>circlize</h3>
|
|||
|
<p>Circular layout is an efficient way for the visualization of huge
|
|||
|
amounts of information. The circlize package provides an implementation
|
|||
|
of circular layout generation in R, including a solution for dendrogram
|
|||
|
objects produced using dendextend:</p>
|
|||
|
<div class="sourceCode" id="cb105"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb105-1"><a href="#cb105-1" tabindex="-1"></a><span class="fu">library</span>(circlize)</span>
|
|||
|
<span id="cb105-2"><a href="#cb105-2" tabindex="-1"></a></span>
|
|||
|
<span id="cb105-3"><a href="#cb105-3" tabindex="-1"></a>dend <span class="ot"><-</span> iris[<span class="dv">1</span><span class="sc">:</span><span class="dv">40</span>,<span class="sc">-</span><span class="dv">5</span>] <span class="sc">%>%</span> dist <span class="sc">%>%</span> hclust <span class="sc">%>%</span> as.dendrogram <span class="sc">%>%</span></span>
|
|||
|
<span id="cb105-4"><a href="#cb105-4" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"branches_k_color"</span>, <span class="at">k=</span><span class="dv">3</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"branches_lwd"</span>, <span class="fu">c</span>(<span class="dv">5</span>,<span class="dv">2</span>,<span class="fl">1.5</span>)) <span class="sc">%>%</span></span>
|
|||
|
<span id="cb105-5"><a href="#cb105-5" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"branches_lty"</span>, <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">1</span>,<span class="dv">3</span>,<span class="dv">1</span>,<span class="dv">1</span>,<span class="dv">2</span>)) <span class="sc">%>%</span></span>
|
|||
|
<span id="cb105-6"><a href="#cb105-6" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"labels_colors"</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"labels_cex"</span>, <span class="fu">c</span>(.<span class="dv">6</span>,<span class="fl">1.5</span>)) <span class="sc">%>%</span></span>
|
|||
|
<span id="cb105-7"><a href="#cb105-7" tabindex="-1"></a> <span class="fu">set</span>(<span class="st">"nodes_pch"</span>, <span class="dv">19</span>) <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"nodes_col"</span>, <span class="fu">c</span>(<span class="st">"orange"</span>, <span class="st">"black"</span>, <span class="st">"plum"</span>, <span class="cn">NA</span>))</span>
|
|||
|
<span id="cb105-8"><a href="#cb105-8" tabindex="-1"></a></span>
|
|||
|
<span id="cb105-9"><a href="#cb105-9" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mar =</span> <span class="fu">rep</span>(<span class="dv">0</span>,<span class="dv">4</span>))</span>
|
|||
|
<span id="cb105-10"><a href="#cb105-10" tabindex="-1"></a><span class="fu">circlize_dendrogram</span>(dend)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCCAYAAAB8GMlFAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBgE0SQIA9pfFtgo6cKGuhooeilaKH41eDs38Ip+f4At1Rq/sjr6NEwQqb/I/DQqsLvaFUjvAx+eWirddAJZnAj1DFJL0mSg/gcIpPkMBkhoyCSJ8lTZIxk0TpKDjXHliJzZPO50dR5ASNSnzeLvIvod0HG/mdkmOC0z8VKnzcQ2M/Yz2vKldduXjp9bleLu0ZWn7vWc+l0JGcaai10yNrUnXLP/8Jf59ewX+c3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yQgFaE+PCU5xyKRwLcLfHD6YjhGDXJB2xZl8PhpLA4cD8G9RzEwp51TJfKRjR9eDvEJKVi23hfXb0dh85LasLUx0eh8t9JObNC75bBg5iOM+6gSUlJScfZICLr0c9LoOFk7i49NxsMLEYgOT4RFaWPUIEVsapEWRbr2k4d4dCkCbBod+3v1jOjSrH3IcykBfZCAVIT68JTkHAtdAmERSRg49haG9XfCiAEuGePHxiVj5JS74OvrF9aCk0ParuypbxzG/u8ePnu/Itq1sM1or4mDnZS2wOWeZyR6DHIWx9G0I23ewU4ca/p/ERQ56k+oOZak0F2rqU+a97lOJlHKKXSrbSnRZjT9AGR/hS4B6SMsdJHLAfVBAmG0C+LSuJ610nQ5Yb5LRzvs2BMIGwoqSS+lrYwEAkucgikx/dqrfvYZ7gJfMs92H+iEI/8EwsrGGC1oDtoo+/94jnN/+dOuM633ctVLYeDMKrAj/6hiqVxf//2hiuuRxyVbApnhXyVbDnL1UgJKEij1nwnwhb9y5CQ3iqEUg4TEVOzcGyjuSSZT5a79QeLY1VlZYYjKV/xfSFACvO5GI4p2gV0HOKFhSxtEENybpstZUoBntvmjEim5jqNcULN1Gfjej8Gq/z1AeECCynB3TofhNgGPyyIloO8SyHyl1feVyPlrVQLH74Vh57VguDuYo1FFK9SrYAWrYgAnlp3QHCkQxdXJFBu2v0SHlrYw+i9Z/ObdKBw6EYK2zctg9RY/7DsSLGDHfP3iUbemJf1pHmFl18aXIlBmw6LnGDy+HAJfJiCMAnlaanBXyJiq53cGgneAjBSTDiDuSb7I7d/74K+5jzF6voeSGfTkRj8w4kzttpo1BWf3TGS9lIC2JCAVobYkW8z6/f3ICxy6EwY7S
|
|||
|
<div class="sourceCode" id="cb106"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb106-1"><a href="#cb106-1" tabindex="-1"></a><span class="co"># circlize_dendrogram(dend, labels = FALSE)</span></span>
|
|||
|
<span id="cb106-2"><a href="#cb106-2" tabindex="-1"></a><span class="co"># circlize_dendrogram(dend, facing = "inside", labels = FALSE)</span></span></code></pre></div>
|
|||
|
<p>The above is a wrapper for functions in circlize. An advantage for
|
|||
|
using the circlize package directly is for plotting a circular
|
|||
|
dendrogram so that you can add more graphics for the elements in the
|
|||
|
tree just by adding more tracks using . For example:</p>
|
|||
|
<div class="sourceCode" id="cb107"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb107-1"><a href="#cb107-1" tabindex="-1"></a><span class="co"># dend <- iris[1:40,-5] %>% dist %>% hclust %>% as.dendrogram %>%</span></span>
|
|||
|
<span id="cb107-2"><a href="#cb107-2" tabindex="-1"></a><span class="co"># set("branches_k_color", k=3) %>% set("branches_lwd", c(5,2,1.5)) %>%</span></span>
|
|||
|
<span id="cb107-3"><a href="#cb107-3" tabindex="-1"></a><span class="co"># set("branches_lty", c(1,1,3,1,1,2)) %>%</span></span>
|
|||
|
<span id="cb107-4"><a href="#cb107-4" tabindex="-1"></a><span class="co"># set("labels_colors") %>% set("labels_cex", c(.9,1.2)) %>%</span></span>
|
|||
|
<span id="cb107-5"><a href="#cb107-5" tabindex="-1"></a><span class="co"># set("nodes_pch", 19) %>% set("nodes_col", c("orange", "black", "plum", NA))</span></span>
|
|||
|
<span id="cb107-6"><a href="#cb107-6" tabindex="-1"></a></span>
|
|||
|
<span id="cb107-7"><a href="#cb107-7" tabindex="-1"></a><span class="fu">set.seed</span>(<span class="dv">2015-07-10</span>) </span>
|
|||
|
<span id="cb107-8"><a href="#cb107-8" tabindex="-1"></a><span class="co"># In the following we get the dendrogram but can also get extra information on top of it</span></span>
|
|||
|
<span id="cb107-9"><a href="#cb107-9" tabindex="-1"></a><span class="fu">circos.initialize</span>(<span class="st">"foo"</span>, <span class="at">xlim =</span> <span class="fu">c</span>(<span class="dv">0</span>, <span class="dv">40</span>))</span>
|
|||
|
<span id="cb107-10"><a href="#cb107-10" tabindex="-1"></a><span class="fu">circos.track</span>(<span class="at">ylim =</span> <span class="fu">c</span>(<span class="dv">0</span>, <span class="dv">1</span>), <span class="at">panel.fun =</span> <span class="cf">function</span>(x, y) {</span>
|
|||
|
<span id="cb107-11"><a href="#cb107-11" tabindex="-1"></a> <span class="fu">circos.rect</span>(<span class="dv">1</span><span class="sc">:</span><span class="dv">40</span><span class="fl">-0.8</span>, <span class="fu">rep</span>(<span class="dv">0</span>, <span class="dv">40</span>), <span class="dv">1</span><span class="sc">:</span><span class="dv">40</span><span class="fl">-0.2</span>, <span class="fu">runif</span>(<span class="dv">40</span>), <span class="at">col =</span> <span class="fu">rand_color</span>(<span class="dv">40</span>), <span class="at">border =</span> <span class="cn">NA</span>)</span>
|
|||
|
<span id="cb107-12"><a href="#cb107-12" tabindex="-1"></a>}, <span class="at">bg.border =</span> <span class="cn">NA</span>)</span>
|
|||
|
<span id="cb107-13"><a href="#cb107-13" tabindex="-1"></a><span class="fu">circos.track</span>(<span class="at">ylim =</span> <span class="fu">c</span>(<span class="dv">0</span>, <span class="dv">1</span>), <span class="at">panel.fun =</span> <span class="cf">function</span>(x, y) {</span>
|
|||
|
<span id="cb107-14"><a href="#cb107-14" tabindex="-1"></a> <span class="fu">circos.text</span>(<span class="dv">1</span><span class="sc">:</span><span class="dv">40</span><span class="fl">-0.5</span>, <span class="fu">rep</span>(<span class="dv">0</span>, <span class="dv">40</span>), <span class="fu">labels</span>(dend), <span class="at">col =</span> <span class="fu">labels_colors</span>(dend),</span>
|
|||
|
<span id="cb107-15"><a href="#cb107-15" tabindex="-1"></a> <span class="at">facing =</span> <span class="st">"clockwise"</span>, <span class="at">niceFacing =</span> <span class="cn">TRUE</span>, <span class="at">adj =</span> <span class="fu">c</span>(<span class="dv">0</span>, <span class="fl">0.5</span>))</span>
|
|||
|
<span id="cb107-16"><a href="#cb107-16" tabindex="-1"></a>}, <span class="at">bg.border =</span> <span class="cn">NA</span>, <span class="at">track.height =</span> <span class="fl">0.1</span>)</span>
|
|||
|
<span id="cb107-17"><a href="#cb107-17" tabindex="-1"></a>max_height <span class="ot">=</span> <span class="fu">attr</span>(dend, <span class="st">"height"</span>)</span>
|
|||
|
<span id="cb107-18"><a href="#cb107-18" tabindex="-1"></a><span class="fu">circos.track</span>(<span class="at">ylim =</span> <span class="fu">c</span>(<span class="dv">0</span>, max_height), <span class="at">panel.fun =</span> <span class="cf">function</span>(x, y) {</span>
|
|||
|
<span id="cb107-19"><a href="#cb107-19" tabindex="-1"></a> <span class="fu">circos.dendrogram</span>(dend, <span class="at">max_height =</span> max_height)</span>
|
|||
|
<span id="cb107-20"><a href="#cb107-20" tabindex="-1"></a>}, <span class="at">track.height =</span> <span class="fl">0.5</span>, <span class="at">bg.border =</span> <span class="cn">NA</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCCAYAAAB8GMlFAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGf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Ou0hqnEVezUeTuOQLUgwBlhtcDKiZZFoJAe8seSorE2+hFOp8SVrcLRpCgMsxP3IHRwtIKTiw0xwiflaKhy8iQiEbExyXB0slbazbopqSNJQ6ko36AyAiyFU1GhFDq6IrI5qMoIKw5uaVbxisJzTS1Gz
|
|||
|
<div class="sourceCode" id="cb108"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb108-1"><a href="#cb108-1" tabindex="-1"></a><span class="fu">circos.clear</span>()</span></code></pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div id="comparing-two-dendrograms" class="section level2">
|
|||
|
<h2>Comparing two dendrograms</h2>
|
|||
|
<div id="dendlist" class="section level3">
|
|||
|
<h3>dendlist</h3>
|
|||
|
<p>A <code>dendlist</code> is a function which produces the dendlist
|
|||
|
class. It accepts several dendrograms and/or dendlist objects and chain
|
|||
|
them all together. This function aim to help with the usability of
|
|||
|
comparing two or more dendrograms.</p>
|
|||
|
<div class="sourceCode" id="cb109"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb109-1"><a href="#cb109-1" tabindex="-1"></a>dend15 <span class="ot"><-</span> <span class="fu">c</span>(<span class="dv">1</span><span class="sc">:</span><span class="dv">5</span>) <span class="sc">%>%</span> dist <span class="sc">%>%</span> <span class="fu">hclust</span>(<span class="at">method =</span> <span class="st">"average"</span>) <span class="sc">%>%</span> as.dendrogram</span>
|
|||
|
<span id="cb109-2"><a href="#cb109-2" tabindex="-1"></a>dend15 <span class="ot"><-</span> dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"labels_to_char"</span>)</span>
|
|||
|
<span id="cb109-3"><a href="#cb109-3" tabindex="-1"></a>dend51 <span class="ot"><-</span> dend15 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"labels"</span>, <span class="fu">as.character</span>(<span class="dv">5</span><span class="sc">:</span><span class="dv">1</span>)) <span class="sc">%>%</span> <span class="fu">match_order_by_labels</span>(dend15)</span>
|
|||
|
<span id="cb109-4"><a href="#cb109-4" tabindex="-1"></a>dends_15_51 <span class="ot"><-</span> <span class="fu">dendlist</span>(dend15, dend51)</span>
|
|||
|
<span id="cb109-5"><a href="#cb109-5" tabindex="-1"></a>dends_15_51</span></code></pre></div>
|
|||
|
<pre><code>#> [[1]]
|
|||
|
#> 'dendrogram' with 2 branches and 5 members total, at height 2.5
|
|||
|
#>
|
|||
|
#> [[2]]
|
|||
|
#> 'dendrogram' with 2 branches and 5 members total, at height 2.5
|
|||
|
#>
|
|||
|
#> attr(,"class")
|
|||
|
#> [1] "dendlist"</code></pre>
|
|||
|
<div class="sourceCode" id="cb111"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb111-1"><a href="#cb111-1" tabindex="-1"></a><span class="fu">head</span>(dends_15_51)</span></code></pre></div>
|
|||
|
<pre><code>#> ============
|
|||
|
#> dend 1
|
|||
|
#> ---------
|
|||
|
#> --[dendrogram w/ 2 branches and 5 members at h = 2.5]
|
|||
|
#> |--[dendrogram w/ 2 branches and 2 members at h = 1]
|
|||
|
#> | |--leaf "1"
|
|||
|
#> | `--leaf "2"
|
|||
|
#> `--[dendrogram w/ 2 branches and 3 members at h = 1.5]
|
|||
|
#> |--leaf "5"
|
|||
|
#> `--[dendrogram w/ 2 branches and 2 members at h = 1]
|
|||
|
#> |--leaf "3"
|
|||
|
#> `--leaf "4"
|
|||
|
#> etc...
|
|||
|
#> ============
|
|||
|
#> dend 2
|
|||
|
#> ---------
|
|||
|
#> --[dendrogram w/ 2 branches and 5 members at h = 2.5]
|
|||
|
#> |--[dendrogram w/ 2 branches and 2 members at h = 1]
|
|||
|
#> | |--leaf "5"
|
|||
|
#> | `--leaf "4"
|
|||
|
#> `--[dendrogram w/ 2 branches and 3 members at h = 1.5]
|
|||
|
#> |--leaf "3"
|
|||
|
#> `--[dendrogram w/ 2 branches and 2 members at h = 1]
|
|||
|
#> |--leaf "2"
|
|||
|
#> `--leaf "1"
|
|||
|
#> etc...</code></pre>
|
|||
|
<p>The function <code>match_order_by_labels</code> makes sure that the
|
|||
|
order in the leaves corresponds to the same labels in both trees.</p>
|
|||
|
</div>
|
|||
|
<div id="dend_diff" class="section level3">
|
|||
|
<h3>dend_diff</h3>
|
|||
|
<p>The <code>dend_diff</code> function plots two trees side by side,
|
|||
|
highlighting edges unique to each tree in red, it relies on the
|
|||
|
<code>distinct_edges</code> function.</p>
|
|||
|
<p>For example:</p>
|
|||
|
<div class="sourceCode" id="cb113"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb113-1"><a href="#cb113-1" tabindex="-1"></a><span class="co"># example 1</span></span>
|
|||
|
<span id="cb113-2"><a href="#cb113-2" tabindex="-1"></a>x <span class="ot"><-</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">5</span> <span class="sc">%>%</span> dist <span class="sc">%>%</span> hclust <span class="sc">%>%</span> as.dendrogram</span>
|
|||
|
<span id="cb113-3"><a href="#cb113-3" tabindex="-1"></a>y <span class="ot"><-</span> <span class="fu">set</span>(x, <span class="st">"labels"</span>, <span class="dv">5</span><span class="sc">:</span><span class="dv">1</span>)</span>
|
|||
|
<span id="cb113-4"><a href="#cb113-4" tabindex="-1"></a></span>
|
|||
|
<span id="cb113-5"><a href="#cb113-5" tabindex="-1"></a><span class="co"># example 2</span></span>
|
|||
|
<span id="cb113-6"><a href="#cb113-6" tabindex="-1"></a>dend1 <span class="ot"><-</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">10</span> <span class="sc">%>%</span> dist <span class="sc">%>%</span> hclust <span class="sc">%>%</span> as.dendrogram</span>
|
|||
|
<span id="cb113-7"><a href="#cb113-7" tabindex="-1"></a>dend2 <span class="ot"><-</span> dend1 <span class="sc">%>%</span> <span class="fu">set</span>(<span class="st">"labels"</span>, <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">3</span>,<span class="dv">2</span>,<span class="dv">4</span>, <span class="dv">5</span><span class="sc">:</span><span class="dv">10</span>) )</span>
|
|||
|
<span id="cb113-8"><a href="#cb113-8" tabindex="-1"></a><span class="fu">dend_diff</span>(dend1, dend2)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCCAYAAAB8GMlFAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBgE0SQIA9pfFtgo6cKGuhooeilaKH41eDs38Ip+f4At1Rq/sjr6NEwQqb/I/DQqsLvaFUjvAx+eWirddAJZnAj1DFJL0mSg/gcIpPkMBkhoyCSJ8lTZIxk0TpKDjXHliJzZPO50dR5ASNSnzeLvIvod0HG/mdkmOC0z8VKnzcQ2M/Yz2vKldduXjp9bleLu0ZWn7vWc+l0JGcaai10yNrUnXLP/8Jf59ewX+c3Wgz+B34Df+vbVrc16zTMVgp9um9bxEfzPU5kPqUtVWxhs6OiWTVW+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1jVTHAKRJLBx40aZMmWKzJ0796JhLVu2TObNmycpKSly7733Gvtqfn7+Rcv5+wTvCP0VY3lbCzz88MMye/ZsiY2NNd4RdurUSYYNG2brmikOgUgSSE9Plx9//FHKy8ubDauhoUEOHTokaWlpnufVKYx9+/Z5Hgd6hyAMVI71wirw9NNPi/pNsGvXrn6Pw9s7vB49ekhUVJTR9g8//CATJkyQ6Ohov/tgBQTsLqBrH/zlecEmx6NHj4rL5ZKOHTs2PWXcLy0t9TwO9A5BGKgc64VVQP0mqE6aT58+3dRxZGVlyYIFC+T++++XxsZG4/Do4sWLJScnx9R+aAwBqwvo2gcv5aICUAVhXV2dxMXFGYvV1tbK5ZdffqlVfH6ec4Q+U7Gg3QWOHDkiBw4ckPHjxxultm7dWsaNGydbtmyxe+nUh0DEC6gL1tQ/tY823dR9dQVpsDeCMFhB1reNgLryrGfPnsZhUVVUVVWVvP/++3LDDTfYpkYKQcDKAupIjbpy9PTp07Jz505Zu3at8ctqsDURhMEKsr5tBNS5wVWrVklhYaFkZGTIkCFDjJ3siSeesE2NFIKAlQXUecndu3cb7wLHjh1rXEGqDtEGe+McYbCCrG8rgcGDBxvvAtUH69u3by+tWvG7oq0mmGIsI9C9e3fjPP2FA1ZHbbZu3SplZWXGh+3N2j8JwguVuY/AOQE+QM+mgEDkCgRytbi3avh115sOryGAAAII2F6AILT9FFMgAggggIA3AYLQmw6vIYAAAgjYXoAgtP0UUyACCCCAgDcBgtCbDq8hgAACCNhegCC0/RRTIAIIIICANwGC0JsOryGAAAII2F6AzxHafopDV+DSpUtFf
|
|||
|
<p>See the <code>highlight_distinct_edges</code> function for more
|
|||
|
control over how to create the distinction (color, line width, line
|
|||
|
type).</p>
|
|||
|
</div>
|
|||
|
<div id="tanglegram" class="section level3">
|
|||
|
<h3>tanglegram</h3>
|
|||
|
<p>A tanglegram plot gives two dendrogram (with the same set of labels),
|
|||
|
one facing the other, and having their labels connected by lines.
|
|||
|
Tanglegram can be used for visually comparing two methods of
|
|||
|
Hierarchical clustering, and are sometimes used in biology when
|
|||
|
comparing two phylogenetic trees.</p>
|
|||
|
<p>Here is an example of creating a tanglegram using dendextend:</p>
|
|||
|
<div class="sourceCode" id="cb114"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb114-1"><a href="#cb114-1" tabindex="-1"></a><span class="fu">tanglegram</span>(dends_15_51)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXcAAADhCAYAAAAziPUUAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBgE0SQIA9pfFtgo6cKGuhooeilaKH41eDs38Ip+f4At1Rq/sjr6NEwQqb/I/DQqsLvaFUjvAx+eWirddAJZnAj1DFJL0mSg/gcIpPkMBkhoyCS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IpLB4UDe4IDArlc+prwTZ8T2Knd2oKp3dHA4hjcwAr4iwMbdV8T4eJcIIByyWrVqYv/Vq1dp7dq1hom8cNmoIO849sMaOr50rThLyYrlqOEzA4N8RlYfKgiwcQ+VK10E7UTkTOvWralChQribLm5ucLAI1KHxRGBKyfP0q4pn6g7ksYPZXeMigYvBIoAG/dAEeTyNgggjr5du3bq/ADE18NF4ywO36ZgCK5kKH72/HMXRctr3HcrVUoxRghiCF4qQzaZjbshL5u+K12iRAlq3749xcTEiIqCogA0CAUFBfqueBHW7tCCn+jUb4UzQUtVr0T1/tW/CM/OpwoFBNi4h8JVLoY2lipVShh4Sd+ACScIk2QeGqLLh09Q9tRZ6lVJnjiCImOj1XVeYAS0QICNuxYosg6nCGCGLHrwkZGF0ykOHTpEmOgUyoKXW/q4D+iaMhsVkvDIXRR3Y3IoQ8JtDxICbNyDBCyrLUQARFVt27al8PDCW2337t2UkZERsvAc+GwJnd2UJtofU7cmJQ6/L2Sx4IYHFwE27sHFl7UrCFSuXJluvPFGFQsQmYFsLNQkZ/ch2vP+fNHssIhwaqy4YyKijME6GmrXygztNbRxR9KBihUrCqZDRGngDzS9Y8eOdXttYFhgbOAukOWw3KFDB4JvmEV7BGrUqEHNmzdXFW/dupUOHz6srpt9oSD/GqW98B4V5F0VTU18/D4q07iu2ZsdtPaBKwmsrd9++636DMtnOZBffGEipBe/gwcPDlr9i0KxoY37v/71LzHNHVEY8g+hd5MmTSL4d13JW2+9JQb3MJNSlsMyCLCmT58uiu3duzdoHOiu6mX27YmJiZScfN2/vGnTJjp58qTZm114P01fSBfS9ohlGPWEgb1Cot3BauTnn38uGCExhiGfYS1+5YA/ftF5NLIY2rjDWDgT+HndJSVwVQ665D64EsBwyKItAmCRrFOnjlCKh3HdunWCsVLbs+hL2/nUbNr/8deiUuElSxCiY8IjtefV1
|
|||
|
<div class="sourceCode" id="cb115"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb115-1"><a href="#cb115-1" tabindex="-1"></a><span class="co"># Same as using:</span></span>
|
|||
|
<span id="cb115-2"><a href="#cb115-2" tabindex="-1"></a><span class="co"># plot(dends_15_51) # since there is a plot method for dendlist</span></span>
|
|||
|
<span id="cb115-3"><a href="#cb115-3" tabindex="-1"></a><span class="co"># and also: </span></span>
|
|||
|
<span id="cb115-4"><a href="#cb115-4" tabindex="-1"></a><span class="co"># tanglegram(dend15, dend51)</span></span></code></pre></div>
|
|||
|
<p>Notice how “unique” nodes are highlighted with dashed lines (i.e.:
|
|||
|
nodes which contains a combination of labels/items, which are not
|
|||
|
present in the other tree). This can be turned off using
|
|||
|
<code>highlight_distinct_edges = FALSE</code>. Also notice how the
|
|||
|
connecting lines are colored to highlight two sub-trees which are
|
|||
|
present in both dendrograms. This can be turned off by setting
|
|||
|
<code>common_subtrees_color_lines = FALSE</code>. We can also color the
|
|||
|
branches of the trees to show the two common sub-trees using
|
|||
|
<code>common_subtrees_color_branches = TRUE</code>:</p>
|
|||
|
<div class="sourceCode" id="cb116"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb116-1"><a href="#cb116-1" tabindex="-1"></a><span class="fu">tanglegram</span>(dends_15_51, <span class="at">common_subtrees_color_branches =</span> <span class="cn">TRUE</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXcAAADhCAYAAAAziPUUAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSw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ufbVW9juNvx+VE+4Y/wzewTrqczdLBx32am4ZJB0YPHgwPXz4UL0VmTJlInCcjB8/Xj1mvnHlyhXJ+Hjs2DGVizxNmjRUo0YNOcr0ZrIw8756yj4YNr/++msCnzikT58+kkny7bff9pQmurQdoKc9M/J/lBBrnFQu1ucdylquhEuvqWflcU+i6MQnMyU18q4qGk9Gg7gtDVH+lvWo7Ng+XgujV4/cYcTv379PCQmCpvT//0BtO2HCBLp+/brNmwLXwOHDhyUFrlIPdLj//vuvykt++fJlDt+ziWDyTvTu3Vt1yQBvEIz9+eefyVPmZbUuL/iZnpy5JFsNo16ka0sv64FnNffWb39Jwy5bBWOs5R+UCpW31nv3s+nVxr1YsWLy3pr/Q0ICe0kJbNWDHuUc2A0VP7G5ft5PPgIjRoygjz76SCqIi
|
|||
|
<p>We may wish to improve the layout of the trees. For this we have the
|
|||
|
<code>entanglement</code>, to measure the quality of the alignment of
|
|||
|
the two trees in the tanglegram layout, and the <code>untangle</code>
|
|||
|
function, for improving it.</p>
|
|||
|
<div class="sourceCode" id="cb117"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb117-1"><a href="#cb117-1" tabindex="-1"></a>dends_15_51 <span class="sc">%>%</span> entanglement <span class="co"># lower is better</span></span></code></pre></div>
|
|||
|
<pre><code>#> [1] 0.9167078</code></pre>
|
|||
|
<div class="sourceCode" id="cb119"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb119-1"><a href="#cb119-1" tabindex="-1"></a><span class="co"># dends_15_51 %>% untangle(method = "DendSer") %>% entanglement # lower is better</span></span>
|
|||
|
<span id="cb119-2"><a href="#cb119-2" tabindex="-1"></a>dends_15_51 <span class="sc">%>%</span> <span class="fu">untangle</span>(<span class="at">method =</span> <span class="st">"step1side"</span>) <span class="sc">%>%</span> entanglement <span class="co"># lower is better</span></span></code></pre></div>
|
|||
|
<pre><code>#> [1] 0</code></pre>
|
|||
|
<p>Notice that just because we can get two trees to have horizontal
|
|||
|
connecting lines, it doesn’t mean these trees are identical (or even
|
|||
|
very similar topologically):</p>
|
|||
|
<div class="sourceCode" id="cb121"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb121-1"><a href="#cb121-1" tabindex="-1"></a>dends_15_51 <span class="sc">%>%</span> <span class="fu">untangle</span>(<span class="at">method =</span> <span class="st">"step1side"</span>) <span class="sc">%>%</span> </span>
|
|||
|
<span id="cb121-2"><a href="#cb121-2" tabindex="-1"></a> <span class="fu">tanglegram</span>(<span class="at">common_subtrees_color_branches =</span> <span class="cn">TRUE</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXcAAADhCAYAAAAziPUUAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBgE0SQIA9pfFtgo6cK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FWpg5c6bUqFFDlYcN/z+MVpo4cWIkEwH5r732mlSvXj3Ajm4zN
|
|||
|
<p>Entanglement is measured by giving the left tree’s labels the values
|
|||
|
of 1 till tree size, and than match these numbers with the right tree.
|
|||
|
Now, entanglement is the L norm distance between these two vectors. That
|
|||
|
is, we take the sum of the absolute difference (each one in the power of
|
|||
|
L). e.g: <code>sum(abs(x-y)**L)</code>. And this is divided by the
|
|||
|
“worst case” entanglement level (e.g: when the right tree is the
|
|||
|
complete reverse of the left tree).</p>
|
|||
|
<p>L tells us which penalty level we are at (L0, L1, L2, partial L’s
|
|||
|
etc). L>1 means that we give a big penalty for sharp angles. While
|
|||
|
L->0 means that any time something is not a straight horizontal line,
|
|||
|
it gets a large penalty If L=0.1 it means that we much prefer straight
|
|||
|
lines over non straight lines</p>
|
|||
|
<p>Finding an optimal rotation for the tanglegram of two dendrogram is a
|
|||
|
hard problem. This problem is also harder for larger trees.</p>
|
|||
|
<p>Let’s see how well some untangle methods can do.</p>
|
|||
|
<p>Without doing anything:</p>
|
|||
|
<div class="sourceCode" id="cb122"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb122-1"><a href="#cb122-1" tabindex="-1"></a>x <span class="ot"><-</span> dends_15_51 </span>
|
|||
|
<span id="cb122-2"><a href="#cb122-2" tabindex="-1"></a>x <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="fu">paste</span>(<span class="st">"entanglement ="</span>, <span class="fu">round</span>(<span class="fu">entanglement</span>(x), <span class="dv">2</span>)))</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXcAAADhCAYAAAAziPUUAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu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Y50nNuTtziauaf211DneJGhH2Y/7du3V1Xd/gpNJtmmu41KYI3rDh482G1bKhOboCj/9ddfqySHX7FKkGXEbNwhz1WCWEXIOkL7xlURTneCADN3J6A4S8KsTzEzMFIhxtCLgRk+9NBD8gEEg8FsUJFi7njoMbPZsmWLypJtNGnSRNbDBpRxVuJOPnvvvffKOvfdd58GjQcjCTGEzMP13nnnHWOWppgS8l5++WUNzE0R5K5KOwGzcSNh1YE6tWvX1jDrVwRMwOiRh48Z5m4FjlitiOW86ob27bff6n1AP8CQ1aYcCv3nP/+R+ZjhG/F67733ZDpWRUKspbeHg8WLF0vtEbSHmaWRfMXR3T01tm88Bl5vvvmm6Q9WimZIrdqwmemKsFLD+DGJMUO4/yiPjVpnhP8FnnOUwerSDK1Zs0Z/Lt29NMy0FW1lmLmbvOOvvPKKfCjr1KljwyBU9UuXLmllypSRZaZPn66SNSNzd7ZxtWrVKlkHD7yQY+v1XDECLPEhFsBmGFTrnFGDBg1km5jxGEkxJeQbX0CqDMRN6AeW7Ir27dun90/Io1Wy/
|
|||
|
<p>Using DendSer:</p>
|
|||
|
<div class="sourceCode" id="cb123"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb123-1"><a href="#cb123-1" tabindex="-1"></a><span class="co"># x <- dends_15_51 %>% untangle(method = "DendSer") </span></span>
|
|||
|
<span id="cb123-2"><a href="#cb123-2" tabindex="-1"></a>x <span class="ot"><-</span> dends_15_51 <span class="sc">%>%</span> <span class="fu">untangle</span>(<span class="at">method =</span> <span class="st">"ladderize"</span>) </span>
|
|||
|
<span id="cb123-3"><a href="#cb123-3" tabindex="-1"></a>x <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="fu">paste</span>(<span class="st">"entanglement ="</span>, <span class="fu">round</span>(<span class="fu">entanglement</span>(x), <span class="dv">2</span>)))</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXcAAADhCAYAAAAziPUUAAAE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J56Qv8WLF5f1Vq9eXZ6jHBgy5K56ggy0SZMmMg/kph07dpTjVswb40HZO++8U19M1oV044ZqIDjecccdjrJly0rGLbQpHPq+ox8zZsyQL141NoUj+gEmqaeUlBQ5D7gG3ND/xx57zCE0R+Q50nFuJH9xtDKnxjbUOV5k6IfVv3vuuUcV9forNJlknd42KoE12n322We91qUuYhMU+f/3v/+pJLdf8ZUg84jVuNs1TwniK0KWEdo3nrJwugkCzNxNQDFLwqpPMTMwUiHG0LKBGXbv3l3egGAwWA0qUswdNz1WNps3b1aXZB3NmjWT5bABpV+VeJPP3n///bJMp06dHNB40JMQQ8hraO+9997TX3IopoRrr776qgPMTRHkrko7AatxPeGrA2Vq1arlwKpfETABo8c1/Flh7nbgiK8V8TmvuuH4+eeftT6gH2DIalMOmZ5//nl5HSt8PV4ffPCBTMdXkRBrafXhYP78+VJ7BPVhZamntOLobU719euPgddbb71l+Q9filZIfbVhM9MT4UsN48cixgph/pEfG7VmhOcC9zny4OvSCq1atUq7L729NKzUFWt5mLlbnPGhQ4fKm7J27douDEIVv3TpkqNkyZIyzw8//KCSHXrmbrZx9ffff8syuOGFHFsr54kR4BMfYgFshkG1zozq168v68SKR0+KKeG6/gWk8kDchH7gk11RQkKC1
|
|||
|
<p>One solution for improving the tanglegram would be to randomly search
|
|||
|
the rotated tree space for a better solution. Here is how to use a
|
|||
|
random search:</p>
|
|||
|
<div class="sourceCode" id="cb124"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb124-1"><a href="#cb124-1" tabindex="-1"></a><span class="fu">set.seed</span>(<span class="dv">3958</span>)</span>
|
|||
|
<span id="cb124-2"><a href="#cb124-2" tabindex="-1"></a>x <span class="ot"><-</span> dends_15_51 <span class="sc">%>%</span> <span class="fu">untangle</span>(<span class="at">method =</span> <span class="st">"random"</span>, <span class="at">R =</span> <span class="dv">10</span>) </span>
|
|||
|
<span id="cb124-3"><a href="#cb124-3" tabindex="-1"></a>x <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="fu">paste</span>(<span class="st">"entanglement ="</span>, <span class="fu">round</span>(<span class="fu">entanglement</span>(x), <span class="dv">2</span>)))</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXcAAADhCAYAAAAziPUUAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBgE0SQIA9pfFtgo6cKGuhooeilaKH41eDs38Ip+f4At1Rq/sjr6NEwQqb/I/DQqsLvaFUjvAx+eWirddAJZnAj1DFJL0mSg/gcIpPkMBkhoyCSJ8lTZIxk0TpKDjXHliJzZPO50dR5ASNSnzeLvIvod0HG/mdkmOC0z8VKnzcQ2M/Yz2vKldduXjp9bleLu0ZWn7vWc+l0JGcaai10yNrU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wA/8FY90ShZjj/+eB3317/+Vf/HBwW+J554or5HPijk/fv3R+XDZFbLli11mtKlS1vKDqrLbZQ3yoO855xzTlQ+E++cUC0IjmeddZZVs2ZNrbhPOeWUKNkhx7Rp03TDa8pmcIR8UJJ2+uWXX3Q9IA64Qf6BAwdaauWIvkc47p2UKo7J1KnzGeYeDRnkSPY699xzTda4/9VKJs3zrrvu8kwHrPHcG264wTONPSIdnugc4BmoJy9So9JI+VeuXOmVjOEOBKjcHYB43aLXZ5QVFKkyY0SSQhn26dNHv4BQMOgNGjLKHS8weoPLly83UZpH69atdb5jjz3WUpNYkbh49tkePXroPD179rSwOsFOygwR+RAefvhhe5RllBJkURNfFpSbIdhdTa8cH5ydMOpAnkaNGlno9RsCJlD0iMOVjHL3A0eMVr788ksjhvXqq69GZIAcUMj21RVqWK/j0cO346Um8XQ4RkVQIHaaM2eOXj0CfrNnz7ZHpY1jvDqNeoDtBngpc0XSF0aKyZAZtamlhp7JMVJD+dGJSYbS4fnBBx/oZ8TrlaulmjoNZFGTq8mIwjQKASr3JF+DO+64Q79gjRs3jlIQJvvPP/9sVa9eXaeZOHGiCbbsyt1t4uqjjz6KvLjKjh3J56UIMMSHWQCTYVha50bNmjXTPJ0TVEa5I97eABkeMDfhA8Lw2tDGjRsj8mF47CSYDY4++midJhnlnikcoaAhO8wrqAs7AVfE4frqq690FEY1pUqV0mGTJ0+2J4/8fuqpp3Q8zBN2SgdH5PeqUzvvbP025jwv0xPkQCMJzHr16pWUWOnwxPtsRrB///vfY56DRvqEE07QckAWNQcQk4YB7ghwQlW9McnQvHnzdDLVmxFlWonJomzwk
|
|||
|
<p>We can see we already got something better. An advantage of the
|
|||
|
random search is the ability to create many many trees and compare them
|
|||
|
to find the best pair.</p>
|
|||
|
<p>Let’s use a greedy forward step wise rotation of the two trees (first
|
|||
|
the left, then the right, and so on), to see if we can find a better
|
|||
|
solution for comparing the two trees. Notice that this may take some
|
|||
|
time to run (the larger the tree, the longer it would take), but we can
|
|||
|
limit the search for smaller k’s, and see what improvement that can
|
|||
|
bring us using step2side (slowest):</p>
|
|||
|
<div class="sourceCode" id="cb125"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb125-1"><a href="#cb125-1" tabindex="-1"></a>x <span class="ot"><-</span> dends_15_51 <span class="sc">%>%</span> <span class="fu">untangle</span>(<span class="at">method =</span> <span class="st">"step2side"</span>) </span>
|
|||
|
<span id="cb125-2"><a href="#cb125-2" tabindex="-1"></a>x <span class="sc">%>%</span> <span class="fu">plot</span>(<span class="at">main =</span> <span class="fu">paste</span>(<span class="st">"entanglement ="</span>, <span class="fu">round</span>(<span class="fu">entanglement</span>(x), <span class="dv">2</span>)))</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXcAAADhCAYAAAAziPUUAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqM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BMlmYDrYSwxw0N1nYjqqhD1Ki0bNmywxJg/YitCHSSjCx4Oq1at0tnr1q1rF2Mdq+4oKV++fEILXtLlCF5qINe6t3mgBkD14VFHH
|
|||
|
<p>We got perfect entanglement (0).</p>
|
|||
|
</div>
|
|||
|
<div id="correlation-measures" class="section level3">
|
|||
|
<h3>Correlation measures</h3>
|
|||
|
<p>We shall use the following for the upcoming examples:</p>
|
|||
|
<div class="sourceCode" id="cb126"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb126-1"><a href="#cb126-1" tabindex="-1"></a><span class="fu">set.seed</span>(<span class="dv">23235</span>)</span>
|
|||
|
<span id="cb126-2"><a href="#cb126-2" tabindex="-1"></a>ss <span class="ot"><-</span> <span class="fu">sample</span>(<span class="dv">1</span><span class="sc">:</span><span class="dv">150</span>, <span class="dv">10</span> )</span>
|
|||
|
<span id="cb126-3"><a href="#cb126-3" tabindex="-1"></a>dend1 <span class="ot"><-</span> iris[ss,<span class="sc">-</span><span class="dv">5</span>] <span class="sc">%>%</span> dist <span class="sc">%>%</span> <span class="fu">hclust</span>(<span class="st">"com"</span>) <span class="sc">%>%</span> as.dendrogram</span>
|
|||
|
<span id="cb126-4"><a href="#cb126-4" tabindex="-1"></a>dend2 <span class="ot"><-</span> iris[ss,<span class="sc">-</span><span class="dv">5</span>] <span class="sc">%>%</span> dist <span class="sc">%>%</span> <span class="fu">hclust</span>(<span class="st">"single"</span>) <span class="sc">%>%</span> as.dendrogram</span>
|
|||
|
<span id="cb126-5"><a href="#cb126-5" tabindex="-1"></a>dend3 <span class="ot"><-</span> iris[ss,<span class="sc">-</span><span class="dv">5</span>] <span class="sc">%>%</span> dist <span class="sc">%>%</span> <span class="fu">hclust</span>(<span class="st">"ave"</span>) <span class="sc">%>%</span> as.dendrogram</span>
|
|||
|
<span id="cb126-6"><a href="#cb126-6" tabindex="-1"></a>dend4 <span class="ot"><-</span> iris[ss,<span class="sc">-</span><span class="dv">5</span>] <span class="sc">%>%</span> dist <span class="sc">%>%</span> <span class="fu">hclust</span>(<span class="st">"centroid"</span>) <span class="sc">%>%</span> as.dendrogram</span>
|
|||
|
<span id="cb126-7"><a href="#cb126-7" tabindex="-1"></a></span>
|
|||
|
<span id="cb126-8"><a href="#cb126-8" tabindex="-1"></a>dend1234 <span class="ot"><-</span> <span class="fu">dendlist</span>(<span class="st">"Complete"</span> <span class="ot">=</span> dend1, <span class="st">"Single"</span> <span class="ot">=</span> dend2, <span class="st">"Average"</span> <span class="ot">=</span> dend3, <span class="st">"Centroid"</span> <span class="ot">=</span> dend4)</span>
|
|||
|
<span id="cb126-9"><a href="#cb126-9" tabindex="-1"></a></span>
|
|||
|
<span id="cb126-10"><a href="#cb126-10" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">2</span>,<span class="dv">2</span>))</span>
|
|||
|
<span id="cb126-11"><a href="#cb126-11" tabindex="-1"></a><span class="fu">plot</span>(dend1, <span class="at">main =</span> <span class="st">"Complete"</span>)</span>
|
|||
|
<span id="cb126-12"><a href="#cb126-12" tabindex="-1"></a><span class="fu">plot</span>(dend2, <span class="at">main =</span> <span class="st">"Single"</span>)</span>
|
|||
|
<span id="cb126-13"><a href="#cb126-13" tabindex="-1"></a><span class="fu">plot</span>(dend3, <span class="at">main =</span> <span class="st">"Average"</span>)</span>
|
|||
|
<span id="cb126-14"><a href="#cb126-14" tabindex="-1"></a><span class="fu">plot</span>(dend4, <span class="at">main =</span> <span class="st">"Centroid"</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCCAYAAAB8GMlFAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3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kE32O8ZBwB7URxg3xi7AYQ8mWLZseOwkPy3MSSFcCUH9C/Y9xdLQHqD2//fZbefnll6MWCeOGSnDqsUO092PHjsnBgwflhx9+0EMcaM9Ks6KHK6JFgraIOHr06CFK2OohDrPNRbuH/okT4Bhh4qyyLCQsRGfNmiVKzaKtRZGQ6oXJPffcIy+99JIef0NjwTid6SAY4YIH5mFtCmeOP0DQBZ/rk///h0ZkOqWG0eMasFgNdmj0cP3795dmzZoJxiaUSkaPc5jh1LeYPlTqGi340OjvuOMOaBr0n1LjmkH5SwJpTeCzzz6TK6+8Uh577DF54IEHtJGMGo4QNTQgGL+L5pQmJ3BJDW3oY7Q1GMVhPN90q1evNg8jftEWITxHjhyp27fZFiMC0sMWAQpCW9gy96Ynn3xSLrzwQv11CQtMfPm9/fbbuicHIYTGc9lll8kXX3yhzanVeIMWkOj5KZVJSGNKNGcLFy6U//znP5I7d25ZunSp3HTTTVqQBd+PuOFmz56tv1xHjBihe3ww4MF9ELgbNmzQx
|
|||
|
<div id="global-comparison-of-two-or-more-dendrograms" class="section level4">
|
|||
|
<h4>Global Comparison of two (or more) dendrograms</h4>
|
|||
|
<p>The <code>all.equal.dendrogram</code> function makes a global
|
|||
|
comparison of two or more dendrograms trees.</p>
|
|||
|
<div class="sourceCode" id="cb127"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb127-1"><a href="#cb127-1" tabindex="-1"></a><span class="fu">all.equal</span>(dend1, dend1)</span></code></pre></div>
|
|||
|
<pre><code>#> [1] TRUE</code></pre>
|
|||
|
<div class="sourceCode" id="cb129"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb129-1"><a href="#cb129-1" tabindex="-1"></a><span class="fu">all.equal</span>(dend1, dend2)</span></code></pre></div>
|
|||
|
<pre><code>#> [1] "Difference in branch heights - Mean relative difference: 0.4932164"</code></pre>
|
|||
|
<div class="sourceCode" id="cb131"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb131-1"><a href="#cb131-1" tabindex="-1"></a><span class="fu">all.equal</span>(dend1, dend2, <span class="at">use.edge.length =</span> <span class="cn">FALSE</span>)</span></code></pre></div>
|
|||
|
<pre><code>#> [1] "Dendrograms contain diffreent edges (i.e.: topology). Unique edges in target: | 2, 7, 13 | Unique edges in current: 7, 9, 11"</code></pre>
|
|||
|
<div class="sourceCode" id="cb133"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb133-1"><a href="#cb133-1" tabindex="-1"></a><span class="fu">all.equal</span>(dend1, dend2, <span class="at">use.edge.length =</span> <span class="cn">FALSE</span>, <span class="at">use.topology =</span> <span class="cn">FALSE</span>)</span></code></pre></div>
|
|||
|
<pre><code>#> [1] TRUE</code></pre>
|
|||
|
<div class="sourceCode" id="cb135"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb135-1"><a href="#cb135-1" tabindex="-1"></a><span class="fu">all.equal</span>(dend2, dend4, <span class="at">use.edge.length =</span> <span class="cn">TRUE</span>)</span></code></pre></div>
|
|||
|
<pre><code>#> [1] "Difference in branch heights - Mean relative difference: 0.1969642"</code></pre>
|
|||
|
<div class="sourceCode" id="cb137"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb137-1"><a href="#cb137-1" tabindex="-1"></a><span class="fu">all.equal</span>(dend2, dend4, <span class="at">use.edge.length =</span> <span class="cn">FALSE</span>)</span></code></pre></div>
|
|||
|
<pre><code>#> [1] "Dendrograms contain diffreent edges (i.e.: topology). Unique edges in target: | 11 | Unique edges in current: 13"</code></pre>
|
|||
|
<div class="sourceCode" id="cb139"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb139-1"><a href="#cb139-1" tabindex="-1"></a><span class="fu">all.equal</span>(<span class="fu">dendlist</span>(dend1, dend1, dend1))</span></code></pre></div>
|
|||
|
<pre><code>#> [1] TRUE</code></pre>
|
|||
|
<div class="sourceCode" id="cb141"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb141-1"><a href="#cb141-1" tabindex="-1"></a><span class="fu">all.equal</span>(dend1234)</span></code></pre></div>
|
|||
|
<pre><code>#> 1==2
|
|||
|
#> "Difference in branch heights - Mean relative difference: 0.4932164"
|
|||
|
#> 1==3
|
|||
|
#> "Difference in branch heights - Mean relative difference: 0.2767035"
|
|||
|
#> 1==4
|
|||
|
#> "Difference in branch heights - Mean relative difference: 0.4081231"
|
|||
|
#> 2==3
|
|||
|
#> "Difference in branch heights - Mean relative difference: 0.4545673"
|
|||
|
#> 2==4
|
|||
|
#> "Difference in branch heights - Mean relative difference: 0.1969642"
|
|||
|
#> 3==4
|
|||
|
#> "Difference in branch heights - Mean relative difference: 0.1970749"</code></pre>
|
|||
|
<div class="sourceCode" id="cb143"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb143-1"><a href="#cb143-1" tabindex="-1"></a><span class="fu">all.equal</span>(dend1234, <span class="at">use.edge.length =</span> <span class="cn">FALSE</span>)</span></code></pre></div>
|
|||
|
<pre><code>#> 1==2
|
|||
|
#> "Dendrograms contain diffreent edges (i.e.: topology). Unique edges in target: | 2, 7, 13 | Unique edges in current: 7, 9, 11"
|
|||
|
#> 1==3
|
|||
|
#> "Dendrograms contain diffreent edges (i.e.: topology). Unique edges in target: | 7 | Unique edges in current: 7"
|
|||
|
#> 1==4
|
|||
|
#> "Dendrograms contain diffreent edges (i.e.: topology). Unique edges in target: | 2, 7 | Unique edges in current: 7, 9"
|
|||
|
#> 2==3
|
|||
|
#> "Dendrograms contain diffreent edges (i.e.: topology). Unique edges in target: | 9, 11 | Unique edges in current: 8, 15"
|
|||
|
#> 2==4
|
|||
|
#> "Dendrograms contain diffreent edges (i.e.: topology). Unique edges in target: | 11 | Unique edges in current: 13"
|
|||
|
#> 3==4
|
|||
|
#> "Dendrograms contain diffreent edges (i.e.: topology). Unique edges in target: | 15 | Unique edges in current: 9"</code></pre>
|
|||
|
</div>
|
|||
|
<div id="distance-matrix-using-dist.dendlist" class="section level4">
|
|||
|
<h4>Distance matrix using dist.dendlist</h4>
|
|||
|
<p>The <code>dist.dendlist</code> function computes the Robinson-Foulds
|
|||
|
distance (also known as symmetric difference) between two dendrograms.
|
|||
|
This is the sum of edges in both trees with labels that exist in only
|
|||
|
one of the two trees (i.e.: the length of
|
|||
|
<code>distinct_edges</code>).</p>
|
|||
|
<div class="sourceCode" id="cb145"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb145-1"><a href="#cb145-1" tabindex="-1"></a>x <span class="ot"><-</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">5</span> <span class="sc">%>%</span> dist <span class="sc">%>%</span> hclust <span class="sc">%>%</span> as.dendrogram</span>
|
|||
|
<span id="cb145-2"><a href="#cb145-2" tabindex="-1"></a>y <span class="ot"><-</span> <span class="fu">set</span>(x, <span class="st">"labels"</span>, <span class="dv">5</span><span class="sc">:</span><span class="dv">1</span>)</span>
|
|||
|
<span id="cb145-3"><a href="#cb145-3" tabindex="-1"></a></span>
|
|||
|
<span id="cb145-4"><a href="#cb145-4" tabindex="-1"></a><span class="fu">dist.dendlist</span>(<span class="fu">dendlist</span>(<span class="at">x1 =</span> x,<span class="at">x2 =</span> x,<span class="at">y1 =</span> y))</span></code></pre></div>
|
|||
|
<pre><code>#> x1 x2
|
|||
|
#> x2 0
|
|||
|
#> y1 4 4</code></pre>
|
|||
|
<div class="sourceCode" id="cb147"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb147-1"><a href="#cb147-1" tabindex="-1"></a><span class="fu">dend_diff</span>(x,y)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCCAYAAAB8GMlFAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUq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OOOi6uvvnrXTf4kQKAPCvjUaB8cqi0RIECAwPsX8Izw/Vt5ZGYCd999d2Y7tl0C6Qgcfvjh8fbbb1fSkGeElTArQoAAAQKpCgjCVCejLwIECBCoREAQVsKsCAECBAikKiAIU52MvggQIECgEgFBWAmzIgQIECCQqoAgTHUy+iJAgACBSgQEYSXMihAgQIBAqgKCMNXJ6IsAAQIEKhEQhJUwK0KAAAECqQoIwlQnoy8CBAgQqERAEFbCrAgBAgQIpCogCFOdjL4IECBAoBIBQVgJsyIECBAgkKqAIEx1MvoiQIAAgUoEBGElzIoQIECAQKoCgjDVyeiLAAECBCoREISVMCtCgAABAqkKCMJUJ6MvAgQIEKhEQBBWwqwIAQIECKQqIAhTnYy+CBAgQKASAUFYCbMiBAgQIJCqgCBMdTL6IkCAAIFKBPpXUkWRJAX+dtWP44DRh1fe27NLfhOrD6i8rIIEkhOYMmVKHHfccZX3tWLFihgxY
|
|||
|
<div class="sourceCode" id="cb148"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb148-1"><a href="#cb148-1" tabindex="-1"></a><span class="fu">dist.dendlist</span>(dend1234)</span></code></pre></div>
|
|||
|
<pre><code>#> Complete Single Average
|
|||
|
#> Single 6
|
|||
|
#> Average 2 4
|
|||
|
#> Centroid 4 2 2</code></pre>
|
|||
|
<p>This function might implement other topological distances in the
|
|||
|
future.</p>
|
|||
|
</div>
|
|||
|
<div id="correlation-matrix-using-cor.dendlist" class="section level4">
|
|||
|
<h4>Correlation matrix using cor.dendlist</h4>
|
|||
|
<p>Both Baker’s Gamma and cophenetic correlation (Which will be
|
|||
|
introduced shortly), can be calculated to create a correlation matrix
|
|||
|
using the <code>cor.dendlist</code> function (the default method is
|
|||
|
cophenetic correlation):</p>
|
|||
|
<div class="sourceCode" id="cb150"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb150-1"><a href="#cb150-1" tabindex="-1"></a><span class="fu">cor.dendlist</span>(dend1234)</span></code></pre></div>
|
|||
|
<pre><code>#> Complete Single Average Centroid
|
|||
|
#> Complete 1.0000000 0.4272001 0.5635291 0.4466374
|
|||
|
#> Single 0.4272001 1.0000000 0.9508998 0.9910913
|
|||
|
#> Average 0.5635291 0.9508998 1.0000000 0.9556376
|
|||
|
#> Centroid 0.4466374 0.9910913 0.9556376 1.0000000</code></pre>
|
|||
|
<p>The corrplot library offers a nice visualization:</p>
|
|||
|
<div class="sourceCode" id="cb152"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb152-1"><a href="#cb152-1" tabindex="-1"></a><span class="fu">library</span>(corrplot)</span>
|
|||
|
<span id="cb152-2"><a href="#cb152-2" tabindex="-1"></a><span class="fu">corrplot</span>(<span class="fu">cor.dendlist</span>(dend1234), <span class="st">"pie"</span>, <span class="st">"lower"</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCCAYAAAB8GMlFAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7E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OKLEa1Lqs7d0EeNQ7iR+9CHDjAjSlw15gAE2ACFRPgGWHFfIx999+NQH1ShFNuL6UEtU4JbdtAnDGNLEkXGruPLD0TYAJMoIoEWBFWEaCei6tnzkKIiS5fxFYtgPjj5d/nO0yACTABDyDAitCNB1no0Q3qyn+g5ueX2Ut1yTJoe
|
|||
|
<p>Which easily tells us that single, average and centroid give similar
|
|||
|
results, while complete is somewhat different.</p>
|
|||
|
<div class="sourceCode" id="cb153"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb153-1"><a href="#cb153-1" tabindex="-1"></a><span class="co"># same subtrees, so there is no need to color the branches</span></span>
|
|||
|
<span id="cb153-2"><a href="#cb153-2" tabindex="-1"></a>dend1234 <span class="sc">%>%</span> <span class="fu">tanglegram</span>(<span class="at">which =</span> <span class="fu">c</span>(<span class="dv">2</span>,<span class="dv">3</span>)) </span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXcAAADhCAYAAAAziPUUAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69y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+r6d7uk+fPv3v7urqOnX+VSZgRFQUAUVAEVAEfIVAWV+djZ6MIqAIKAKKgEVAlbveCIqAIqAI+BABVe4+vKh6SoqAIqAIqHLXe0ARUAQUAR8ioMrdhxdVT0kRUAQUAVXueg8oAoqAIuBDBFS5+/Ci6ikpAoqAIqDKXe8BRUARUAR8iEBWKveHH35YjjzySKlXr57sscce0rVrV7nrrrtk8+bNwUuwePFi2Weffey0cuXK4PpkLqTjGMlsr9alCOQSAscee6x9fnv16iU7d+7MpabnRFvLZNsI1UsvvVRGjhwZFryjjjpKPvzwQylbtqzMnj1bOnToYMuhhJs3bx52n0RWpuMYibRP91UEchWBL774QlDqTt58800ZMGCA+6vzJCCQVZb76tWr5amnnrKnde+998qKFSvk119/lWuvvdau++STT2T8+PF2uVmzZvLee+/ZqX79+kmAQqtQBBSBdCHw5JNPFjnUE088UeS//kkcgfKJV5G8Gn755RfZtWuXrfDoo4+Whg0b2mVcMmvWrJGKFStKhQoV7DpcNB988IFdPuigg6Ry5cr2P8qf//vtt5/9ApgxY4Z06dJFrr/+eqlTp44tz8/atWtlxIgRMmXKFOnYsaMMGTJExowZI/Pnz5dzzjlH9t1332DZ0IVJkybJs88+K/PmzZM999xTzj77bHu80HL6XxFQBIojsH79ehk9erTdcPnll8t//vMfef/992XRokXSsmVLux5D7t1335UaNWrIsGHDgpXw3N5xxx32/9/+9jfByENefvllWwd6Ye+995Yrr7xSatWqZbfxTOPqxc17wgknyN133y1NmjSRG264weqYn376yRqVCxcutPugD3im27RpY/fnJ1Z9sWHDBnnwwQdl4sSJVt/gXkafZERwy2SLmIseMD52iMwClSpVCpx22mmBZ555JmCs92JNnDVrli1HWeOWsdvNTWDXHXDAAYG6desGt1OmU6dOgT///NOWM18IgRYtWhTZbi52oFWrVnbdiy++aMuFO8Zrr70WMC+ZIvuaF07ghRdeKNZGXaEIKALFEXj00Uft82O+uANbt24NGCPO/v/HP/4RLDxz5szgM/bzzz8H17t9zUsg+Dwb5Rksy7POxHaj1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ergnGfVK668W2f69cR8kdsAijvvvFOOOeYYOfHEE+Xbb78NKvlY9IW3Xjp62ccrrnPXuy7Vy0W1XqqPFqV+ADEdLGJ84PKvf/0r+CZECb/11lt272hWe5RD2M19+/a1c3rjTceN/SLgBoomDJpCuEnbtWsn5513npx00kk2Soee/nDWfLQ6dbsik
|
|||
|
<div class="sourceCode" id="cb154"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb154-1"><a href="#cb154-1" tabindex="-1"></a><span class="co"># Here the branches colors are very helpful:</span></span>
|
|||
|
<span id="cb154-2"><a href="#cb154-2" tabindex="-1"></a>dend1234 <span class="sc">%>%</span> <span class="fu">tanglegram</span>(<span class="at">which =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">2</span>), </span>
|
|||
|
<span id="cb154-3"><a href="#cb154-3" tabindex="-1"></a> <span class="at">common_subtrees_color_branches =</span> <span class="cn">TRUE</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXcAAADhCAYAAAAziPUUAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUx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qo4dOwqOQEZExmEB9jeFeFEmdhUZwG/TyilVV48CVsuo5aZ2YCcEwZCryADFpsZvBMTePqaaxkm5xQyqELYwVN6+fZtYx0WdO3cOc4G86iVetYobCYMoHgYKwWKuCPQ3b94IIwrOsRpEqSI+4QerkGIsgdElMsRqG2GERd3g4GDRBA8j1scLI4xuH7p9wlBauHBh3dMGxhR+eqvnlbZ40MCAqzzwlAowyEiSH
|
|||
|
</div>
|
|||
|
<div id="bakers-gamma-index" class="section level4">
|
|||
|
<h4>Baker’s Gamma Index</h4>
|
|||
|
<p>Baker’s Gamma Index (see baker’s paper from 1974) is a measure of
|
|||
|
association (similarity) between two trees of Hierarchical clustering
|
|||
|
(dendrograms). It is defined as the rank correlation between the stages
|
|||
|
at which pairs of objects combine in each of the two trees.</p>
|
|||
|
<p>Or more detailed: It is calculated by taking two items, and see what
|
|||
|
is the highest possible level of k (number of cluster groups created
|
|||
|
when cutting the tree) for which the two item still belongs to the same
|
|||
|
tree. That k is returned, and the same is done for these two items for
|
|||
|
the second tree. There are n over 2 combinations of such pairs of items
|
|||
|
from the items in the tree, and all of these numbers are calculated for
|
|||
|
each of the two trees. Then, these two sets of numbers (a set for the
|
|||
|
items in each tree) are paired according to the pairs of items compared,
|
|||
|
and a Spearman correlation is calculated.</p>
|
|||
|
<p>The value can range between -1 to 1. With near 0 values meaning that
|
|||
|
the two trees are not statistically similar. For exact p-value one
|
|||
|
should use a permutation test. One such option will be to permute over
|
|||
|
the labels of one tree many times, calculating the distribution under
|
|||
|
the null hypothesis (keeping the trees topologies constant).</p>
|
|||
|
<p>Notice that this measure is not affected by the height of a branch
|
|||
|
but only of its relative position compared with other branches.</p>
|
|||
|
<div class="sourceCode" id="cb155"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb155-1"><a href="#cb155-1" tabindex="-1"></a><span class="fu">cor_bakers_gamma</span>(dend15, dend51)</span></code></pre></div>
|
|||
|
<pre><code>#> [1] 0.2751938</code></pre>
|
|||
|
<p>Even that we can reach perfect entanglement, Baker’s gamma shows us
|
|||
|
that the tree’s topology is not identical. As opposed with the
|
|||
|
correlation of a tree with itself:</p>
|
|||
|
<div class="sourceCode" id="cb157"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb157-1"><a href="#cb157-1" tabindex="-1"></a><span class="fu">cor_bakers_gamma</span>(dend15, dend15)</span></code></pre></div>
|
|||
|
<pre><code>#> [1] 1</code></pre>
|
|||
|
<p>Since the observations creating the Baker’s Gamma Index of such a
|
|||
|
measure are correlated, we need to perform a permutation test for the
|
|||
|
calculation of the statistical significance of the index. Let’s look at
|
|||
|
the distribution of Baker’s Gamma Index under the null hypothesis
|
|||
|
(assuming fixed tree topologies). This will be different for different
|
|||
|
tree structures and sizes. Here are the results when the compared tree
|
|||
|
is itself (after shuffling its own labels), and when comparing tree 1 to
|
|||
|
the shuffled tree 2:</p>
|
|||
|
<div class="sourceCode" id="cb159"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb159-1"><a href="#cb159-1" tabindex="-1"></a><span class="fu">set.seed</span>(<span class="dv">23235</span>)</span>
|
|||
|
<span id="cb159-2"><a href="#cb159-2" tabindex="-1"></a>the_cor <span class="ot"><-</span> <span class="fu">cor_bakers_gamma</span>(dend15, dend15)</span>
|
|||
|
<span id="cb159-3"><a href="#cb159-3" tabindex="-1"></a>the_cor2 <span class="ot"><-</span> <span class="fu">cor_bakers_gamma</span>(dend15, dend51)</span>
|
|||
|
<span id="cb159-4"><a href="#cb159-4" tabindex="-1"></a>the_cor</span></code></pre></div>
|
|||
|
<pre><code>#> [1] 1</code></pre>
|
|||
|
<div class="sourceCode" id="cb161"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb161-1"><a href="#cb161-1" tabindex="-1"></a>the_cor2</span></code></pre></div>
|
|||
|
<pre><code>#> [1] 0.2751938</code></pre>
|
|||
|
<div class="sourceCode" id="cb163"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb163-1"><a href="#cb163-1" tabindex="-1"></a>R <span class="ot"><-</span> <span class="dv">100</span></span>
|
|||
|
<span id="cb163-2"><a href="#cb163-2" tabindex="-1"></a>cor_bakers_gamma_results <span class="ot"><-</span> <span class="fu">numeric</span>(R)</span>
|
|||
|
<span id="cb163-3"><a href="#cb163-3" tabindex="-1"></a>dend_mixed <span class="ot"><-</span> dend15</span>
|
|||
|
<span id="cb163-4"><a href="#cb163-4" tabindex="-1"></a><span class="cf">for</span>(i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span>R) {</span>
|
|||
|
<span id="cb163-5"><a href="#cb163-5" tabindex="-1"></a> dend_mixed <span class="ot"><-</span> <span class="fu">sample.dendrogram</span>(dend_mixed, <span class="at">replace =</span> <span class="cn">FALSE</span>)</span>
|
|||
|
<span id="cb163-6"><a href="#cb163-6" tabindex="-1"></a> cor_bakers_gamma_results[i] <span class="ot"><-</span> <span class="fu">cor_bakers_gamma</span>(dend15, dend_mixed)</span>
|
|||
|
<span id="cb163-7"><a href="#cb163-7" tabindex="-1"></a>}</span>
|
|||
|
<span id="cb163-8"><a href="#cb163-8" tabindex="-1"></a><span class="fu">plot</span>(<span class="fu">density</span>(cor_bakers_gamma_results),</span>
|
|||
|
<span id="cb163-9"><a href="#cb163-9" tabindex="-1"></a> <span class="at">main =</span> <span class="st">"Baker's gamma distribution under H0"</span>,</span>
|
|||
|
<span id="cb163-10"><a href="#cb163-10" tabindex="-1"></a> <span class="at">xlim =</span> <span class="fu">c</span>(<span class="sc">-</span><span class="dv">1</span>,<span class="dv">1</span>))</span>
|
|||
|
<span id="cb163-11"><a href="#cb163-11" tabindex="-1"></a><span class="fu">abline</span>(<span class="at">v =</span> <span class="dv">0</span>, <span class="at">lty =</span> <span class="dv">2</span>)</span>
|
|||
|
<span id="cb163-12"><a href="#cb163-12" tabindex="-1"></a><span class="fu">abline</span>(<span class="at">v =</span> the_cor, <span class="at">lty =</span> <span class="dv">2</span>, <span class="at">col =</span> <span class="dv">2</span>)</span>
|
|||
|
<span id="cb163-13"><a href="#cb163-13" tabindex="-1"></a><span class="fu">abline</span>(<span class="at">v =</span> the_cor2, <span class="at">lty =</span> <span class="dv">2</span>, <span class="at">col =</span> <span class="dv">4</span>)</span>
|
|||
|
<span id="cb163-14"><a href="#cb163-14" tabindex="-1"></a><span class="fu">legend</span>(<span class="st">"topleft"</span>, <span class="at">legend =</span> <span class="fu">c</span>(<span class="st">"cor"</span>, <span class="st">"cor2"</span>), <span class="at">fill =</span> <span class="fu">c</span>(<span class="dv">2</span>,<span class="dv">4</span>))</span>
|
|||
|
<span id="cb163-15"><a href="#cb163-15" tabindex="-1"></a><span class="fu">round</span>(<span class="fu">sum</span>(the_cor2 <span class="sc"><</span> cor_bakers_gamma_results)<span class="sc">/</span> R, <span class="dv">4</span>)</span></code></pre></div>
|
|||
|
<pre><code>#> [1] 0.17</code></pre>
|
|||
|
<div class="sourceCode" id="cb165"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb165-1"><a href="#cb165-1" tabindex="-1"></a><span class="fu">title</span>(<span class="at">sub =</span> <span class="fu">paste</span>(<span class="st">"One sided p-value:"</span>,</span>
|
|||
|
<span id="cb165-2"><a href="#cb165-2" tabindex="-1"></a> <span class="st">"cor ="</span>, <span class="fu">round</span>(<span class="fu">sum</span>(the_cor <span class="sc"><</span> cor_bakers_gamma_results)<span class="sc">/</span> R, <span class="dv">4</span>),</span>
|
|||
|
<span id="cb165-3"><a href="#cb165-3" tabindex="-1"></a> <span class="st">" ; cor2 ="</span>, <span class="fu">round</span>(<span class="fu">sum</span>(the_cor2 <span class="sc"><</span> cor_bakers_gamma_results)<span class="sc">/</span> R, <span class="dv">4</span>)</span>
|
|||
|
<span id="cb165-4"><a href="#cb165-4" tabindex="-1"></a> ))</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCCAYAAAB8GMlFAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaS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fdNTF6jCqe8QN3GQ87l/FgU3EM5eSOg7zwOXr0qKtTp07qe/PmzV2GUlRxjAenOnfJJZe4jKEYlzEfoY6/+eYbdd2Ys1DHhhJ2GUNsLsT78ssvXefOnXOdOXNGxUFexgPbZSgd14MPPugyHtAuY6jPZQzpqnLdwqT7cuDAAVfhwoVV3lWqVHEZD1qVN2S97LLLVMzs6nf48GGV3phDdRmKxmU8PF3GS4I6ZzzgXcbLg8t4AKpjyG487FW+qD/KQV3atWvnMpSIOw1YdujQQXFFnLffftsvWdJVzf31448/VvkinxYtWrgM5eoyhivVuccff1zF69evnzoePHiwOjYUlDquX7++C3GMh7k6NpSoum4oFRfqa3J66qmnXEbPTB3HxcW5jIemC3W48847Xcawmjpft25dldaMh7Ron5YtW6p2w3H58uXd9wTuPZzbv3+/Soc/BQsWVOd2797t+uSTT1RbI46htFy1a9dW8TLXxejJuIwXE5UO+eP+QBq0za5du1Qa4wVKnYPM4NOtWzd1HfEeeughFcfTn+xkRBrkiXpCBuMF0HXFFVeosgyF7Lpw4YLK1p82CvY3kllu87eN9hs0aFCGj2EDoGQzXixUMpPlf//7X3c2JkvjRdd9j
|
|||
|
<p>We can see that we do not have enough evidence that dend15 and dend51
|
|||
|
are significantly “similar” (i.e.: with a correlation larger than
|
|||
|
0).</p>
|
|||
|
<p>We can also build a bootstrap confidence interval, using
|
|||
|
<code>sample.dendrogram</code>, for the correlation. This function can
|
|||
|
be very slow for larger trees, so make sure you use if carefully:</p>
|
|||
|
<div class="sourceCode" id="cb166"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb166-1"><a href="#cb166-1" tabindex="-1"></a>dend1 <span class="ot"><-</span> dend15</span>
|
|||
|
<span id="cb166-2"><a href="#cb166-2" tabindex="-1"></a>dend2 <span class="ot"><-</span> dend51</span>
|
|||
|
<span id="cb166-3"><a href="#cb166-3" tabindex="-1"></a></span>
|
|||
|
<span id="cb166-4"><a href="#cb166-4" tabindex="-1"></a><span class="fu">set.seed</span>(<span class="dv">23801</span>)</span>
|
|||
|
<span id="cb166-5"><a href="#cb166-5" tabindex="-1"></a></span>
|
|||
|
<span id="cb166-6"><a href="#cb166-6" tabindex="-1"></a>R <span class="ot"><-</span> <span class="dv">100</span></span>
|
|||
|
<span id="cb166-7"><a href="#cb166-7" tabindex="-1"></a>dend1_labels <span class="ot"><-</span> <span class="fu">labels</span>(dend1)</span>
|
|||
|
<span id="cb166-8"><a href="#cb166-8" tabindex="-1"></a>dend2_labels <span class="ot"><-</span> <span class="fu">labels</span>(dend2)</span>
|
|||
|
<span id="cb166-9"><a href="#cb166-9" tabindex="-1"></a>cor_bakers_gamma_results <span class="ot"><-</span> <span class="fu">numeric</span>(R)</span>
|
|||
|
<span id="cb166-10"><a href="#cb166-10" tabindex="-1"></a><span class="cf">for</span>(i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span>R) {</span>
|
|||
|
<span id="cb166-11"><a href="#cb166-11" tabindex="-1"></a> sampled_labels <span class="ot"><-</span> <span class="fu">sample</span>(dend1_labels, <span class="at">replace =</span> <span class="cn">TRUE</span>)</span>
|
|||
|
<span id="cb166-12"><a href="#cb166-12" tabindex="-1"></a> <span class="co"># members needs to be fixed since it will be later used in nleaves</span></span>
|
|||
|
<span id="cb166-13"><a href="#cb166-13" tabindex="-1"></a> dend_mixed1 <span class="ot"><-</span> <span class="fu">sample.dendrogram</span>(dend1, </span>
|
|||
|
<span id="cb166-14"><a href="#cb166-14" tabindex="-1"></a> <span class="at">dend_labels=</span>dend1_labels,</span>
|
|||
|
<span id="cb166-15"><a href="#cb166-15" tabindex="-1"></a> <span class="at">fix_members=</span><span class="cn">TRUE</span>,<span class="at">fix_order=</span><span class="cn">TRUE</span>,<span class="at">fix_midpoint=</span><span class="cn">FALSE</span>,</span>
|
|||
|
<span id="cb166-16"><a href="#cb166-16" tabindex="-1"></a> <span class="at">replace =</span> <span class="cn">TRUE</span>, <span class="at">sampled_labels=</span>sampled_labels</span>
|
|||
|
<span id="cb166-17"><a href="#cb166-17" tabindex="-1"></a> )</span>
|
|||
|
<span id="cb166-18"><a href="#cb166-18" tabindex="-1"></a> dend_mixed2 <span class="ot"><-</span> <span class="fu">sample.dendrogram</span>(dend2, <span class="at">dend_labels=</span>dend2_labels,</span>
|
|||
|
<span id="cb166-19"><a href="#cb166-19" tabindex="-1"></a> <span class="at">fix_members=</span><span class="cn">TRUE</span>,<span class="at">fix_order=</span><span class="cn">TRUE</span>,<span class="at">fix_midpoint=</span><span class="cn">FALSE</span>,</span>
|
|||
|
<span id="cb166-20"><a href="#cb166-20" tabindex="-1"></a> <span class="at">replace =</span> <span class="cn">TRUE</span>, <span class="at">sampled_labels=</span>sampled_labels</span>
|
|||
|
<span id="cb166-21"><a href="#cb166-21" tabindex="-1"></a> ) </span>
|
|||
|
<span id="cb166-22"><a href="#cb166-22" tabindex="-1"></a> cor_bakers_gamma_results[i] <span class="ot"><-</span> <span class="fu">cor_bakers_gamma</span>(dend_mixed1, dend_mixed2, <span class="at">warn =</span> <span class="cn">FALSE</span>)</span>
|
|||
|
<span id="cb166-23"><a href="#cb166-23" tabindex="-1"></a>}</span>
|
|||
|
<span id="cb166-24"><a href="#cb166-24" tabindex="-1"></a></span>
|
|||
|
<span id="cb166-25"><a href="#cb166-25" tabindex="-1"></a></span>
|
|||
|
<span id="cb166-26"><a href="#cb166-26" tabindex="-1"></a><span class="co"># here is the tanglegram</span></span>
|
|||
|
<span id="cb166-27"><a href="#cb166-27" tabindex="-1"></a><span class="fu">tanglegram</span>(dend1, dend2)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCCAYAAAB8GMlFAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O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j1VvXCvhQX8lMgRqN5zSE5s26sq7HLWMEkpyI5c5ayJBMJIgIYwjDBZVOQJnHHGGUalO3bs0EbpXMN0xkFuWEbg0L8WGWVzWNRAwY0YJEBDGIOdxiafJgBvNt26uSZonDhxQvbv33/6JLcsJVD6icuLUIeEeMmZzNmilsJm4ZYSoCG0FC8LjwQB81shl1JEgrjIsVWbpWbvYVVZzpSxktgpPTIVsxYSsIAADaEFUFlkZAl06dJF8vLyVKWVlZVy6NChyDbAgbUVzzvtUo3Dog68AGymMg2hzTrUqer069fPUJ1vhQYKSzaatdm5Rz5drsqOT0uRrLOHW1IPCyWBSBGgIYwUadZjKYGcnBzJzMxUdZSXl8uRI0csrc/JhZd9sVrqyyoUgvyLz5b4ZAaMdfL1YAfdaQjt0IvUQREYMGCAQQIhmijWECie94VRcB4X0RssuBG7BGgIY7fv2HI3Avn5+ZKe7pq0UVpaKggUTAkvgca6ein7fJUqNDGrs2SOHBjeClgaCbQDARrCdoDOKq0hAC8zfCu0hq1eaunHy6Sxulbtdr303
|
|||
|
<div class="sourceCode" id="cb167"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb167-1"><a href="#cb167-1" tabindex="-1"></a><span class="co"># And here is the tanglegram for one sample of our trees:</span></span>
|
|||
|
<span id="cb167-2"><a href="#cb167-2" tabindex="-1"></a>dend_mixed1 <span class="ot"><-</span> <span class="fu">rank_order.dendrogram</span>(dend_mixed1)</span>
|
|||
|
<span id="cb167-3"><a href="#cb167-3" tabindex="-1"></a>dend_mixed2 <span class="ot"><-</span> <span class="fu">rank_order.dendrogram</span>(dend_mixed2)</span>
|
|||
|
<span id="cb167-4"><a href="#cb167-4" tabindex="-1"></a>dend_mixed1 <span class="ot"><-</span> <span class="fu">fix_members_attr.dendrogram</span>(dend_mixed1)</span>
|
|||
|
<span id="cb167-5"><a href="#cb167-5" tabindex="-1"></a>dend_mixed2 <span class="ot"><-</span> <span class="fu">fix_members_attr.dendrogram</span>(dend_mixed2)</span>
|
|||
|
<span id="cb167-6"><a href="#cb167-6" tabindex="-1"></a><span class="fu">tanglegram</span>(dend_mixed1, dend_mixed2)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCCAYAAAB8GMlFAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBgE0SQIA9pfFtgo6cKGuhooeilaKH41eDs38Ip+f4At1Rq/sjr6NEwQqb/I/DQqsLvaFUjvAx+eWirddAJZnAj1DFJL0mSg/gcIpPkMBkhoyCSJ8lTZIxk0TpKDjXHliJzZPO50dR5ASNSnzeLvIvod0HG/mdkmOC0z8VKnzcQ2M/Yz2vKldduXjp9bleLu0ZWn7vWc+l0JGcaai10yNrUnXLP/8Jf59ewX+c3Wgz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1gSQCG09/AgeBEAABEAAiRDvARAAARAAAVsTQCK09fAjeBAAARAAASRCvAdAAARAAARsTQCJ0NbDj+BBAARAAASQCPEeAAEQAAEQsDUBJEJbDz+CBwEQAAEQQCLEewAEQAAEQMDWBJAIbT38CB4EQAAEQACJEO8BEAABEAABWxNAIrT18CN4EAABEAABJEK8B0AABEAABGxNAInQ1sOP4EEABEAABJAI8R4AARAAARCwNQEkQlsPP4IHARAAARBAIsR7AARAAARAwNYEkAhtPfwIHgRAAARAAIkQ7wEQAAFTEMjNzaU///zTFL7CSXMRQCI013gZ3tsjR47QkiVL5L8ffvihXn83b95Mn3zyCR09erTec3AABFwEdu3aReeddx4tX77ctQs/QUA1AkiEqqGEIiawcuVK+WFVWFhIxcXFdUL5/vvv6fnnn6eIiAi68MILqbq6us7zsBMEXASWLVtGU6ZMcb3ETxBQlUCgqtpMoCwvL49CQkJM4KnxXQwNDSV/f8+/pdatW0dDhw6luLg4Gj16dJ1B8LFnn32W2rZtS8899xzxmERHR9d5bl07V19yD6U8eTOF9+5S12Hs8xGBol0HaOPdL9Kgj59R3YNp06YRP2E4cOBAnbqrqqqopKSkzmNm31lZWSk/s4KDg80eimH9t1Ui3Lt3L51wwgnyn2FHxESOzZkzhwYNGlTLY74b3LFjB1111VX0/vvv1zrer18/uW/BggWUkpLSrCTIF5ZlH6ZN982jkz94ggJC8OFQC7CPdux68zM5Nr4wz98dzpw50xemNbe5f/9+Gjt2LL3wwgua27KrAVslwvDwcBo8eDAtXbrUruOtedy33347tWnTRtpZvHgx8V/qNe8a+eCLL75IO3fulD9b4lTRjn20/flFlDhzcksuxzUqE6gqr6CcH/8mvwDPJwQqm6lXHf9B9t1339V73MwH+A/GgIAAM4dgeN998641PBY42FIC/Ff5t99+S2vWrKF27drVmQQ/+OAD+umnn+iaa66htWvXUmlpabPMBbQOk+fv/2g55axa16xrcbI2BLK+X0MVBYXaKHdq7datG5166qma2oByexJAIrTnuGsWNT8u3bZtG/3zzz/Ed4T1yfHHH0+ff/65/NfcmaM9b7tcUZv26GtUlpuvvMaGbwhkfP2L5oY5EQ4fPlxzOzBgPwK2ejRqv+HVP2J+LDp9+nTFMM/24+843GXSpEleTViKO+sUyh77J/GHb1nOEUqbNZ+O//fd7iawrSOBisJiyv3FcWce1ileR8swBQLqEEAiVIcjtNRDgO/8evXq5XE0KCjI43VLXvSeeR0dXptGpYdyKOenv2nfh8uo08QxLVGFa7wkwH+QVFdUSi2xo2pPnvJSPS4HAc0JIBFqjtjeBtq3b68JgKCI1pQyewatnfo4iYWItP3FDyh68HHUqlsHTexBaf0E3B+Ltjt9QP0n4ggIGJQAviM06MDArcYJRA1Ipq6Tz5MnVpWU0aaZ84hnL0L0I1AqlrIcWbtFGozo2xN/iOiHHpZUJIBEqCJMqNKfQLdpF1FEcndp+GjaLtrxUv0TdPT3zvoWD33xk7wj50jjxw6zfsCI0JIEkAgtOaz2Cco/KJBS5txC/qGOhfV731tKeX9utg8AH0fq/lg09kx8P+jj4YD5FhJAImwhOFxmHAKturan3vdc63BIfF+Y+uDLVK7xmjbjRO87T4p2H6TCrXukA21POY5CE2J85wwsg4AXBJAIvYCHS41DoMMFI6jdGY6JGqUZubTl8TeM45xFPTn4vx+UyPBYVEGBDRMSQCI04aDB5boJ9Hn4BgqOcZR3y1r+O7l/UNd9BfZ6QyDru9Xycr/AAOWPEG/04VoQ8BUBJEJfkYdd1QkEt42kpMduUvRufeYdKt6fqbzGhnoEeA1n8Z5DUmG7EQMpKDJcPeXQBAI6E0Ai1Bk4zGlLIGZof+p85ThppLKohDY/8BJVV1Zpa9SG2
|
|||
|
<div class="sourceCode" id="cb168"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb168-1"><a href="#cb168-1" tabindex="-1"></a><span class="fu">cor_bakers_gamma</span>(dend_mixed1, dend_mixed2, <span class="at">warn =</span> <span class="cn">FALSE</span>)</span></code></pre></div>
|
|||
|
<pre><code>#> [1] 1</code></pre>
|
|||
|
<div class="sourceCode" id="cb170"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb170-1"><a href="#cb170-1" tabindex="-1"></a>CI95 <span class="ot"><-</span> <span class="fu">quantile</span>(cor_bakers_gamma_results, <span class="at">probs=</span><span class="fu">c</span>(.<span class="dv">025</span>,.<span class="dv">975</span>))</span>
|
|||
|
<span id="cb170-2"><a href="#cb170-2" tabindex="-1"></a>CI95</span></code></pre></div>
|
|||
|
<pre><code>#> 2.5% 97.5%
|
|||
|
#> 0.2751938 1.0000000</code></pre>
|
|||
|
<div class="sourceCode" id="cb172"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb172-1"><a href="#cb172-1" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">1</span>))</span>
|
|||
|
<span id="cb172-2"><a href="#cb172-2" tabindex="-1"></a><span class="fu">plot</span>(<span class="fu">density</span>(cor_bakers_gamma_results),</span>
|
|||
|
<span id="cb172-3"><a href="#cb172-3" tabindex="-1"></a> <span class="at">main =</span> <span class="st">"Baker's gamma bootstrap distribution"</span>,</span>
|
|||
|
<span id="cb172-4"><a href="#cb172-4" tabindex="-1"></a> <span class="at">xlim =</span> <span class="fu">c</span>(<span class="sc">-</span><span class="dv">1</span>,<span class="dv">1</span>))</span>
|
|||
|
<span id="cb172-5"><a href="#cb172-5" tabindex="-1"></a><span class="fu">abline</span>(<span class="at">v =</span> CI95, <span class="at">lty =</span> <span class="dv">2</span>, <span class="at">col =</span> <span class="dv">3</span>)</span>
|
|||
|
<span id="cb172-6"><a href="#cb172-6" tabindex="-1"></a><span class="fu">abline</span>(<span class="at">v =</span> <span class="fu">cor_bakers_gamma</span>(dend1, dend2), <span class="at">lty =</span> <span class="dv">2</span>, <span class="at">col =</span> <span class="dv">2</span>)</span>
|
|||
|
<span id="cb172-7"><a href="#cb172-7" tabindex="-1"></a><span class="fu">legend</span>(<span class="st">"topleft"</span>, <span class="at">legend =</span><span class="fu">c</span>(<span class="st">"95% CI"</span>, <span class="st">"Baker's Gamma Index"</span>), <span class="at">fill =</span> <span class="fu">c</span>(<span class="dv">3</span>,<span class="dv">2</span>))</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCCAYAAAB8GMlFAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel0L9Xy23FMYlPYZenAx0yDB1/PX6dledmQjikjkXCxqMJS9WtfFCyH9XtSekEF+2dH+P4tzITduTygGfv58a5VCTH5PtXD7EFZiNyUDBhHnsFTBgE0SQIA9pfFtgo6cKGuhooeilaKH41eDs38Ip+f4At1Rq/sjr6NEwQqb/I/DQqsLvaFUjvAx+eWirddAJZnAj1DFJL0mSg/gcIpPkMBkhoyCSJ8lTZIxk0TpKDjXHliJzZPO50dR5ASNSnzeLvIvod0HG/mdkmOC0z8VKnzcQ2M/Yz2vKldduXjp9bleLu0ZWn7vWc+l0JGcaai10yNrUnXLP/8Jf59ewX+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8OwvXbPffco68ZP36895oHHnhAx+E+xgftQoBp1DTr4v8IfF999VXvdfi/vP3227X2aP7vTJ8+3Xt+/vz5+pqhQ4fKiy++qO/natWqycUXXyxbt271puNBlAQMBtsT+OqrrwzVnYZ6cBnqH8u4//77DfUPYKh/JB0/aNAgbxuUxqjTqX8eQz0kDPWw1WmUcPKmQV74/PHHH0aPHj30cadOnQz1z6fTqIedjqtUqZJx7rnnGpUrV9a///Of/+jz6h9d/1ZC2FAmJAPppk6dauzdu9fYtWuXToO81EPWUELHuOGGGwz1UDWU6cdQJl1drrcyPgdvvPGGzhd1Uw9dQ2kyOm/8vvPOO3XKSO1TD32dhxpDNdRD1FAPBkO9JOg49RA21MuDobQJ/Rt1VwJI54v2oxy0pVu3boZ6MHmvAUslVDRXpHnqqaeiqotP0/Sh0gR0nsgDLLp06aIZ4Xf9+vW9/BctWmQo4a3TIh4MkQb1X7t2rc4rUprNmzcbhx9+uL4O7VSC3/jiiy8M9SDXcW3atDHUg9ZQQkr/VsJG56uErwF2KK9hw4bGXXfdZZj19ng8hnrpMsDj0ksvNSL1BTJE2fjgXsH9qh7W3rz37Nmjy/T/8/rrr+s0qMNpp52m7wNlotRxqDMC2oLzStDq37FsFzLEvYP8laXF2378DtdvYII06qVQ1wl/rrjiCh2nXuQM3N9mX4LDMccco9Nde+21Os3jjz+uf4PL6aefruPATb2Q6mPkrYSlTqNeMnUc+gL/J7169dL3B9LceOONOg3/RE9Aok/KlMkiYApC3OT+n6pVqxo4bwalweh/RDwoENTbof7nxXUQVAhmHkrj0sd4KCqNQJ/DH/Of9fPPP9dxE
|
|||
|
<p>The bootstrap sampling can do weird things with small trees. In this
|
|||
|
case we had many times that the two trees got perfect correlation. The
|
|||
|
usage and interpretation should be done carefully!</p>
|
|||
|
</div>
|
|||
|
<div id="cophenetic-correlation" class="section level4">
|
|||
|
<h4>Cophenetic correlation</h4>
|
|||
|
<p>The cophenetic distance between two observations that have been
|
|||
|
clustered is defined to be the inter-group dissimilarity at which the
|
|||
|
two observations are first combined into a single cluster. This distance
|
|||
|
has many ties and restrictions. The cophenetic correlation (see sokal
|
|||
|
1962) is the correlation between two cophenetic distance matrices of two
|
|||
|
trees.</p>
|
|||
|
<p>The value can range between -1 to 1. With near 0 values meaning that
|
|||
|
the two trees are not statistically similar. For exact p-value one
|
|||
|
should result to a permutation test. One such option will be to permute
|
|||
|
over the labels of one tree many times, and calculating the distribution
|
|||
|
under the null hypothesis (keeping the trees topologies constant).</p>
|
|||
|
<div class="sourceCode" id="cb173"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb173-1"><a href="#cb173-1" tabindex="-1"></a><span class="fu">cor_cophenetic</span>(dend15, dend51)</span></code></pre></div>
|
|||
|
<pre><code>#> [1] 0.3125</code></pre>
|
|||
|
<p>The function <code>cor_cophenetic</code> is faster than
|
|||
|
<code>cor_bakers_gamma</code>, and might be preferred for that
|
|||
|
reason.</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div id="the-fowlkes-mallows-index-and-the-bk-plot" class="section level3">
|
|||
|
<h3>The Fowlkes-Mallows Index and the Bk plot</h3>
|
|||
|
<div id="the-fowlkes-mallows-index" class="section level4">
|
|||
|
<h4>The Fowlkes-Mallows Index</h4>
|
|||
|
<p>The Fowlkes-Mallows Index (see fowlkes 1983) (FM Index, or Bk) is a
|
|||
|
measure of similarity between two clusterings. The FM index ranges from
|
|||
|
0 to 1, a higher value indicates a greater similarity between the two
|
|||
|
clusters.</p>
|
|||
|
<p>The dendextend package allows the calculation of FM-Index, its
|
|||
|
expectancy and variance under the null hypothesis, and a creation of
|
|||
|
permutations of the FM-Index under H0. Thanks to the profdpm package, we
|
|||
|
have another example of calculating the FM (though it does not offer the
|
|||
|
expectancy and variance under H0):</p>
|
|||
|
<div class="sourceCode" id="cb175"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb175-1"><a href="#cb175-1" tabindex="-1"></a>hc1 <span class="ot"><-</span> <span class="fu">hclust</span>(<span class="fu">dist</span>(iris[,<span class="sc">-</span><span class="dv">5</span>]), <span class="st">"com"</span>)</span>
|
|||
|
<span id="cb175-2"><a href="#cb175-2" tabindex="-1"></a>hc2 <span class="ot"><-</span> <span class="fu">hclust</span>(<span class="fu">dist</span>(iris[,<span class="sc">-</span><span class="dv">5</span>]), <span class="st">"single"</span>)</span>
|
|||
|
<span id="cb175-3"><a href="#cb175-3" tabindex="-1"></a></span>
|
|||
|
<span id="cb175-4"><a href="#cb175-4" tabindex="-1"></a><span class="co"># FM index of a cluster with himself is 1:</span></span>
|
|||
|
<span id="cb175-5"><a href="#cb175-5" tabindex="-1"></a><span class="fu">FM_index</span>(<span class="fu">cutree</span>(hc1, <span class="at">k=</span><span class="dv">3</span>), <span class="fu">cutree</span>(hc1, <span class="at">k=</span><span class="dv">3</span>))</span></code></pre></div>
|
|||
|
<pre><code>#> [1] 1
|
|||
|
#> attr(,"E_FM")
|
|||
|
#> [1] 0.37217
|
|||
|
#> attr(,"V_FM")
|
|||
|
#> [1] 5.985372e-05</code></pre>
|
|||
|
<div class="sourceCode" id="cb177"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb177-1"><a href="#cb177-1" tabindex="-1"></a><span class="co"># FM index of two clusterings:</span></span>
|
|||
|
<span id="cb177-2"><a href="#cb177-2" tabindex="-1"></a><span class="fu">FM_index</span>(<span class="fu">cutree</span>(hc1, <span class="at">k=</span><span class="dv">3</span>), <span class="fu">cutree</span>(hc2, <span class="at">k=</span><span class="dv">3</span>)) </span></code></pre></div>
|
|||
|
<pre><code>#> [1] 0.8059522
|
|||
|
#> attr(,"E_FM")
|
|||
|
#> [1] 0.4462325
|
|||
|
#> attr(,"V_FM")
|
|||
|
#> [1] 6.464092e-05</code></pre>
|
|||
|
<div class="sourceCode" id="cb179"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb179-1"><a href="#cb179-1" tabindex="-1"></a><span class="co"># we got a value far above the expected under H0</span></span>
|
|||
|
<span id="cb179-2"><a href="#cb179-2" tabindex="-1"></a> </span>
|
|||
|
<span id="cb179-3"><a href="#cb179-3" tabindex="-1"></a><span class="co"># Using the R code:</span></span>
|
|||
|
<span id="cb179-4"><a href="#cb179-4" tabindex="-1"></a><span class="fu">FM_index_R</span>(<span class="fu">cutree</span>(hc1, <span class="at">k=</span><span class="dv">3</span>), <span class="fu">cutree</span>(hc2, <span class="at">k=</span><span class="dv">3</span>))</span></code></pre></div>
|
|||
|
<pre><code>#> [1] 0.8059522
|
|||
|
#> attr(,"E_FM")
|
|||
|
#> [1] 0.4462325
|
|||
|
#> attr(,"V_FM")
|
|||
|
#> [1] 6.464092e-05</code></pre>
|
|||
|
<p>The E_FM and V_FM are the values expected under the null hypothesis
|
|||
|
that the two trees have the same topology but one is a random shuffle of
|
|||
|
the labels of the other (i.e.: “no connection” between the trees).</p>
|
|||
|
<p>So for the values:</p>
|
|||
|
<div class="sourceCode" id="cb181"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb181-1"><a href="#cb181-1" tabindex="-1"></a><span class="fu">FM_index</span>(<span class="fu">cutree</span>(hc1, <span class="at">k=</span><span class="dv">3</span>), <span class="fu">cutree</span>(hc2, <span class="at">k=</span><span class="dv">3</span>)) </span></code></pre></div>
|
|||
|
<pre><code>#> [1] 0.8059522
|
|||
|
#> attr(,"E_FM")
|
|||
|
#> [1] 0.4462325
|
|||
|
#> attr(,"V_FM")
|
|||
|
#> [1] 6.464092e-05</code></pre>
|
|||
|
<p>We can take (under a normal asymptotic distribution)</p>
|
|||
|
<div class="sourceCode" id="cb183"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb183-1"><a href="#cb183-1" tabindex="-1"></a><span class="fl">0.4462</span> <span class="sc">+</span> <span class="fl">1.645</span> <span class="sc">*</span> <span class="fu">sqrt</span>(<span class="fl">6.464092e-05</span>)</span></code></pre></div>
|
|||
|
<pre><code>#> [1] 0.4594257</code></pre>
|
|||
|
<p>And since 0.8059 (our value) > 0.4594 (the critical value under
|
|||
|
H0, with alpha=5% for a one sided test) - then we can say that we
|
|||
|
significantly reject the hypothesis that the two trees are
|
|||
|
“not-similar”.</p>
|
|||
|
</div>
|
|||
|
<div id="the-bk-plot" class="section level4">
|
|||
|
<h4>The Bk plot</h4>
|
|||
|
<p>In the Bk method we calculate the FM Index (Bk) for each k
|
|||
|
(k=2,3,…,n-1) number of clusters, giving the association between the two
|
|||
|
trees when each is cut to have k groups. The similarity between two
|
|||
|
hierarchical clustering dendrograms, can be investigated, using the
|
|||
|
(k,Bk) plot: For every level of splitting of the two dendrograms which
|
|||
|
produces k clusters in each tree, the plot shows the number Bk, and
|
|||
|
therefore enables the investigation of potential nuances in the
|
|||
|
structure of similarity. The Bk measures the number of pairs of items
|
|||
|
which are in the same cluster in both dendrograms, one of the clusters
|
|||
|
in one of the trees and one of the clusters in the other tree, divided
|
|||
|
by the geometric mean of the number of pairs of items which are in the
|
|||
|
same cluster in each tree. Namely, <span class="math inline">\({a_{uv}}
|
|||
|
= 1\left( {or{\rm{ }}{{\rm{b}}_{uv}} = 1} \right)\)</span> if the items
|
|||
|
u and v are in the same cluster in the first tree (second tree), when it
|
|||
|
is cut so to give k clusters, and otherwise 0:</p>
|
|||
|
<p><span class="math display">\[{FM_k} = {B_k} =
|
|||
|
\frac{{\sum\limits_{}^{} {{a_{uv}}{b_{uv}}} }}{{\sqrt {\sum\limits_{}^{}
|
|||
|
{{a_{uv}}} \sum\limits_{}^{} {{b_{uv}}} } }}\]</span></p>
|
|||
|
<p>The Bk measure can be plotted for every value of k (except k=n) in
|
|||
|
order to create the “(k,Bk) plot”. The plot compares the similarity of
|
|||
|
the two trees for different cuts. The mean and variance of Bk, under the
|
|||
|
null hypothesis (that the two trees are not “similar”), and under the
|
|||
|
assumption that the margins of the matching matrix are fixed, are given
|
|||
|
in Fowlkes and Mallows (see fowlkes 1983). They allow making inference
|
|||
|
on whether the results obtained are different from what would have been
|
|||
|
expected under the null hypothesis (of now particular order of the
|
|||
|
trees’ labels).</p>
|
|||
|
<p>The <code>Bk</code> and the <code>Bk_plot</code> functions allow the
|
|||
|
calculation of the FM-Index for a range of k values on two trees. Here
|
|||
|
are examples:</p>
|
|||
|
<div class="sourceCode" id="cb185"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb185-1"><a href="#cb185-1" tabindex="-1"></a><span class="fu">set.seed</span>(<span class="dv">23235</span>)</span>
|
|||
|
<span id="cb185-2"><a href="#cb185-2" tabindex="-1"></a>ss <span class="ot"><-</span> <span class="cn">TRUE</span> <span class="co"># sample(1:150, 30 ) # TRUE #</span></span>
|
|||
|
<span id="cb185-3"><a href="#cb185-3" tabindex="-1"></a>hc1 <span class="ot"><-</span> <span class="fu">hclust</span>(<span class="fu">dist</span>(iris[ss,<span class="sc">-</span><span class="dv">5</span>]), <span class="st">"com"</span>)</span>
|
|||
|
<span id="cb185-4"><a href="#cb185-4" tabindex="-1"></a>hc2 <span class="ot"><-</span> <span class="fu">hclust</span>(<span class="fu">dist</span>(iris[ss,<span class="sc">-</span><span class="dv">5</span>]), <span class="st">"single"</span>)</span>
|
|||
|
<span id="cb185-5"><a href="#cb185-5" tabindex="-1"></a>dend1 <span class="ot"><-</span> <span class="fu">as.dendrogram</span>(hc1)</span>
|
|||
|
<span id="cb185-6"><a href="#cb185-6" tabindex="-1"></a>dend2 <span class="ot"><-</span> <span class="fu">as.dendrogram</span>(hc2)</span>
|
|||
|
<span id="cb185-7"><a href="#cb185-7" tabindex="-1"></a><span class="co"># cutree(tree1) </span></span>
|
|||
|
<span id="cb185-8"><a href="#cb185-8" tabindex="-1"></a></span>
|
|||
|
<span id="cb185-9"><a href="#cb185-9" tabindex="-1"></a><span class="co"># It works the same for hclust and dendrograms:</span></span>
|
|||
|
<span id="cb185-10"><a href="#cb185-10" tabindex="-1"></a><span class="fu">Bk</span>(hc1, hc2, <span class="at">k =</span> <span class="dv">3</span>)</span></code></pre></div>
|
|||
|
<pre><code>#> $`3`
|
|||
|
#> [1] 0.8059522
|
|||
|
#> attr(,"E_FM")
|
|||
|
#> [1] 0.4462325
|
|||
|
#> attr(,"V_FM")
|
|||
|
#> [1] 6.464092e-05</code></pre>
|
|||
|
<div class="sourceCode" id="cb187"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb187-1"><a href="#cb187-1" tabindex="-1"></a><span class="fu">Bk</span>(dend1, dend2, <span class="at">k =</span> <span class="dv">3</span>)</span></code></pre></div>
|
|||
|
<pre><code>#> $`3`
|
|||
|
#> [1] 0.8059522
|
|||
|
#> attr(,"E_FM")
|
|||
|
#> [1] 0.4462325
|
|||
|
#> attr(,"V_FM")
|
|||
|
#> [1] 6.464092e-05</code></pre>
|
|||
|
<p>The Bk plot:</p>
|
|||
|
<div class="sourceCode" id="cb189"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb189-1"><a href="#cb189-1" tabindex="-1"></a><span class="fu">Bk_plot</span>(hc1, hc2, <span class="at">main =</span> <span class="st">"WRONG Bk plot </span><span class="sc">\n</span><span class="st">(due to the way cutree works with ties in hclust)"</span>, <span class="at">warn =</span> <span class="cn">FALSE</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCCAYAAAB8GMlFAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIw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SRCUKIqIoIIiCoiD8KIKYUBGVZ0JMPBEzKipizjlgxIQBFQUxYwKzIhKMYEBEJUpGcob+65Tvjr2TdmZnZqdn5tT37Xa6ffve0z1dXbmMpyQkIkAEiAARIAIFikDZAp03p00EiAARIAJEwBAgI+SDQASIABEgAgWNABlhQd9+Tp4IEAEiQATICPkMEAEiQASIQEEjQEZY0LefkycCRIAIEAEyQj4DRIAIEAEiUNAIkBEW9O3n5IkAESACRICMkM8AESACRIAIFDQCZIQFffs5eSJABIgAESAj5DNABIgAESACBY0AGWFB335OnggQASJABMgI+QwQASJABIhAQSNARljQt5+TJwJEgAgQATJCPgNEgAgQASJQ0AiQERb07efkiQARIAJEgIyQzwARSAMCmzZtkhkzZsjGjRvT0FvRLpYtWyazZs0SXINEBIhA+hEgI0w/puwxiwj8/PPPUqZMGSlXrpysXLkyNJI+ffrYfhwbP358aP9tt91m+4855hgZO3ZsqA3auX5q1Kgh++23n3z77beh89zKmDFjZJ999pGqVavKzjvvbEtsf/rpp66JLS+99FLrb/fddy/C0FatWmX7q1SpUqT9li1bpH///tK0aVOpVauW7LTTTlK5cmXp2bOnMcUijcM2tt9++yLzABaYQ5s2beTNN98MtX7llVes3aGHHhral46VTz75xPoFDsnQihUr5Pbbb0/mFLYlAmlBgIwwLTCyk6AgsNtuuxnjACP5+uuvQ8P6+OOPQ+uff/55aH3ChAm2vv/++4f2lS1bVnbccUdp2LCh1K9fX9asWSPjxo2Tjh07ypw5c0LtXnrpJTnssMOMQYKRgVlus802tt2lSxcZMmRIqK1bAaN+6KGH3GbUped5ctZZZ8mgQYPkzz//FDDPXXbZxRjo8OHD7ZpgoMXRDjvsILvuuqudCzy++eYbOe644+S7774r7tRSP/7XX38Z03/wwQdL/dq8IBEgI+QzkFcIQIoDQwJNnDjRllBZgqE48jNC1wZMzlH16tVl5syZJnmB8f36668mUYEhOoYKaRMSG+jYY48VvMghUc6bN09OP/10ATO78sorZfny5a7b0PKGG26QBQsWhLbDV2699VZ5+umnZdtt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ktIuO7PMWJ3PNrylltukbffflugtnzqqadMGrzxxhuNAfnbo8+ffvrJdkWT6Pxt3TqkVeAMcmpNOAJFI6fmRDuH2ymnnGLSIUJDEplLtH65jwikCwEywnQhyX4ChYB7od9///02LqgqQVBlQg0KRggvSkhe7du3t2PuH1SbjonAIQYSIs7zv7CbNWtmzaFCXbdunTvVlmBicJwBuXa28b9/CGW49957beumm27yHzKJyNnyIEU5gkoSd
|
|||
|
<div class="sourceCode" id="cb190"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb190-1"><a href="#cb190-1" tabindex="-1"></a><span class="fu">Bk_plot</span>(dend1, dend2, <span class="at">main =</span> <span class="st">"CORRECT Bk plot </span><span class="sc">\n</span><span class="st">(based on dendrograms)"</span>)</span></code></pre></div>
|
|||
|
<p><img role="img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCCAYAAAB8GMlFAAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxPsRjVXu8HOh0qao30cArp9SZZxDfg3h1wTzKxu5E/LUxX5wKdX5SnAzmDx4A4OIqLbB69yMesE1pKojLjVdoNsfyiPi45hZmAn3uLWdpOtfQOaVmikEs7ovj8hFWpz7EV6mel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XLqzn4EMkHFlVp5FIfYfBqEFQS5OIQKwRICOMNcLsPyYIQHoAIf7OeDzqOl7izz77rMb6we4HSQ2SHuLjQL1799YwAd0wf8AErRPGrbfeaneHLBGGAUlo7969ct111wnCDdwoM23D9RHpvMKdm
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div id="session-info" class="section level1">
|
|||
|
<h1>Session info</h1>
|
|||
|
<div class="sourceCode" id="cb191"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb191-1"><a href="#cb191-1" tabindex="-1"></a><span class="fu">sessionInfo</span>()</span></code></pre></div>
|
|||
|
<pre><code>#> R version 4.4.1 (2024-06-14)
|
|||
|
#> Platform: x86_64-apple-darwin20
|
|||
|
#> Running under: macOS Big Sur 11.7.10
|
|||
|
#>
|
|||
|
#> Matrix products: default
|
|||
|
#> BLAS: /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/lib/libRblas.0.dylib
|
|||
|
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0
|
|||
|
#>
|
|||
|
#> locale:
|
|||
|
#> [1] C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
|
|||
|
#>
|
|||
|
#> time zone: America/New_York
|
|||
|
#> tzcode source: internal
|
|||
|
#>
|
|||
|
#> attached base packages:
|
|||
|
#> [1] stats graphics grDevices utils datasets methods base
|
|||
|
#>
|
|||
|
#> other attached packages:
|
|||
|
#> [1] corrplot_0.94 pvclust_2.2-0 dynamicTreeCut_1.63-1
|
|||
|
#> [4] gplots_3.1.3.1 DendSer_1.0.2 seriation_1.5.6
|
|||
|
#> [7] gclus_1.3.2 cluster_2.1.6 viridis_0.6.5
|
|||
|
#> [10] viridisLite_0.4.2 ggplot2_3.5.1 circlize_0.4.16
|
|||
|
#> [13] colorspace_2.1-1 knitr_1.48 dendextend_1.19.0
|
|||
|
#>
|
|||
|
#> loaded via a namespace (and not attached):
|
|||
|
#> [1] sass_0.4.9 utf8_1.2.4 generics_0.1.3
|
|||
|
#> [4] bitops_1.0-8 KernSmooth_2.23-24 shape_1.4.6.1
|
|||
|
#> [7] gtools_3.9.5 digest_0.6.37 magrittr_2.0.3
|
|||
|
#> [10] caTools_1.18.2 evaluate_0.24.0 grid_4.4.1
|
|||
|
#> [13] iterators_1.0.14 fastmap_1.2.0 foreach_1.5.2
|
|||
|
#> [16] jsonlite_1.8.8 GlobalOptions_0.1.2 gridExtra_2.3
|
|||
|
#> [19] fansi_1.0.6 scales_1.3.0 codetools_0.2-20
|
|||
|
#> [22] jquerylib_0.1.4 registry_0.5-1 cli_3.6.3
|
|||
|
#> [25] rlang_1.1.4 munsell_0.5.1 withr_3.0.1
|
|||
|
#> [28] cachem_1.1.0 yaml_2.3.10 tools_4.4.1
|
|||
|
#> [31] dplyr_1.1.4 ca_0.71.1 TSP_1.2-4
|
|||
|
#> [34] vctrs_0.6.5 R6_2.5.1 lifecycle_1.0.4
|
|||
|
#> [37] MASS_7.3-60.2 pkgconfig_2.0.3 pillar_1.9.0
|
|||
|
#> [40] bslib_0.8.0 gtable_0.3.5 glue_1.7.0
|
|||
|
#> [43] xfun_0.47 tibble_3.2.1 tidyselect_1.2.1
|
|||
|
#> [46] highr_0.11 rstudioapi_0.16.0 farver_2.1.2
|
|||
|
#> [49] htmltools_0.5.8.1 rmarkdown_2.28 labeling_0.4.3
|
|||
|
#> [52] compiler_4.4.1</code></pre>
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<!-- code folding -->
|
|||
|
|
|||
|
|
|||
|
<!-- dynamically load mathjax for compatibility with self-contained -->
|
|||
|
<script>
|
|||
|
(function () {
|
|||
|
var script = document.createElement("script");
|
|||
|
script.type = "text/javascript";
|
|||
|
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
|
|||
|
document.getElementsByTagName("head")[0].appendChild(script);
|
|||
|
})();
|
|||
|
</script>
|
|||
|
|
|||
|
</body>
|
|||
|
</html>
|