phylotree 2.6.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -5
- package/bin/phylotree-neighbor-join.js +4 -5
- package/bin/root-to-tip.js +1 -1
- package/bin/tip-date-extractor.js +26 -18
- package/dist/phylotree-menus.css +93 -0
- package/dist/phylotree.d.ts +509 -241
- package/dist/phylotree.js +5023 -1515
- package/dist/phylotree.min.js +1 -1
- package/package.json +25 -27
- package/src/branches.js +58 -34
- package/src/clustering/cluster-picker.js +18 -2
- package/src/clustering/phylopart.js +14 -6
- package/src/export.js +1 -1
- package/src/extract-dates.js +3 -3
- package/src/formats/beast.js +5 -1
- package/src/formats/newick.js +43 -7
- package/src/formats/nexml.js +87 -30
- package/src/formats/nexus.js +112 -32
- package/src/formats/phyloxml.js +74 -15
- package/src/formats/registry.js +5 -1
- package/src/index.js +1 -0
- package/src/main.js +76 -25
- package/src/metrics/center-of-tree.js +4 -2
- package/src/metrics/compute-midpoint.js +7 -1
- package/src/metrics/pairwise-distances.js +4 -2
- package/src/metrics/root-to-tip.js +43 -10
- package/src/metrics/sackins.js +7 -1
- package/src/msa-parsers/fasta.js +9 -12
- package/src/neighbor-join.js +107 -75
- package/src/nodes.js +43 -31
- package/src/render/clades.js +16 -4
- package/src/render/draw.js +128 -86
- package/src/render/edges.js +17 -8
- package/src/render/events.js +2 -3
- package/src/render/menus.js +110 -10
- package/src/render/nodes.js +42 -16
- package/src/render/options.js +3 -1
- package/src/render/selection-sets.js +30 -14
- package/src/render/unrooted.js +90 -12
- package/src/rooting.js +12 -3
- package/src/traversal.js +4 -3
package/src/metrics/sackins.js
CHANGED
|
@@ -14,7 +14,13 @@ export default function sackin(tree) {
|
|
|
14
14
|
let tips = tree.getTips();
|
|
15
15
|
|
|
16
16
|
// Count number of ancestors to root for each tree
|
|
17
|
-
let depths = _.map(tips, d => {
|
|
17
|
+
let depths = _.map(tips, d => {
|
|
18
|
+
let depth = 0;
|
|
19
|
+
for (let n = d; n.parent; n = n.parent) {
|
|
20
|
+
depth++;
|
|
21
|
+
}
|
|
22
|
+
return depth;
|
|
23
|
+
});
|
|
18
24
|
|
|
19
25
|
return _.reduce(depths, function(memo, num){ return memo + num; }, 0);
|
|
20
26
|
|
package/src/msa-parsers/fasta.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import * as _ from "lodash";
|
|
2
|
-
|
|
3
1
|
export default function parseFasta(fastaData) {
|
|
2
|
+
let sfasta = String(fastaData).split("\n");
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
let sfasta = _.split(fastaData, "\n");
|
|
7
|
-
|
|
8
|
-
let seqs = _.chain(sfasta)
|
|
4
|
+
let starts = sfasta
|
|
9
5
|
.map((d, i) => (d.startsWith(">") ? i : -1))
|
|
10
|
-
.filter((d) => d != -1)
|
|
11
|
-
.map((d, i, c) => _.slice(sfasta, c[i], c[i + 1]))
|
|
12
|
-
.keyBy((d) => _.trim(d[0], ">"))
|
|
13
|
-
.mapValues((d) => _.tail(d).join(""))
|
|
14
|
-
.value();
|
|
6
|
+
.filter((d) => d != -1);
|
|
15
7
|
|
|
16
|
-
|
|
8
|
+
let seqs = {};
|
|
9
|
+
starts.forEach((start, k) => {
|
|
10
|
+
let record = sfasta.slice(start, starts[k + 1]);
|
|
11
|
+
seqs[record[0].replace(/^>+|>+$/g, "")] = record.slice(1).join("");
|
|
12
|
+
});
|
|
17
13
|
|
|
14
|
+
return seqs;
|
|
18
15
|
}
|
package/src/neighbor-join.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import * as _ from "lodash";
|
|
2
1
|
import { default as phylotree } from "./main";
|
|
3
2
|
|
|
4
3
|
function remove(i, D) {
|
|
5
4
|
let dNew = [];
|
|
6
5
|
|
|
7
|
-
for (let j
|
|
6
|
+
for (let j = 0; j < D.length; j++) {
|
|
8
7
|
if (j != i) {
|
|
9
8
|
let dNewRow = [];
|
|
10
|
-
for (let k
|
|
9
|
+
for (let k = 0; k < D[j].length; k++) {
|
|
11
10
|
if (k != i) {
|
|
12
11
|
dNewRow.push(D[j][k]);
|
|
13
12
|
}
|
|
@@ -20,9 +19,9 @@ function remove(i, D) {
|
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
function getDPrime(distanceMatrix, totalDistances, N) {
|
|
23
|
-
let DPrime =
|
|
24
|
-
for (let i
|
|
25
|
-
for (let j
|
|
22
|
+
let DPrime = Array.from({ length: N }, () => Array(N).fill(0));
|
|
23
|
+
for (let i = 0; i < N; i++) {
|
|
24
|
+
for (let j = i + 1; j < N; j++) {
|
|
26
25
|
DPrime[i][j] =
|
|
27
26
|
(N - 2) * distanceMatrix[i][j] - totalDistances[i] - totalDistances[j];
|
|
28
27
|
DPrime[j][i] = DPrime[i][j];
|
|
@@ -35,8 +34,8 @@ function ijMinDPrime(dPrime, N) {
|
|
|
35
34
|
let i = -1;
|
|
36
35
|
let j = -1;
|
|
37
36
|
let minD = Infinity;
|
|
38
|
-
for (let ii
|
|
39
|
-
for (let jj
|
|
37
|
+
for (let ii = 0; ii < N; ii++) {
|
|
38
|
+
for (let jj = ii + 1; jj < N; jj++) {
|
|
40
39
|
if (dPrime[ii][jj] < minD) {
|
|
41
40
|
i = ii;
|
|
42
41
|
j = jj;
|
|
@@ -48,10 +47,10 @@ function ijMinDPrime(dPrime, N) {
|
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
function createDelta(totalDistances, N) {
|
|
51
|
-
let deltaMatrix =
|
|
50
|
+
let deltaMatrix = Array.from({ length: N }, () => Array(N));
|
|
52
51
|
|
|
53
|
-
for (let i
|
|
54
|
-
for (let j
|
|
52
|
+
for (let i = 0; i < N; i++) {
|
|
53
|
+
for (let j = i + 1; j < N; j++) {
|
|
55
54
|
deltaMatrix[i][j] = (totalDistances[i] - totalDistances[j]) / (N - 2);
|
|
56
55
|
deltaMatrix[j][i] = deltaMatrix[i][j];
|
|
57
56
|
}
|
|
@@ -63,23 +62,30 @@ function createDelta(totalDistances, N) {
|
|
|
63
62
|
export function getDistanceMatrix(seqs) {
|
|
64
63
|
// Gaps are masked
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
const lengths = Object.values(seqs).map((seq) => seq.length);
|
|
66
|
+
if (!lengths.length) {
|
|
67
|
+
return {};
|
|
68
|
+
}
|
|
69
|
+
// Compare only the positions present in every sequence
|
|
70
|
+
let seqLength = Math.min(...lengths);
|
|
71
|
+
|
|
72
|
+
const matrix = {};
|
|
73
|
+
for (const [key, seq] of Object.entries(seqs)) {
|
|
74
|
+
matrix[key] = Object.values(seqs).map((seq2) => {
|
|
75
|
+
let differences = 0;
|
|
76
|
+
for (let i = 0; i < seqLength; i++) {
|
|
77
|
+
if (seq[i] != seq2[i] && seq[i] != "-" && seq2[i] != "-") {
|
|
78
|
+
differences++;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return differences;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return matrix;
|
|
79
85
|
}
|
|
80
86
|
|
|
81
87
|
function getTotalDistances(distanceMatrix) {
|
|
82
|
-
return
|
|
88
|
+
return distanceMatrix.map((row) => row.reduce((total, d) => total + d, 0));
|
|
83
89
|
}
|
|
84
90
|
|
|
85
91
|
/**
|
|
@@ -100,23 +106,50 @@ function getTotalDistances(distanceMatrix) {
|
|
|
100
106
|
* @returns The neighbor joining new tree.
|
|
101
107
|
*/
|
|
102
108
|
export default function neighborJoining(distanceMatrixArr, n, nodeList) {
|
|
103
|
-
|
|
104
|
-
let tree = new phylotree("");
|
|
109
|
+
let json = neighborJoiningJson(distanceMatrixArr, n, nodeList);
|
|
105
110
|
|
|
106
|
-
|
|
111
|
+
return new phylotree(jsonToNewick(json) + ":0;");
|
|
112
|
+
}
|
|
107
113
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
114
|
+
function jsonToNewick(node) {
|
|
115
|
+
// Quote names containing non-alphanumeric characters
|
|
116
|
+
let name = /\W/.test(node.name)
|
|
117
|
+
? "'" + node.name.replaceAll("'", "''") + "'"
|
|
118
|
+
: node.name;
|
|
119
|
+
let label = node.children
|
|
120
|
+
? "(" + node.children.map(jsonToNewick).join(",") + ")" + name
|
|
121
|
+
: name;
|
|
122
|
+
|
|
123
|
+
return node.attribute === undefined
|
|
124
|
+
? label
|
|
125
|
+
: label + ":" + node.attribute;
|
|
126
|
+
}
|
|
111
127
|
|
|
112
|
-
|
|
113
|
-
|
|
128
|
+
function findByName(node, name) {
|
|
129
|
+
if (node.name == name) {
|
|
130
|
+
return node;
|
|
131
|
+
}
|
|
132
|
+
for (const child of node.children || []) {
|
|
133
|
+
let found = findByName(child, name);
|
|
134
|
+
if (found) {
|
|
135
|
+
return found;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
114
140
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
141
|
+
function neighborJoiningJson(distanceMatrixArr, n, nodeList) {
|
|
142
|
+
if (n <= 2) {
|
|
143
|
+
// Get root
|
|
144
|
+
let distance = distanceMatrixArr[0][1] / 2;
|
|
118
145
|
|
|
119
|
-
return
|
|
146
|
+
return {
|
|
147
|
+
name: "",
|
|
148
|
+
children: [
|
|
149
|
+
{ name: nodeList[0], attribute: distance },
|
|
150
|
+
{ name: nodeList[1], attribute: distance },
|
|
151
|
+
],
|
|
152
|
+
};
|
|
120
153
|
} else {
|
|
121
154
|
let N = n;
|
|
122
155
|
let totalDistances = getTotalDistances(distanceMatrixArr);
|
|
@@ -125,22 +158,17 @@ export default function neighborJoining(distanceMatrixArr, n, nodeList) {
|
|
|
125
158
|
let deltaMatrix = createDelta(totalDistances, N);
|
|
126
159
|
let limbLengthI = (distanceMatrixArr[i][j] + deltaMatrix[i][j]) / 2;
|
|
127
160
|
let limbLengthJ = (distanceMatrixArr[i][j] - deltaMatrix[i][j]) / 2;
|
|
128
|
-
let newRow =
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
}),
|
|
141
|
-
_.isNumber
|
|
142
|
-
)
|
|
143
|
-
);
|
|
161
|
+
let newRow = [0];
|
|
162
|
+
for (let k = 0; k < n; k++) {
|
|
163
|
+
if (k != i && k != j) {
|
|
164
|
+
newRow.push(
|
|
165
|
+
0.5 *
|
|
166
|
+
(distanceMatrixArr[k][i] +
|
|
167
|
+
distanceMatrixArr[k][j] -
|
|
168
|
+
distanceMatrixArr[i][j])
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
144
172
|
|
|
145
173
|
let nodeI = nodeList[i];
|
|
146
174
|
let nodeJ = nodeList[j];
|
|
@@ -148,44 +176,48 @@ export default function neighborJoining(distanceMatrixArr, n, nodeList) {
|
|
|
148
176
|
// Get all nodes of type InternalNode{x} and increment number.
|
|
149
177
|
// If there are none, start with InternalNode0
|
|
150
178
|
let m = "InternalNode0";
|
|
151
|
-
let internalNodes =
|
|
152
|
-
_.includes(x, "InternalNode")
|
|
153
|
-
);
|
|
179
|
+
let internalNodes = nodeList.filter((x) => x.includes("InternalNode"));
|
|
154
180
|
|
|
155
181
|
if (internalNodes.length) {
|
|
156
|
-
|
|
157
|
-
|
|
182
|
+
// Compare as numbers: as strings, "9" > "10" and the label would repeat.
|
|
183
|
+
let highestNum = Math.max(
|
|
184
|
+
...internalNodes.map((label) => Number(label.split("InternalNode")[1]))
|
|
158
185
|
);
|
|
159
|
-
m = "InternalNode" +
|
|
186
|
+
m = "InternalNode" + (highestNum + 1);
|
|
160
187
|
}
|
|
161
188
|
|
|
162
189
|
nodeList.unshift(m);
|
|
163
190
|
|
|
164
|
-
distanceMatrixArr = remove(
|
|
165
|
-
distanceMatrixArr = remove(
|
|
191
|
+
distanceMatrixArr = remove(Math.max(i, j), distanceMatrixArr);
|
|
192
|
+
distanceMatrixArr = remove(Math.min(i, j), distanceMatrixArr);
|
|
166
193
|
|
|
167
194
|
distanceMatrixArr.unshift(newRow);
|
|
168
195
|
|
|
169
|
-
|
|
196
|
+
for (let l = 1; l < n - 1; l++) {
|
|
197
|
+
distanceMatrixArr[l].unshift(newRow[l]);
|
|
198
|
+
}
|
|
170
199
|
|
|
171
200
|
// Remove from nodeList
|
|
172
|
-
|
|
173
|
-
|
|
201
|
+
for (let k = nodeList.length - 1; k >= 0; k--) {
|
|
202
|
+
if (nodeList[k] == nodeI || nodeList[k] == nodeJ) {
|
|
203
|
+
nodeList.splice(k, 1);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
let tree = neighborJoiningJson(distanceMatrixArr, N - 1, nodeList);
|
|
174
207
|
|
|
175
|
-
let treeNodeI =
|
|
176
|
-
let treeNodeJ =
|
|
208
|
+
let treeNodeI = { name: nodeI, attribute: limbLengthI };
|
|
209
|
+
let treeNodeJ = { name: nodeJ, attribute: limbLengthJ };
|
|
177
210
|
|
|
178
211
|
// If the node doesn't exist, create. Otherwise, reassign the length
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
tree.addChild(internalNode, treeNodeJ);
|
|
212
|
+
let internalNode = findByName(tree, m);
|
|
213
|
+
if (internalNode) {
|
|
214
|
+
internalNode.children = [treeNodeI, treeNodeJ];
|
|
183
215
|
} else {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
216
|
+
tree.children.push({
|
|
217
|
+
name: m,
|
|
218
|
+
attribute: 0,
|
|
219
|
+
children: [treeNodeI, treeNodeJ],
|
|
220
|
+
});
|
|
189
221
|
}
|
|
190
222
|
|
|
191
223
|
// Set negative to 0 and add distance to other limblength
|
package/src/nodes.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import * as d3 from "d3";
|
|
1
2
|
import * as _ from "underscore";
|
|
2
3
|
|
|
3
4
|
// These methods are part of the Phylotree object
|
|
4
5
|
|
|
6
|
+
function lengthAttr(l) {
|
|
7
|
+
return l === null || l === undefined ? null : String(l);
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
export function graftANode(graftAt, newChild, newParent, lengths) {
|
|
6
11
|
|
|
7
12
|
let nodes = this.nodes.descendants();
|
|
@@ -14,24 +19,26 @@ export function graftANode(graftAt, newChild, newParent, lengths) {
|
|
|
14
19
|
|
|
15
20
|
let parentIndex = graftAt.parent.children.indexOf(graftAt);
|
|
16
21
|
|
|
17
|
-
let newSplit = {
|
|
22
|
+
let newSplit = d3.hierarchy({
|
|
18
23
|
name: newParent,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
newNode = {
|
|
24
|
+
attribute: lengths ? lengthAttr(lengths[2]) : null,
|
|
25
|
+
original_child_order: graftAt.data["original_child_order"]
|
|
26
|
+
}),
|
|
27
|
+
newNode = d3.hierarchy({
|
|
24
28
|
name: newChild,
|
|
25
|
-
|
|
26
|
-
attribute: lengths ? lengths[1] : null,
|
|
29
|
+
attribute: lengths ? lengthAttr(lengths[1]) : null,
|
|
27
30
|
original_child_order: 2
|
|
28
|
-
};
|
|
31
|
+
});
|
|
29
32
|
|
|
33
|
+
newSplit.parent = graftAt.parent;
|
|
34
|
+
newNode.parent = newSplit;
|
|
30
35
|
newSplit["children"] = [graftAt, newNode];
|
|
31
36
|
graftAt["parent"].children[parentIndex] = newSplit;
|
|
32
37
|
graftAt.parent = newSplit;
|
|
33
|
-
graftAt["attribute"] = lengths ? lengths[0] : null;
|
|
34
|
-
graftAt["original_child_order"] = 1;
|
|
38
|
+
graftAt.data["attribute"] = lengths ? lengthAttr(lengths[0]) : null;
|
|
39
|
+
graftAt.data["original_child_order"] = 1;
|
|
40
|
+
|
|
41
|
+
this.update(this.nodes);
|
|
35
42
|
}
|
|
36
43
|
}
|
|
37
44
|
|
|
@@ -41,6 +48,8 @@ export function graftANode(graftAt, newChild, newParent, lengths) {
|
|
|
41
48
|
|
|
42
49
|
export function addChild(parent, child) {
|
|
43
50
|
|
|
51
|
+
child.parent = parent;
|
|
52
|
+
|
|
44
53
|
if(parent.children) {
|
|
45
54
|
parent.children.push(child);
|
|
46
55
|
} else {
|
|
@@ -53,13 +62,10 @@ export function addChild(parent, child) {
|
|
|
53
62
|
|
|
54
63
|
export function createNode(name, lengths) {
|
|
55
64
|
|
|
56
|
-
return {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
parent: '',
|
|
62
|
-
};
|
|
65
|
+
return d3.hierarchy({
|
|
66
|
+
name: name,
|
|
67
|
+
attribute: lengths ? lengths[1] : null
|
|
68
|
+
});
|
|
63
69
|
|
|
64
70
|
}
|
|
65
71
|
|
|
@@ -84,8 +90,6 @@ export function deleteANode(index) {
|
|
|
84
90
|
let delete_me_idx = node.parent.children.indexOf(node);
|
|
85
91
|
|
|
86
92
|
if (delete_me_idx >= 0) {
|
|
87
|
-
nodes.splice(index, 1);
|
|
88
|
-
|
|
89
93
|
if (node.children) {
|
|
90
94
|
node.children.forEach(function(d) {
|
|
91
95
|
d["original_child_order"] = node.parent.children.length;
|
|
@@ -97,23 +101,31 @@ export function deleteANode(index) {
|
|
|
97
101
|
if (node.parent.children.length > 2) {
|
|
98
102
|
node.parent.children.splice(delete_me_idx, 1);
|
|
99
103
|
} else {
|
|
104
|
+
let sibling = node.parent.children[1 - delete_me_idx];
|
|
105
|
+
|
|
100
106
|
if (node.parent.parent) {
|
|
101
107
|
node.parent.parent.children[
|
|
102
108
|
node.parent.parent.children.indexOf(node.parent)
|
|
103
|
-
] =
|
|
104
|
-
|
|
105
|
-
node.parent.children[1 - delete_me_idx].parent = node.parent.parent;
|
|
106
|
-
nodes.splice(nodes.indexOf(node.parent), 1);
|
|
109
|
+
] = sibling;
|
|
110
|
+
sibling.parent = node.parent.parent;
|
|
107
111
|
} else {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
// the parent is the root: lift the sibling's children, or keep a
|
|
113
|
+
// leaf sibling as the sole child
|
|
114
|
+
let root = node.parent;
|
|
115
|
+
if (!sibling) {
|
|
116
|
+
delete root.children;
|
|
117
|
+
} else if (sibling.children) {
|
|
118
|
+
root.children = sibling.children;
|
|
119
|
+
root.children.forEach(function(d) {
|
|
120
|
+
d.parent = root;
|
|
121
|
+
});
|
|
122
|
+
} else {
|
|
123
|
+
root.children = [sibling];
|
|
124
|
+
}
|
|
115
125
|
}
|
|
116
126
|
}
|
|
127
|
+
|
|
128
|
+
this.update(this.nodes);
|
|
117
129
|
}
|
|
118
130
|
}
|
|
119
131
|
}
|
package/src/render/clades.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as d3 from "d3";
|
|
2
2
|
import * as _ from "underscore";
|
|
3
|
-
import { isNodeCollapsed } from "./nodes";
|
|
3
|
+
import { isNodeCollapsed, nodeOrAncestorNotshown } from "./nodes";
|
|
4
4
|
|
|
5
5
|
export function cladeCssSelectors(css_classes) {
|
|
6
6
|
return [css_classes["clade"]].reduce(function(p, c, i, a) {
|
|
7
|
-
return
|
|
7
|
+
return p + "path." + c + (i < a.length - 1 ? "," : "");
|
|
8
8
|
}, "");
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -16,7 +16,17 @@ export function updateCollapsedClades(transitions) {
|
|
|
16
16
|
let collapsed_clades = enclosure
|
|
17
17
|
.selectAll(cladeCssSelectors(this.css_classes))
|
|
18
18
|
.data(
|
|
19
|
-
|
|
19
|
+
// a hidden clade is not laid out, so do not draw its stale polygon
|
|
20
|
+
this.phylotree.nodes
|
|
21
|
+
.descendants()
|
|
22
|
+
.filter(
|
|
23
|
+
d =>
|
|
24
|
+
isNodeCollapsed(d) &&
|
|
25
|
+
Array.isArray(d.collapsed) &&
|
|
26
|
+
d.collapsed.length > 0 &&
|
|
27
|
+
!d.hidden &&
|
|
28
|
+
!nodeOrAncestorNotshown(d)
|
|
29
|
+
),
|
|
20
30
|
function(d) {
|
|
21
31
|
return d.id || (d.id = ++node_id);
|
|
22
32
|
}
|
|
@@ -110,7 +120,9 @@ export function updateCollapsedClades(transitions) {
|
|
|
110
120
|
.attr("class", this.css_classes["clade"])
|
|
111
121
|
.merge(collapsed_clades)
|
|
112
122
|
.attr("d", function(d) {
|
|
113
|
-
|
|
123
|
+
// always draw from the current layout: a cached outline goes stale as
|
|
124
|
+
// soon as another clade is collapsed, expanded, hidden or shown
|
|
125
|
+
return (d.collapsed_clade = spline(d.collapsed));
|
|
114
126
|
});
|
|
115
127
|
}
|
|
116
128
|
}
|