-
Notifications
You must be signed in to change notification settings - Fork 4
/
rooting.html
212 lines (183 loc) · 7.06 KB
/
rooting.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>FigTree Demo</title>
<script src="js/d3.js" charset="utf-8"></script>
<script src="js/d3-selection-multi.min.js" charset="utf-8"></script>
<!--<script src="https://d3js.org/d3.v5.min.js" charset="utf-8"></script>-->
<style>
text {
font-family: "helvetica-neue", "helvetica", "sans-serif";
font-size: 14pt;
font-weight: 300;
}
.branch .branch-path {
fill: none;
stroke: #541753;
stroke-width: 2px;
stroke-linecap: round;
stroke-linejoin: round;
}
.branch.hovered .branch-path {
stroke-width: 4px;
}
.external-node .node-shape {
fill: #22b680;
/*stroke: rgb(255, 255, 255);*/
/*stroke-width: 1;*/
}
.external-node .node-shape.hovered {
stroke: rgb(0,0,0);
/*stroke-width: 1;*/
}
.external-node .node-shape.unselected {
fill: #22b680;
/*stroke: rgb(255, 255, 255);*/
}
.external-node .node-shape.selected {
fill: #edb23b;
/*stroke: rgb(0,0,0);*/
}
.internal-node .node-shape {
fill: #29c5ef;
/*stroke: rgb(255, 255, 255);*/
/*stroke-width: 1;*/
}
.internal-node.hovered .node-shape {
stroke: rgb(0,0,0);
}
.root-true .node-shape {
fill: #e31e58;
/*stroke: rgb(255, 255, 255);*/
/*stroke-width: 1;*/
}
.node-background {
fill: rgb(255, 255, 255);
/*stroke: rgb(255, 255, 255);*/
/*stroke-width: 1;*/
}
.node-label {
font-family: "helvetica-neue", "helvetica", "sans-serif";
font-size: 14pt;
font-weight: 300;
}
.trend-line {
stroke: rgb(0,0,0);
stroke-width: 2px;
stroke-linecap: round;
}
.axis text {
font-family: "helvetica-neue", "helvetica", "sans-serif";
font-size: 12pt;
font-weight: 300;
}
.axis-label text {
font-family: "helvetica-neue", "helvetica", "sans-serif";
font-size: 12pt;
font-weight: bold;
}
.node-label.support {
font-size: 10pt;
}
.branch-label.length {
/*display: none;*/
font-size: 8pt;
}
.original-root .node-shape{
fill: #e31e58;
opacity: 0.4;
}
#tooltip {
background: #F6EECA;
border: 1px solid #005C68;
color: #005C68;
border-radius: 5px;
padding: 5px;
font-family: "helvetica-neue", "helvetica", "sans-serif";
font-size: 12pt;
font-weight: 300;
}
</style>
</head>
<body>
<div id="tooltip" display="none" style="position: absolute; display: none;"></div>
<div>
<figure>
<svg id="phylogram_1a" width="600" height="500"></svg>
<svg id="phylogram_1b" width="600" height="500"></svg>
<svg id="phylogram_1c" width="600" height="500"></svg>
</figure>
<!--<button id="sort_up_button">Sort ascending</button>-->
<!--<button id="sort_down_button">Sort descending</button>-->
<!--<button id="rectangular_button">Draw rectangular</button>-->
<!--<button id="triangular_button">Draw triangular</button>-->
</div>
<!-- <script src ="dist/figtree.js"></script> -->
<script type="module">
import {Tree,FigTree,circle,axis,tipLabel,equalAngleLayout,rootToTipLayout,branch} from "./dist/figtree.esm.js";
const timeTreeString =
'((((virusA_1975.5:20.0,virusB_1966:10.0):10.0,virusC_1986:40.0):15.0,(virusD_1969:35.0,virusE_1955.5:20.0):5.0):25.0,(virusF_2002:55.0,virusG_1965:15.0):40.0);';
const tree = Tree.parseNewick(timeTreeString, {datePrefix: "_"});
tree.annotateNode(tree.root,{root:true});
const treeSVG = document.getElementById('phylogram_1a');
const rootToTipSVG =document.getElementById('phylogram_1b');
const margins = { top: 10, bottom: 60, left: 100, right: 50};
const unRootedFig = new FigTree(treeSVG,margins,tree)
.layout(equalAngleLayout(tree.internalNodes[5]))
.nodes(
circle()
.attr("fill",d=>d.degree>1?"steelblue":"#c71585")
.attr("r",d=>d.annotations.hovered?10:5)
.rotateOnClick(),
tipLabel(d=>d.name)
)
.nodeBackgrounds(
circle()
.attr("r",7)
)
.branches(
branch()
.curve(d3.curveBasis)
.hilightOnHover()
.reRootOnClick("euclidean")
);
const rootToTipPlot = new FigTree(rootToTipSVG,margins,tree)
.layout(rootToTipLayout())
.nodes(
circle()
.filter(d=>!d.children)
.attr("r",d=>d.annotations.hovered?10:5)
.annotateOnHover("hovered"),
)
.nodeBackgrounds(
circle()
.attr("r",7)
)
.branches(
branch()
.curve(d3.curveBasis)
.hilightOnHover()
)
.feature(
axis()
.location("bottom")
.y(500-margins.top-margins.bottom+5)
.x(0)
.title({text:"Date",
yPadding:30})
)
.feature(
axis()
.location("left")
.y(0)
.x(-5)
.title({text:"Divergence",
xPadding:-80,
rotation:-90})
.tickFormat(d3.format(".3f"))
.ticks(4)
)
</script>
</body>
</html>