phylotree 2.1.7 → 2.2.1

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/dist/phylotree.js CHANGED
@@ -8274,6 +8274,16 @@
8274
8274
  /**
8275
8275
  * Get the tips of the tree
8276
8276
  * @returns {Array} Nodes in the current ``phylotree``.
8277
+ * @example
8278
+ * // Get all leaf nodes from a tree
8279
+ * const tree = new Phylotree("((A:0.1,B:0.2):0.05,C:0.3);");
8280
+ * const tips = tree.getTips();
8281
+ * console.log(tips.map(tip => tip.data.name)); // ["A", "B", "C"]
8282
+ *
8283
+ * @example
8284
+ * // Count the number of taxa in the tree
8285
+ * const numTaxa = tree.getTips().length;
8286
+ * console.log(`Tree has ${numTaxa} taxa`);
8277
8287
  */
8278
8288
  function getTips() {
8279
8289
  // get all nodes that have no nodes
@@ -8316,6 +8326,18 @@
8316
8326
  *
8317
8327
  * @param {String} name Name of the desired node.
8318
8328
  * @returns {Node} Desired node.
8329
+ * @example
8330
+ * // Find a specific node by name
8331
+ * const tree = new Phylotree("((A:0.1,B:0.2):0.05,C:0.3);");
8332
+ * const nodeA = tree.getNodeByName("A");
8333
+ * console.log(nodeA.data.name); // "A"
8334
+ *
8335
+ * @example
8336
+ * // Check if a node exists and get its branch length
8337
+ * const nodeB = tree.getNodeByName("B");
8338
+ * if (nodeB) {
8339
+ * console.log(`Node B has branch length: ${nodeB.data.attribute}`);
8340
+ * }
8319
8341
  */
8320
8342
  function getNodeByName(name) {
8321
8343
  return ___namespace.filter(this.nodes.descendants(), d => {
@@ -8329,6 +8351,21 @@
8329
8351
  *
8330
8352
  * @param {Object} attributes An object whose keys are the names of nodes
8331
8353
  * to modify, and whose values are the new attributes to add.
8354
+ * @example
8355
+ * // Add species information to nodes
8356
+ * const tree = new Phylotree(newick);
8357
+ * tree.assignAttributes({
8358
+ * "Human": { species: "Homo sapiens", host: "human" },
8359
+ * "Chimp": { species: "Pan troglodytes", host: "chimpanzee" }
8360
+ * });
8361
+ *
8362
+ * @example
8363
+ * // Add selection categories for visualization
8364
+ * tree.assignAttributes({
8365
+ * "foreground_1": { category: "foreground", color: "red" },
8366
+ * "foreground_2": { category: "foreground", color: "red" },
8367
+ * "background_1": { category: "background", color: "blue" }
8368
+ * });
8332
8369
  */
8333
8370
  function assignAttributes(attributes) {
8334
8371
  //return nodes;
@@ -8396,6 +8433,22 @@
8396
8433
  * @param {Boolean} terminal Whether to include terminal nodes.
8397
8434
  * @param {Boolean} internal Whther to include internal nodes.
8398
8435
  * @returns {Array} An array of selected nodes.
8436
+ * @example
8437
+ * // Select all descendants of an internal node
8438
+ * const tree = new Phylotree("(((A,B)AB,(C,D)CD)ABCD,E);");
8439
+ * const internalNode = tree.getNodeByName("ABCD");
8440
+ * const allDescendants = tree.selectAllDescendants(internalNode, true, true);
8441
+ * console.log(allDescendants.map(n => n.data.name)); // ["AB", "A", "B", "CD", "C", "D"]
8442
+ *
8443
+ * @example
8444
+ * // Select only terminal descendants (tips in a clade)
8445
+ * const cladeTips = tree.selectAllDescendants(internalNode, true, false);
8446
+ * console.log(cladeTips.map(n => n.data.name)); // ["A", "B", "C", "D"]
8447
+ *
8448
+ * @example
8449
+ * // Select only internal descendants
8450
+ * const cladeInternals = tree.selectAllDescendants(internalNode, false, true);
8451
+ * console.log(cladeInternals.map(n => n.data.name)); // ["AB", "CD"]
8399
8452
  */
8400
8453
  function selectAllDescendants$1(node, terminal, internal) {
8401
8454
 
@@ -8447,6 +8500,29 @@
8447
8500
  * @param {String} nwk_str - A string representing a phylogenetic tree in Newick format.
8448
8501
  * @param {Object} bootstrap_values.
8449
8502
  * @returns {Object} An object with keys ``json`` and ``error``.
8503
+ * @example
8504
+ * // Parse a simple Newick tree with branch lengths
8505
+ * const newick = "((A:0.1,B:0.2):0.05,C:0.3);";
8506
+ * const result = newickParser(newick);
8507
+ * if (result.error) {
8508
+ * console.error("Parse error:", result.error);
8509
+ * } else {
8510
+ * console.log("Parsed tree:", result.json);
8511
+ * }
8512
+ *
8513
+ * @example
8514
+ * // Parse tree with tagged branches
8515
+ * const taggedNewick = "((A:0.1,B{Foreground}:0.2){Foreground}:0.05,C:0.3);";
8516
+ * const result = newickParser(taggedNewick);
8517
+ * // Tagged branches will have annotation properties
8518
+ *
8519
+ * @example
8520
+ * // Parse tree with custom delimiters
8521
+ * const nhxNewick = "((A:0.1,B:0.2[&&NHX:S=species1:D=Y]):0.05,C:0.3);";
8522
+ * const result = newickParser(nhxNewick, {
8523
+ * left_delimiter: '[',
8524
+ * right_delimiter: ']'
8525
+ * });
8450
8526
  */
8451
8527
 
8452
8528
  function newickParser(nwk_str, options={}) {
@@ -8663,6 +8739,25 @@
8663
8739
  * what label is written (optional).
8664
8740
  * @param {Node} node - start at this node (default == root)
8665
8741
  * @returns {String} newick - Phylogenetic tree serialized as a Newick string.
8742
+ * @example
8743
+ * // Export tree to basic Newick format
8744
+ * const tree = new Phylotree(newick);
8745
+ * const exportedNewick = tree.getNewick();
8746
+ * console.log(exportedNewick); // "((A:0.1,B:0.2):0.05,C:0.3);"
8747
+ *
8748
+ * @example
8749
+ * // Export with custom node annotations
8750
+ * const annotatedNewick = tree.getNewick(function(node) {
8751
+ * if (node.data.selected) {
8752
+ * return "{SELECTED}";
8753
+ * }
8754
+ * return "";
8755
+ * });
8756
+ *
8757
+ * @example
8758
+ * // Export a subtree starting from a specific node
8759
+ * const nodeOfInterest = tree.getNodeByName("A");
8760
+ * const subtreeNewick = tree.getNewick(null, nodeOfInterest);
8666
8761
  */
8667
8762
 
8668
8763
 
@@ -8713,6 +8808,54 @@
8713
8808
  return element_array.join("")+";";
8714
8809
  }
8715
8810
 
8811
+ /**
8812
+ * Generate Newick string with selection tags.
8813
+ *
8814
+ * @param {Object} options - Configuration options.
8815
+ * @param {string} [options.tag='Foreground'] - Tag name for selected nodes (single selection mode).
8816
+ * @param {boolean} [options.multiSet=false] - Use multi-set mode tags (uses set names as tags).
8817
+ * @returns {string} Tagged Newick string.
8818
+ * @example
8819
+ * // Basic tagged output (uses selection state)
8820
+ * const tagged = tree.getTaggedNewick();
8821
+ * // Returns: "((A{Foreground}:0.1,B:0.2):0.05,C{Foreground}:0.3);"
8822
+ *
8823
+ * @example
8824
+ * // Custom tag name
8825
+ * const tagged = tree.getTaggedNewick({ tag: 'TEST' });
8826
+ * // Returns: "((A{TEST}:0.1,B:0.2):0.05,C{TEST}:0.3);"
8827
+ *
8828
+ * @example
8829
+ * // Multi-set mode (uses set names as tags)
8830
+ * const tagged = tree.getTaggedNewick({ multiSet: true });
8831
+ * // Returns: "((A{TEST}:0.1,B{REFERENCE}):0.2,C{TEST}:0.3);"
8832
+ */
8833
+ function getTaggedNewick(options = {}) {
8834
+ const tag = options.tag || 'Foreground';
8835
+ const multiSet = options.multiSet || false;
8836
+
8837
+ // Get selection attribute name from display if available
8838
+ const selectionAttr = this.display
8839
+ ? this.display.selection_attribute_name
8840
+ : 'selected';
8841
+
8842
+ // Get selection sets from display if in multi-set mode
8843
+ this.display ? this.display._selectionSets : null;
8844
+
8845
+ const annotator = (node) => {
8846
+ if (multiSet && node._selectionSet) {
8847
+ // Multi-set mode: use set name as tag
8848
+ return `{${node._selectionSet}}`;
8849
+ } else if (node[selectionAttr]) {
8850
+ // Single selection mode: use configured tag
8851
+ return `{${tag}}`;
8852
+ }
8853
+ return '';
8854
+ };
8855
+
8856
+ return this.getNewick(annotator);
8857
+ }
8858
+
8716
8859
  function parseAnnotations (buf) {
8717
8860
 
8718
8861
  let str = buf;
@@ -9234,6 +9377,23 @@
9234
9377
  *
9235
9378
  * @param {Function} attr Empty if getting, or new branch length accessor if setting.
9236
9379
  * @returns {Object} The branch length accessor if getting, or the current this if setting.
9380
+ * @example
9381
+ * // Set a custom branch length accessor
9382
+ * const tree = new Phylotree(newick);
9383
+ * tree.setBranchLength(function(node) {
9384
+ * // Use a transformed branch length
9385
+ * return Math.log(node.data.attribute + 1);
9386
+ * });
9387
+ *
9388
+ * @example
9389
+ * // Set all branch lengths to 1 (equal branch lengths)
9390
+ * tree.setBranchLength(function(node) {
9391
+ * return 1;
9392
+ * });
9393
+ *
9394
+ * @example
9395
+ * // Get the current branch length accessor
9396
+ * const currentAccessor = tree.setBranchLength();
9237
9397
  */
9238
9398
  function setBranchLength(attr) {
9239
9399
  if (!arguments.length) return this.branch_length_accessor;
@@ -9242,7 +9402,19 @@
9242
9402
  }
9243
9403
 
9244
9404
  /**
9245
- * Normalizes branch lengths
9405
+ * Normalizes branch lengths to range [0,1]
9406
+ * @returns {Phylotree} The current phylotree instance
9407
+ * @example
9408
+ * // Normalize all branch lengths to 0-1 range
9409
+ * const tree = new Phylotree(newick);
9410
+ * tree.normalizeBranchLengths();
9411
+ * // Now all branch lengths are between 0 and 1
9412
+ *
9413
+ * @example
9414
+ * // Useful for comparing trees with different scales
9415
+ * const tree1 = new Phylotree(newick1).normalizeBranchLengths();
9416
+ * const tree2 = new Phylotree(newick2).normalizeBranchLengths();
9417
+ * // Both trees now have comparable branch length scales
9246
9418
  */
9247
9419
  function normalize(attr) {
9248
9420
 
@@ -9276,9 +9448,29 @@
9276
9448
 
9277
9449
 
9278
9450
  /**
9279
- * Scales branch lengths
9451
+ * Scales branch lengths using a custom transformation function
9280
9452
  *
9281
- * @param {Function} function that scales the branches
9453
+ * @param {Function} scale_by Function that transforms each branch length
9454
+ * @returns {Phylotree} The current phylotree instance
9455
+ * @example
9456
+ * // Scale all branch lengths by a constant factor
9457
+ * const tree = new Phylotree(newick);
9458
+ * tree.scaleBranchLengths(function(length) {
9459
+ * return length * 2; // Double all branch lengths
9460
+ * });
9461
+ *
9462
+ * @example
9463
+ * // Apply logarithmic transformation
9464
+ * tree.scaleBranchLengths(function(length) {
9465
+ * return Math.log10(length + 1);
9466
+ * });
9467
+ *
9468
+ * @example
9469
+ * // Convert to time units (assuming substitutions per site)
9470
+ * const mutationRate = 1e-8;
9471
+ * tree.scaleBranchLengths(function(length) {
9472
+ * return length / mutationRate; // Convert to years
9473
+ * });
9282
9474
  */
9283
9475
  function scale(scale_by) {
9284
9476
 
@@ -9316,6 +9508,23 @@
9316
9508
  the specified fraction
9317
9509
 
9318
9510
  * @returns {Phylotree} The current ``phylotree``.
9511
+ * @example
9512
+ * // Reroot tree on a specific node
9513
+ * const tree = new Phylotree("((A:0.1,B:0.2):0.05,(C:0.3,D:0.1):0.08);");
9514
+ * const nodeC = tree.getNodeByName("C");
9515
+ * tree.reroot(nodeC);
9516
+ * // Tree is now rooted on the branch leading to C
9517
+ *
9518
+ * @example
9519
+ * // Reroot with custom branch length partitioning
9520
+ * const nodeA = tree.getNodeByName("A");
9521
+ * tree.reroot(nodeA, 0.3); // 30% of branch length goes to new root
9522
+ *
9523
+ * @example
9524
+ * // Reroot on midpoint of tree (balance tree)
9525
+ * const tips = tree.getTips();
9526
+ * const midpoint = tree.computeMidpoint();
9527
+ * tree.reroot(midpoint);
9319
9528
  */
9320
9529
  function reroot(node, fraction) {
9321
9530
 
@@ -9453,6 +9662,11 @@
9453
9662
  select(rendered_tree.container).node().appendChild(rendered_tree.show());
9454
9663
  select(this.display.container).dispatch('reroot');
9455
9664
 
9665
+ // Emit rerooted event via new event system
9666
+ if (rendered_tree.emit) {
9667
+ rendered_tree.emit('rerooted', this.nodes);
9668
+ }
9669
+
9456
9670
  }
9457
9671
 
9458
9672
  return this;
@@ -9797,8 +10011,12 @@
9797
10011
  .append("text")
9798
10012
  .classed(this.css_classes["node_text"], true)
9799
10013
  .merge(labels)
9800
- .on("click", d=> {
9801
- this.handle_node_click(node, d);
10014
+ .on("click", (event, d) => {
10015
+ this.emit('nodeClick', node, event);
10016
+ this.handle_node_click(node, event);
10017
+ })
10018
+ .on("mouseenter", (event) => {
10019
+ this.emit('nodeHover', node, event);
9802
10020
  })
9803
10021
  .attr("dy", d => {
9804
10022
  return this.shown_font_size * 0.33;
@@ -9939,8 +10157,12 @@
9939
10157
  .attr("r", d => {
9940
10158
  return Math.min(this.shown_font_size * 0.75, radius);
9941
10159
  })
9942
- .on("click", d => {
9943
- this.handle_node_click(node, d);
10160
+ .on("click", (event, d) => {
10161
+ this.emit('nodeClick', node, event);
10162
+ this.handle_node_click(node, event);
10163
+ })
10164
+ .on("mouseenter", (event) => {
10165
+ this.emit('nodeHover', node, event);
9944
10166
  });
9945
10167
  } else {
9946
10168
  circles.remove();
@@ -10251,9 +10473,15 @@
10251
10473
  .attr("class", d => {
10252
10474
  return this.reclassEdge(d);
10253
10475
  })
10254
- .on("click", d => {
10255
- this.modifySelection([edge.target], this.selection_attribute_name);
10256
- this.update();
10476
+ .on("click", (event, d) => {
10477
+ this.emit('branchClick', edge, event);
10478
+ // Check for multi-set selection mode
10479
+ if (this.options["selection-mode"] === "multi-set" && this._activeSetName) {
10480
+ this.handleMultiSetClick(edge.target);
10481
+ } else {
10482
+ this.modifySelection([edge.target], this.selection_attribute_name);
10483
+ this.update();
10484
+ }
10257
10485
  });
10258
10486
 
10259
10487
  let new_branch_path = this.draw_branch([edge.source, edge.target]);
@@ -10307,6 +10535,12 @@
10307
10535
  class_var += " " + css_classes["selected-branch"];
10308
10536
  }
10309
10537
 
10538
+ // Multi-set selection mode: add set-specific class
10539
+ if (edge.target && edge.target._selectionSet) {
10540
+ const safeName = edge.target._selectionSet.replace(/[^a-zA-Z0-9-_]/g, '_');
10541
+ class_var += " phylotree-set-branch-" + safeName;
10542
+ }
10543
+
10310
10544
  return class_var;
10311
10545
 
10312
10546
  }
@@ -10414,6 +10648,10 @@
10414
10648
  }
10415
10649
 
10416
10650
  this.placenodes();
10651
+
10652
+ // Emit collapsed event with node and current collapsed state
10653
+ this.emit('collapsed', node, node.collapsed);
10654
+
10417
10655
  return this;
10418
10656
  }
10419
10657
 
@@ -10466,7 +10704,13 @@
10466
10704
  svg = svg.transition(100);
10467
10705
  }
10468
10706
 
10469
- svg.attr("height", sizes[0]).attr("width", sizes[1]);
10707
+ if (this.options["responsive"]) {
10708
+ // Responsive mode: update viewBox
10709
+ svg.attr("viewBox", `0 0 ${sizes[1]} ${sizes[0]}`);
10710
+ } else {
10711
+ // Fixed mode: update width/height
10712
+ svg.attr("height", sizes[0]).attr("width", sizes[1]);
10713
+ }
10470
10714
 
10471
10715
  }
10472
10716
 
@@ -10573,7 +10817,7 @@
10573
10817
  menu_object = select(container)
10574
10818
  .append("div")
10575
10819
  .attr("id", d3_layout_phylotree_context_menu_id)
10576
- .attr("class", "dropdown-menu")
10820
+ .attr("class", "phylotree-context-menu dropdown-menu")
10577
10821
  .attr("role", "menu");
10578
10822
  }
10579
10823
 
@@ -10596,7 +10840,7 @@
10596
10840
  if (options["collapsible"]) {
10597
10841
  menu_object
10598
10842
  .append("a")
10599
- .attr("class", "dropdown-item")
10843
+ .attr("class", "phylotree-menu-item dropdown-item")
10600
10844
  .attr("tabindex", "-1")
10601
10845
  .text(isNodeCollapsed(node) ? "Expand Subtree" : "Collapse Subtree")
10602
10846
  .on("click", d => {
@@ -10604,10 +10848,10 @@
10604
10848
  this.toggleCollapse(node).update();
10605
10849
  });
10606
10850
  if (options["selectable"]) {
10607
- menu_object.append("div").attr("class", "dropdown-divider");
10851
+ menu_object.append("div").attr("class", "phylotree-menu-divider dropdown-divider");
10608
10852
  menu_object
10609
10853
  .append("h6")
10610
- .attr("class", "dropdown-header")
10854
+ .attr("class", "phylotree-menu-header dropdown-header")
10611
10855
  .text("Toggle selection");
10612
10856
  }
10613
10857
  }
@@ -10615,38 +10859,50 @@
10615
10859
  if (options["selectable"]) {
10616
10860
  menu_object
10617
10861
  .append("a")
10618
- .attr("class", "dropdown-item")
10862
+ .attr("class", "phylotree-menu-item dropdown-item")
10619
10863
  .attr("tabindex", "-1")
10620
10864
  .text("All descendant branches")
10621
- .on("click", function(d) {
10865
+ .on("click", (d) => {
10622
10866
  menu_object.style("display", "none");
10623
- phylotree.modifySelection(
10624
- phylotree.selectAllDescendants(node, true, true)
10625
- );
10867
+ const nodes = phylotree.selectAllDescendants(node, true, true);
10868
+ if (this.options["selection-mode"] === "multi-set" && this._activeSetName) {
10869
+ nodes.forEach(n => this.addToSet(n, this._activeSetName));
10870
+ this.update();
10871
+ } else {
10872
+ this.modifySelection(nodes);
10873
+ }
10626
10874
  });
10627
10875
 
10628
10876
  menu_object
10629
10877
  .append("a")
10630
- .attr("class", "dropdown-item")
10878
+ .attr("class", "phylotree-menu-item dropdown-item")
10631
10879
  .attr("tabindex", "-1")
10632
10880
  .text("All terminal branches")
10633
- .on("click", function(d) {
10881
+ .on("click", (d) => {
10634
10882
  menu_object.style("display", "none");
10635
- phylotree.modifySelection(
10636
- phylotree.selectAllDescendants(node, true, false)
10637
- );
10883
+ const nodes = phylotree.selectAllDescendants(node, true, false);
10884
+ if (this.options["selection-mode"] === "multi-set" && this._activeSetName) {
10885
+ nodes.forEach(n => this.addToSet(n, this._activeSetName));
10886
+ this.update();
10887
+ } else {
10888
+ this.modifySelection(nodes);
10889
+ }
10638
10890
  });
10639
10891
 
10640
10892
  menu_object
10641
10893
  .append("a")
10642
- .attr("class", "dropdown-item")
10894
+ .attr("class", "phylotree-menu-item dropdown-item")
10643
10895
  .attr("tabindex", "-1")
10644
10896
  .text("All internal branches")
10645
- .on("click", function(d) {
10897
+ .on("click", (d) => {
10646
10898
  menu_object.style("display", "none");
10647
- phylotree.modifySelection(
10648
- phylotree.selectAllDescendants(node, false, true)
10649
- );
10899
+ const nodes = phylotree.selectAllDescendants(node, false, true);
10900
+ if (this.options["selection-mode"] === "multi-set" && this._activeSetName) {
10901
+ nodes.forEach(n => this.addToSet(n, this._activeSetName));
10902
+ this.update();
10903
+ } else {
10904
+ this.modifySelection(nodes);
10905
+ }
10650
10906
  });
10651
10907
  }
10652
10908
  }
@@ -10655,33 +10911,44 @@
10655
10911
  if (options["selectable"]) {
10656
10912
  menu_object
10657
10913
  .append("a")
10658
- .attr("class", "dropdown-item")
10914
+ .attr("class", "phylotree-menu-item dropdown-item")
10659
10915
  .attr("tabindex", "-1")
10660
10916
  .text("Incident branch")
10661
- .on("click", function(d) {
10917
+ .on("click", (d) => {
10662
10918
  menu_object.style("display", "none");
10663
- phylotree.modifySelection([node]);
10919
+ if (this.options["selection-mode"] === "multi-set" && this._activeSetName) {
10920
+ this.addToSet(node, this._activeSetName);
10921
+ this.update();
10922
+ } else {
10923
+ this.modifySelection([node]);
10924
+ }
10664
10925
  });
10665
10926
 
10666
10927
  menu_object
10667
10928
  .append("a")
10668
- .attr("class", "dropdown-item")
10929
+ .attr("class", "phylotree-menu-item dropdown-item")
10669
10930
  .attr("tabindex", "-1")
10670
10931
  .text("Path to root")
10671
- .on("click", d => {
10932
+ .on("click", (d) => {
10672
10933
  menu_object.style("display", "none");
10673
- this.modifySelection(this.phylotree.pathToRoot(node));
10934
+ const nodes = this.phylotree.pathToRoot(node);
10935
+ if (this.options["selection-mode"] === "multi-set" && this._activeSetName) {
10936
+ nodes.forEach(n => this.addToSet(n, this._activeSetName));
10937
+ this.update();
10938
+ } else {
10939
+ this.modifySelection(nodes);
10940
+ }
10674
10941
  });
10675
10942
 
10676
10943
  if (options["reroot"] || options["hide"]) {
10677
- menu_object.append("div").attr("class", "dropdown-divider");
10944
+ menu_object.append("div").attr("class", "phylotree-menu-divider dropdown-divider");
10678
10945
  }
10679
10946
  }
10680
10947
 
10681
10948
  if (options["reroot"]) {
10682
10949
  menu_object
10683
10950
  .append("a")
10684
- .attr("class", "dropdown-item")
10951
+ .attr("class", "phylotree-menu-item dropdown-item")
10685
10952
  .attr("tabindex", "-1")
10686
10953
  .text("Reroot on this node")
10687
10954
  .on("click", d => {
@@ -10694,7 +10961,7 @@
10694
10961
  if (options["hide"]) {
10695
10962
  menu_object
10696
10963
  .append("a")
10697
- .attr("class", "dropdown-item")
10964
+ .attr("class", "phylotree-menu-item dropdown-item")
10698
10965
  .attr("tabindex", "-1")
10699
10966
  .text("Hide this " + (isLeafNode(node) ? "node" : "subtree"))
10700
10967
  .on("click", d => {
@@ -10709,7 +10976,7 @@
10709
10976
  if (hasHiddenNodes(node)) {
10710
10977
  menu_object
10711
10978
  .append("a")
10712
- .attr("class", "dropdown-item")
10979
+ .attr("class", "phylotree-menu-item dropdown-item")
10713
10980
  .attr("tabindex", "-1")
10714
10981
  .text("Show all descendant nodes")
10715
10982
  .on("click", function(d) {
@@ -10748,13 +11015,13 @@
10748
11015
  ];
10749
11016
 
10750
11017
  if (___namespace.some(show_divider_options)) {
10751
- menu_object.append("div").attr("class", "dropdown-divider");
11018
+ menu_object.append("div").attr("class", "phylotree-menu-divider dropdown-divider");
10752
11019
  }
10753
11020
 
10754
11021
  has_user_elements.forEach(function(d) {
10755
11022
  menu_object
10756
11023
  .append("a")
10757
- .attr("class", "dropdown-item")
11024
+ .attr("class", "phylotree-menu-item dropdown-item")
10758
11025
  .attr("tabindex", "-1")
10759
11026
  .text((d[0])(node)) // eslint-disable-line
10760
11027
  .on("click", ___namespace.partial(d[1], node));
@@ -10944,8 +11211,14 @@
10944
11211
  }
10945
11212
  }
10946
11213
 
10947
- if (this._selectionCallback && attr != "tag") {
10948
- this._selectionCallback(this.getSelection());
11214
+ if (attr != "tag") {
11215
+ const selection = this.getSelection();
11216
+ // Call legacy callback for backward compatibility
11217
+ if (this._selectionCallback) {
11218
+ this._selectionCallback(selection);
11219
+ }
11220
+ // Emit event for new event system
11221
+ this.emit('selectionChange', selection);
10949
11222
  }
10950
11223
 
10951
11224
  this.refresh();
@@ -11008,6 +11281,65 @@
11008
11281
  return this;
11009
11282
  }
11010
11283
 
11284
+ /**
11285
+ * Select nodes by their names.
11286
+ *
11287
+ * @param {string[]} names - Array of node names to select.
11288
+ * @returns {this} For chaining.
11289
+ * @example
11290
+ * tree.selectNodes(['HUMAN', 'CHIMP', 'GORILLA']);
11291
+ */
11292
+ function selectNodes(names) {
11293
+ if (!names || !Array.isArray(names) || names.length === 0) {
11294
+ return this;
11295
+ }
11296
+
11297
+ const nodesToSelect = this.phylotree.nodes.descendants()
11298
+ .filter(node => names.includes(node.data.name));
11299
+
11300
+ if (nodesToSelect.length > 0) {
11301
+ this.modifySelection(nodesToSelect, this.selection_attribute_name, false, false, 'true');
11302
+ }
11303
+
11304
+ return this;
11305
+ }
11306
+
11307
+ /**
11308
+ * Deselect nodes by their names.
11309
+ *
11310
+ * @param {string[]} names - Array of node names to deselect.
11311
+ * @returns {this} For chaining.
11312
+ * @example
11313
+ * tree.deselectNodes(['HUMAN']);
11314
+ */
11315
+ function deselectNodes(names) {
11316
+ if (!names || !Array.isArray(names) || names.length === 0) {
11317
+ return this;
11318
+ }
11319
+
11320
+ const nodesToDeselect = this.phylotree.nodes.descendants()
11321
+ .filter(node => names.includes(node.data.name));
11322
+
11323
+ if (nodesToDeselect.length > 0) {
11324
+ this.modifySelection(nodesToDeselect, this.selection_attribute_name, false, false, 'false');
11325
+ }
11326
+
11327
+ return this;
11328
+ }
11329
+
11330
+ /**
11331
+ * Clear all current selection.
11332
+ *
11333
+ * @returns {this} For chaining.
11334
+ * @example
11335
+ * tree.clearSelection();
11336
+ */
11337
+ function clearSelection() {
11338
+ const allNodes = this.phylotree.nodes.descendants();
11339
+ this.modifySelection(allNodes, this.selection_attribute_name, false, false, 'false');
11340
+ return this;
11341
+ }
11342
+
11011
11343
  var menus = /*#__PURE__*/Object.freeze({
11012
11344
  __proto__: null,
11013
11345
  nodeDropdownMenu: nodeDropdownMenu,
@@ -11015,7 +11347,357 @@
11015
11347
  modifySelection: modifySelection,
11016
11348
  getSelection: getSelection,
11017
11349
  selectAllDescendants: selectAllDescendants,
11018
- selectionCallback: selectionCallback
11350
+ selectionCallback: selectionCallback,
11351
+ selectNodes: selectNodes,
11352
+ deselectNodes: deselectNodes,
11353
+ clearSelection: clearSelection
11354
+ });
11355
+
11356
+ /**
11357
+ * Event emitter mixin for phylotree TreeRender
11358
+ * Provides on/off/emit pattern for tree events
11359
+ * @module render/event-emitter
11360
+ */
11361
+
11362
+ /**
11363
+ * Register an event listener
11364
+ * @param {string} eventName - Event name (nodeClick, branchClick, nodeHover,
11365
+ * contextMenu, rendered, selectionChange, collapsed, rerooted)
11366
+ * @param {Function} callback - Handler function
11367
+ * @returns {this} For chaining
11368
+ * @example
11369
+ * tree.on('nodeClick', (node, event) => console.log(node.data.name));
11370
+ * tree.on('selectionChange', (selectedNodes) => updatePanel(selectedNodes));
11371
+ */
11372
+ function on(eventName, callback) {
11373
+ if (!this._eventListeners) {
11374
+ this._eventListeners = {};
11375
+ }
11376
+ if (!this._eventListeners[eventName]) {
11377
+ this._eventListeners[eventName] = [];
11378
+ }
11379
+ this._eventListeners[eventName].push(callback);
11380
+ return this;
11381
+ }
11382
+
11383
+ /**
11384
+ * Remove an event listener
11385
+ * @param {string} eventName - Event name
11386
+ * @param {Function} callback - Handler to remove (must be same reference)
11387
+ * @returns {this} For chaining
11388
+ * @example
11389
+ * const handler = (node) => console.log(node);
11390
+ * tree.on('nodeClick', handler);
11391
+ * tree.off('nodeClick', handler);
11392
+ */
11393
+ function off(eventName, callback) {
11394
+ if (this._eventListeners && this._eventListeners[eventName]) {
11395
+ this._eventListeners[eventName] = this._eventListeners[eventName]
11396
+ .filter(cb => cb !== callback);
11397
+ }
11398
+ return this;
11399
+ }
11400
+
11401
+ /**
11402
+ * Emit an event to all registered listeners
11403
+ * @param {string} eventName - Event name
11404
+ * @param {...*} args - Arguments to pass to listeners
11405
+ * @returns {this} For chaining
11406
+ * @private
11407
+ */
11408
+ function emit(eventName, ...args) {
11409
+ if (this._eventListeners && this._eventListeners[eventName]) {
11410
+ this._eventListeners[eventName].forEach(callback => {
11411
+ try {
11412
+ callback.apply(this, args);
11413
+ } catch (e) {
11414
+ console.error(`Error in ${eventName} event handler:`, e);
11415
+ }
11416
+ });
11417
+ }
11418
+ return this;
11419
+ }
11420
+
11421
+ var eventEmitter = /*#__PURE__*/Object.freeze({
11422
+ __proto__: null,
11423
+ on: on,
11424
+ off: off,
11425
+ emit: emit
11426
+ });
11427
+
11428
+ /**
11429
+ * Multi-set selection management for phylotree
11430
+ * @module render/selection-sets
11431
+ */
11432
+
11433
+ /**
11434
+ * Initialize multi-set selection mode.
11435
+ * Called automatically during render when selection-mode is 'multi-set'.
11436
+ *
11437
+ * @param {Array<{name: string, color: string}>} sets - Array of selection set definitions.
11438
+ * @private
11439
+ */
11440
+ function initializeSelectionSets(sets) {
11441
+ this._selectionSets = {};
11442
+ this._activeSetName = null;
11443
+
11444
+ sets.forEach(set => {
11445
+ this._selectionSets[set.name] = {
11446
+ name: set.name,
11447
+ color: set.color,
11448
+ members: new Set()
11449
+ };
11450
+ });
11451
+
11452
+ // Set first set as active by default
11453
+ if (sets.length > 0) {
11454
+ this._activeSetName = sets[0].name;
11455
+ }
11456
+
11457
+ // Inject CSS for set colors
11458
+ this._injectSetStyles(sets);
11459
+ }
11460
+
11461
+ /**
11462
+ * Inject dynamic CSS styles for selection set colors.
11463
+ *
11464
+ * @param {Array<{name: string, color: string}>} sets - Array of selection set definitions.
11465
+ * @private
11466
+ */
11467
+ function _injectSetStyles(sets) {
11468
+ const styleId = 'phylotree-selection-set-styles';
11469
+ let styleEl = document.getElementById(styleId);
11470
+
11471
+ if (!styleEl) {
11472
+ styleEl = document.createElement('style');
11473
+ styleEl.id = styleId;
11474
+ document.head.appendChild(styleEl);
11475
+ }
11476
+
11477
+ const css = sets.map(set => {
11478
+ const safeName = set.name.replace(/[^a-zA-Z0-9-_]/g, '_');
11479
+ return `
11480
+ .phylotree-set-${safeName} path.branch {
11481
+ stroke: ${set.color} !important;
11482
+ }
11483
+ .phylotree-set-${safeName} .node circle {
11484
+ fill: ${set.color} !important;
11485
+ }
11486
+ .phylotree-set-branch-${safeName} {
11487
+ stroke: ${set.color} !important;
11488
+ }
11489
+ `;
11490
+ }).join('\n');
11491
+
11492
+ styleEl.textContent = css;
11493
+ }
11494
+
11495
+ /**
11496
+ * Set the active selection set. Clicks will add nodes to this set.
11497
+ *
11498
+ * @param {string} name - Name of the set to activate.
11499
+ * @returns {this} For chaining.
11500
+ * @example
11501
+ * tree.setActiveSet('foreground');
11502
+ */
11503
+ function setActiveSet(name) {
11504
+ if (this._selectionSets && this._selectionSets[name]) {
11505
+ this._activeSetName = name;
11506
+ } else {
11507
+ console.warn(`Selection set '${name}' not found`);
11508
+ }
11509
+ return this;
11510
+ }
11511
+
11512
+ /**
11513
+ * Get the currently active selection set name.
11514
+ *
11515
+ * @returns {string|null} Active set name or null if not in multi-set mode.
11516
+ * @example
11517
+ * const activeSet = tree.getActiveSet(); // 'foreground'
11518
+ */
11519
+ function getActiveSet() {
11520
+ return this._activeSetName;
11521
+ }
11522
+
11523
+ /**
11524
+ * Get all members (nodes) of a selection set.
11525
+ *
11526
+ * @param {string} setName - Name of the selection set.
11527
+ * @returns {Node[]} Array of nodes in the set.
11528
+ * @example
11529
+ * const foregroundNodes = tree.getSetMembers('foreground');
11530
+ */
11531
+ function getSetMembers(setName) {
11532
+ if (!this._selectionSets || !this._selectionSets[setName]) {
11533
+ return [];
11534
+ }
11535
+
11536
+ const memberNames = this._selectionSets[setName].members;
11537
+ return this.phylotree.nodes.descendants()
11538
+ .filter(node => memberNames.has(node.data.name));
11539
+ }
11540
+
11541
+ /**
11542
+ * Add a node to a selection set.
11543
+ *
11544
+ * @param {Node|string} node - Node object or node name.
11545
+ * @param {string} setName - Target set name.
11546
+ * @returns {this} For chaining.
11547
+ * @example
11548
+ * tree.addToSet('HUMAN', 'foreground');
11549
+ * tree.addToSet(nodeObject, 'background');
11550
+ */
11551
+ function addToSet(node, setName) {
11552
+ if (!this._selectionSets || !this._selectionSets[setName]) {
11553
+ console.warn(`Selection set '${setName}' not found`);
11554
+ return this;
11555
+ }
11556
+
11557
+ const nodeName = typeof node === 'string' ? node : node.data.name;
11558
+ const nodeObj = typeof node === 'string'
11559
+ ? this.phylotree.getNodeByName(node)
11560
+ : node;
11561
+
11562
+ if (nodeObj) {
11563
+ // Remove from all other sets (mutually exclusive)
11564
+ Object.keys(this._selectionSets).forEach(otherSet => {
11565
+ this._selectionSets[otherSet].members.delete(nodeName);
11566
+ });
11567
+
11568
+ this._selectionSets[setName].members.add(nodeName);
11569
+ nodeObj._selectionSet = setName;
11570
+
11571
+ this.emit('setChange', {
11572
+ action: 'add',
11573
+ set: setName,
11574
+ node: nodeObj,
11575
+ allSets: this._getSetsSummary()
11576
+ });
11577
+
11578
+ this.refresh();
11579
+ this.update();
11580
+ }
11581
+
11582
+ return this;
11583
+ }
11584
+
11585
+ /**
11586
+ * Remove a node from a selection set.
11587
+ *
11588
+ * @param {Node|string} node - Node object or node name.
11589
+ * @param {string} setName - Target set name.
11590
+ * @returns {this} For chaining.
11591
+ * @example
11592
+ * tree.removeFromSet('HUMAN', 'foreground');
11593
+ */
11594
+ function removeFromSet(node, setName) {
11595
+ if (!this._selectionSets || !this._selectionSets[setName]) {
11596
+ return this;
11597
+ }
11598
+
11599
+ const nodeName = typeof node === 'string' ? node : node.data.name;
11600
+ const nodeObj = typeof node === 'string'
11601
+ ? this.phylotree.getNodeByName(node)
11602
+ : node;
11603
+
11604
+ if (this._selectionSets[setName].members.has(nodeName)) {
11605
+ this._selectionSets[setName].members.delete(nodeName);
11606
+ if (nodeObj) {
11607
+ delete nodeObj._selectionSet;
11608
+ }
11609
+
11610
+ this.emit('setChange', {
11611
+ action: 'remove',
11612
+ set: setName,
11613
+ node: nodeObj,
11614
+ allSets: this._getSetsSummary()
11615
+ });
11616
+
11617
+ this.refresh();
11618
+ this.update();
11619
+ }
11620
+
11621
+ return this;
11622
+ }
11623
+
11624
+ /**
11625
+ * Get a summary of all sets and their members.
11626
+ *
11627
+ * @returns {Object} Object with set names as keys and arrays of node names as values.
11628
+ * @private
11629
+ */
11630
+ function _getSetsSummary() {
11631
+ const summary = {};
11632
+ if (this._selectionSets) {
11633
+ Object.keys(this._selectionSets).forEach(setName => {
11634
+ summary[setName] = Array.from(this._selectionSets[setName].members);
11635
+ });
11636
+ }
11637
+ return summary;
11638
+ }
11639
+
11640
+ /**
11641
+ * Handle click in multi-set mode.
11642
+ * Adds the clicked node to the active set.
11643
+ *
11644
+ * @param {Node} node - The clicked node.
11645
+ * @private
11646
+ */
11647
+ function handleMultiSetClick(node) {
11648
+ if (!this._activeSetName || !this._selectionSets) {
11649
+ return;
11650
+ }
11651
+
11652
+ node.data.name;
11653
+ const currentSet = node._selectionSet;
11654
+
11655
+ if (currentSet === this._activeSetName) {
11656
+ // Already in active set, remove it
11657
+ this.removeFromSet(node, this._activeSetName);
11658
+ } else {
11659
+ // Add to active set (removes from other sets automatically)
11660
+ this.addToSet(node, this._activeSetName);
11661
+ }
11662
+ }
11663
+
11664
+ /**
11665
+ * Check if a node belongs to a specific set.
11666
+ *
11667
+ * @param {Node} node - The node to check.
11668
+ * @param {string} setName - The set name to check.
11669
+ * @returns {boolean} True if node is in the set.
11670
+ */
11671
+ function isInSet(node, setName) {
11672
+ if (!this._selectionSets || !this._selectionSets[setName]) {
11673
+ return false;
11674
+ }
11675
+ return this._selectionSets[setName].members.has(node.data.name);
11676
+ }
11677
+
11678
+ /**
11679
+ * Get the set name a node belongs to.
11680
+ *
11681
+ * @param {Node} node - The node to check.
11682
+ * @returns {string|null} The set name or null if not in any set.
11683
+ */
11684
+ function getNodeSet(node) {
11685
+ return node._selectionSet || null;
11686
+ }
11687
+
11688
+ var selectionSets = /*#__PURE__*/Object.freeze({
11689
+ __proto__: null,
11690
+ initializeSelectionSets: initializeSelectionSets,
11691
+ _injectSetStyles: _injectSetStyles,
11692
+ setActiveSet: setActiveSet,
11693
+ getActiveSet: getActiveSet,
11694
+ getSetMembers: getSetMembers,
11695
+ addToSet: addToSet,
11696
+ removeFromSet: removeFromSet,
11697
+ _getSetsSummary: _getSetsSummary,
11698
+ handleMultiSetClick: handleMultiSetClick,
11699
+ isInSet: isInSet,
11700
+ getNodeSet: getNodeSet
11019
11701
  });
11020
11702
 
11021
11703
  // replacement for d3.functor
@@ -11038,6 +11720,7 @@
11038
11720
  this._nodeLabel = this.defNodeLabel;
11039
11721
  this.svg = null;
11040
11722
  this._selectionCallback = null;
11723
+ this._eventListeners = {};
11041
11724
  this.scales = [1, 1];
11042
11725
  this.size = [1, 1];
11043
11726
  this.fixed_width = [14, 30];
@@ -11106,7 +11789,13 @@
11106
11789
  "show-labels": true,
11107
11790
  "node-styler": null,
11108
11791
  "edge-styler": null,
11109
- "node-span": null
11792
+ "node-span": null,
11793
+ "responsive": false,
11794
+ "preserve-aspect-ratio": "xMidYMid meet",
11795
+ "selection-mode": "single",
11796
+ "selection-sets": [],
11797
+ "initial-selection": [],
11798
+ "initial-sets": {}
11110
11799
  };
11111
11800
 
11112
11801
  this.ensure_size_is_in_px = function(value) {
@@ -11148,6 +11837,37 @@
11148
11837
  this.initializeEdgeLabels();
11149
11838
  this.update();
11150
11839
  d3PhylotreeAddEventListener();
11840
+
11841
+ // Initialize multi-set selection if configured
11842
+ if (this.options["selection-mode"] === "multi-set" &&
11843
+ this.options["selection-sets"].length > 0) {
11844
+ this.initializeSelectionSets(this.options["selection-sets"]);
11845
+ }
11846
+
11847
+ // Apply initial selection if configured
11848
+ this.applyInitialSelection();
11849
+ }
11850
+
11851
+ /**
11852
+ * Apply initial selection from render options.
11853
+ * @private
11854
+ */
11855
+ applyInitialSelection() {
11856
+ // Single selection mode
11857
+ if (this.options["initial-selection"] &&
11858
+ this.options["initial-selection"].length > 0) {
11859
+ this.selectNodes(this.options["initial-selection"]);
11860
+ }
11861
+
11862
+ // Multi-set mode
11863
+ if (this.options["selection-mode"] === "multi-set" &&
11864
+ this.options["initial-sets"]) {
11865
+ Object.entries(this.options["initial-sets"]).forEach(([setName, nodeNames]) => {
11866
+ nodeNames.forEach(nodeName => {
11867
+ this.addToSet(nodeName, setName);
11868
+ });
11869
+ });
11870
+ }
11151
11871
  }
11152
11872
 
11153
11873
  pad_height() {
@@ -11215,9 +11935,22 @@
11215
11935
  .select("svg")
11216
11936
  .remove();
11217
11937
 
11218
- this.svg = create$1("svg")
11219
- .attr("width", this.width)
11220
- .attr("height", this.height);
11938
+ this.svg = create$1("svg");
11939
+
11940
+ if (this.options["responsive"]) {
11941
+ // Responsive mode: use viewBox for scaling
11942
+ this.svg
11943
+ .attr("viewBox", `0 0 ${this.width} ${this.height}`)
11944
+ .attr("preserveAspectRatio", this.options["preserve-aspect-ratio"])
11945
+ .style("width", "100%")
11946
+ .style("height", "auto")
11947
+ .style("max-width", "100%");
11948
+ } else {
11949
+ // Fixed mode: explicit width/height
11950
+ this.svg
11951
+ .attr("width", this.width)
11952
+ .attr("height", this.height);
11953
+ }
11221
11954
 
11222
11955
  this.set_size([this.height, this.width]);
11223
11956
 
@@ -11454,6 +12187,9 @@
11454
12187
  this.svg.call(zoom$1);
11455
12188
  }
11456
12189
 
12190
+ // Emit rendered event
12191
+ this.emit('rendered');
12192
+
11457
12193
  return this;
11458
12194
  }
11459
12195
 
@@ -12364,6 +13100,8 @@
12364
13100
  ___namespace.extend(TreeRender.prototype, events);
12365
13101
  ___namespace.extend(TreeRender.prototype, menus);
12366
13102
  ___namespace.extend(TreeRender.prototype, opt);
13103
+ ___namespace.extend(TreeRender.prototype, eventEmitter);
13104
+ ___namespace.extend(TreeRender.prototype, selectionSets);
12367
13105
 
12368
13106
  function resortChildren(comparator, start_node, filter) {
12369
13107
  // ascending
@@ -12422,6 +13160,28 @@
12422
13160
  * - boostrap_values
12423
13161
  * - type - format type
12424
13162
  * @returns {Phylotree} phylotree - itself, following the builder pattern.
13163
+ * @example
13164
+ * // Create a simple phylotree from a Newick string
13165
+ * const newick = "((A:0.1,B:0.2):0.05,C:0.3)";
13166
+ * const tree = new Phylotree(newick);
13167
+ *
13168
+ * @example
13169
+ * // Create a phylotree with options
13170
+ * const tree = new Phylotree(newick, {
13171
+ * bootstrap_values: true,
13172
+ * type: "newick"
13173
+ * });
13174
+ *
13175
+ * @example
13176
+ * // Create from hierarchical JSON
13177
+ * const jsonTree = {
13178
+ * name: "root",
13179
+ * children: [
13180
+ * { name: "A", length: 0.1 },
13181
+ * { name: "B", length: 0.2 }
13182
+ * ]
13183
+ * };
13184
+ * const tree = new Phylotree(jsonTree);
12425
13185
  */
12426
13186
  let Phylotree = class {
12427
13187
  constructor(nwk, options = {}) {
@@ -12551,7 +13311,7 @@
12551
13311
  return JSON.stringify(node_array);
12552
13312
  }
12553
13313
 
12554
- /*
13314
+ /**
12555
13315
  * Traverse the tree in a prescribed order, and compute a value at each node.
12556
13316
  *
12557
13317
  * @param {Function} callback A function to be called on each node.
@@ -12560,6 +13320,31 @@
12560
13320
  * @param {Function} backtrack ; if provided, then at each node n, backtrack (n) will be called,
12561
13321
  and if it returns TRUE, traversal will NOT continue past into this
12562
13322
  node and its children
13323
+ * @example
13324
+ * // Count all nodes in the tree
13325
+ * let nodeCount = 0;
13326
+ * tree.traverse_and_compute(function(node) {
13327
+ * nodeCount++;
13328
+ * });
13329
+ * console.log(`Tree has ${nodeCount} nodes`);
13330
+ *
13331
+ * @example
13332
+ * // Find maximum depth in post-order traversal
13333
+ * tree.traverse_and_compute(function(node) {
13334
+ * if (!node.children) {
13335
+ * node.depth = 0;
13336
+ * } else {
13337
+ * node.depth = Math.max(...node.children.map(c => c.depth)) + 1;
13338
+ * }
13339
+ * }, "post-order");
13340
+ *
13341
+ * @example
13342
+ * // Add custom attributes to leaf nodes only
13343
+ * tree.traverse_and_compute(function(node) {
13344
+ * if (!node.children) {
13345
+ * node.data.isLeaf = true;
13346
+ * }
13347
+ * });
12563
13348
  */
12564
13349
  traverse_and_compute(callback, traversal_type, root_node, backtrack) {
12565
13350
  traversal_type = traversal_type || "post-order";
@@ -12604,7 +13389,42 @@
12604
13389
  this.nodes = json;
12605
13390
  }
12606
13391
 
12607
- // Warning : Requires DOM!
13392
+ /**
13393
+ * Render the phylotree to a DOM element. Warning: Requires DOM!
13394
+ *
13395
+ * @param {Object} options - Rendering options including container, dimensions, and styling
13396
+ * @returns {TreeRender} The display object for further customization
13397
+ * @example
13398
+ * // Basic rendering to a div element
13399
+ * const tree = new Phylotree(newick);
13400
+ * tree.render({
13401
+ * container: "#tree-container",
13402
+ * width: 800,
13403
+ * height: 600
13404
+ * });
13405
+ *
13406
+ * @example
13407
+ * // Render with custom styling options
13408
+ * const display = tree.render({
13409
+ * container: d3.select("#my-tree"),
13410
+ * width: 1000,
13411
+ * height: 800,
13412
+ * 'left-right-spacing': 'fit-to-size',
13413
+ * 'top-bottom-spacing': 'fit-to-size',
13414
+ * 'show-scale': true,
13415
+ * selectable: true,
13416
+ * collapsible: true
13417
+ * });
13418
+ *
13419
+ * @example
13420
+ * // Render radial tree layout
13421
+ * tree.render({
13422
+ * container: "#radial-tree",
13423
+ * layout: "radial",
13424
+ * width: 600,
13425
+ * height: 600
13426
+ * });
13427
+ */
12608
13428
  render(options) {
12609
13429
  this.display = new TreeRender(this, options);
12610
13430
  return this.display;
@@ -12620,6 +13440,7 @@
12620
13440
  Phylotree.prototype.normalizeBranchLengths = normalize;
12621
13441
  Phylotree.prototype.scaleBranchLengths = scale;
12622
13442
  Phylotree.prototype.getNewick = getNewick;
13443
+ Phylotree.prototype.getTaggedNewick = getTaggedNewick;
12623
13444
  Phylotree.prototype.resortChildren = resortChildren;
12624
13445
  Phylotree.prototype.setBranchLength = setBranchLength;
12625
13446
  Phylotree.prototype.maxParsimony = maxParsimony;