veg / phylotree.js

Interactive viewer of phylogenetic trees
http://phylotree.hyphy.org
MIT License
169 stars 78 forks source link

Node IDs are undefined #442

Open Mirekium opened 1 year ago

Mirekium commented 1 year ago

Hi, I have a problem with the "id" on the tree when I use phylotree.js v 1.4.0 and D3.js v 6, I can't get defined "id" of the nodes they whether internal or leaf, you can see the image, all the "id" are "node-undefined".

I haven't had a problem with phylotree.js v 0.1.6 and D3.js v 3, Is there a way to make these "ids" appear? here is my code:


    let tree;
    function drawTree(newickSource) { 
        const height = innerHeight * 0.97;
        const width = innerWidth * 0.253;
        tree = new phylotree.phylotree(newickSource);       
        global_tree = tree;

        const renderOptions = {
          container:"#svg", 
          height:height, 
          width:width,
          "left-right-spacing": "fit-to-size",
          "top-bottom-spacing": "fit-to-size",
          selectable: true,
          "restricted-selectable": false,
          "binary-selectable": false,
          collapsible: false,
          transitions: false,
          "show-scale": false,
          "align-tips": false,
          zoom: false,
          reroot: false,
          hide: false,
          brush: false,
          branches: "step",
          "label-nodes-with-name": true,
          "internal-names": true,
          "node-styler": nodeStyler,
          "edge-styler": edgeStyler
        };

        tree.render(renderOptions);

       $(tree.display.container).append(tree.display.show());

      };

capture-tree

stevenweaver commented 1 year ago

Dear @Mirekium,

Do you happen to have an example Newick tree that I can reproduce the issue with?

Best, Steven

Mirekium commented 1 year ago

For the moment, I am currently using phylotree.js with genealogical data, here is my data: ((((((((('Al Dhabab','Jaafar','Al Adhbat','Amru','Abu Bakr')'Kilab',('Uqayl','Quchair','Jeda')'Kaab','Hilal','Amer Essoghra','Numair')'Amir',('Jusham','Nasr','Saad','Thaqif')'Upper Hawazin')'Hawazin',(('Morra','Thalaba','Fazara')'Dhubyan','Abs','Achja','Abdallah ibn Ghatafan')'Ghatafan','Jadila','Bahila','Ghani','Sulaym','Mouhareb')'Qays',((('Layth','Damrah','Doal')'Abd Menat','Quraysh','Malken','Malek')'Kinanah',(('Saad','Imru Al-Qays')'Saad',('Malek','Yarboue')'Handala','Amru','Arrabeb')'Tamim','Asad','Hudhayl','Muzaina','Khuzaah_')'Khondof')'Mudar',('Bakr','Taghlib','Abdul Qays','Hanifa','Anz')'Rabia')'Maad','Akk')'Adnan',(((('Kalb','Al-Qayn','Udhrah','Bali','Majid','Khulan Qudaa','Tanukh','Juhaynah','Al-Mahra','Nahd','Bahra')'Quodaa','Al-Humaisa')'Himyar')'Sabaa',(('Hamdan',('Khatham','Bajila')'Anmar',('Azd Assarat','Azd Oman','Ghassen','Al-Aws - Al-Khazraj','Khuzaah')'Azd')'Malek',('Al-Achar','Khulan El-Alya','Kindah','Madhhij','Tayy','Judham','Lakhm','Amilah')'Orayb')'Kahlan')'Qahtan')' ')'Arabs'

stevenweaver commented 1 year ago

Dear @Mirekium,

Do you have the nodeStyler code? We don't typically set an id for each node, so I'm curious if you are trying to do that with your code.

Best, Steven

Mirekium commented 1 year ago

It seems that D3.js version 6 does not allow you to create "id" of the nodes unlike D3.js version 3. As you see, my project is phylogeographic even if I currently use now genealogical data, the "ids" of the nodes are therefore essential for my project. If there is no solution I stay on D3.js version 3.