Closed JoseCorCab closed 4 months ago
Hi Jose,
The dendrogram you provided:
ape::write.tree(ape::read.tree(text ="((((9,14):2.7,((2,10):1.9,(4,8):2.4):3.6):4.0,((1,11):2.7,((7,12):2.8,((0,3):2.6,(5,(6,13):2.3):3.0):3.4):4.1):4.6):5.8,((21,((30,(16,18):2.2):2.4,(35,39):2.8):3.3):3.7,((37,(26,33):2.3):2.6,(((24,(32,(19,27):1.9):3.0):3.2,((22,38):2.0,(28,31):2.2):3.5):3.9,((20,36):3.0,((25,34):2.7,((15,29):1.9,(17,23):1.9):3.5):3.9):4.3):4.8):4.9):6.2):8.7;"))
DOES NOT match the heatmap in the graph. It has more nodes. There are no nodes for Ids 32-39 in the heatmap. It is difficult to implement a height for terminal nodes without a proper dendrogram.
Dear neuhausi,
Sorry for de confusion, The dendrogram I provided is from the example used in your API https://canvasxpress.org/api/dendrograms.html#varDendrogramNewick "((((9,14):2.7,((2,10):1.9,(4,8):2.4):3.6):4.0,((1,11):2.7,((7,12):2.8,((0,3):2.6,(5,(6,13):2.3):3.0):3.4):4.1):4.6):5.8,((21,((30,(16,18):2.2):2.4,(35,39):2.8):3.3):3.7,((37,(26,33):2.3):2.6,(((24,(32,(19,27):1.9):3.0):3.2,((22,38):2.0,(28,31):2.2):3.5):3.9,((20,36):3.0,((25,34):2.7,((15,29):1.9,(17,23):1.9):3.5):3.9):4.3):4.8):4.9):6.2):8.7" The aim of this is to show you that the format used in the example lacks terminal leaf weights. Taken from this plot:
The dendrogram that corresponds to the heatmap in my example is:
"(((2:0.000358295,3:0.000358295):0.00654867,(4:0.00350737,((5:0.000716589,6:0.000716589):0.0027152,(7:0.00436671,(8:0.00244088,(9:0.00201541,(10:0.00152275,(11:0.000537442,(12:0.000358295,13:0.000358295):0.000179147):0.00098531):0.000492655):0.000425475):0.00192583):-0.000934925):7.55778e-05):0.0033996):0.000200688,(((14:0.00161233,15:0.00161233):0.00223934,((16:0.00125403,17:0.00125403):0.00232891,((18:0.000716589,19:0.000716589):0.00152275,(20:0.00107488,21:0.00107488):0.00116446):0.0013436):0.000268721):0.00217916,((22:0.00214977,23:0.00214977):0.00181387,(24:0.00295593,(((1:0.000358295,25:0.000358295):0,26:0.000358295):0.00160113,(27:0.00143318,(28:0.000716589,((29:0.000358295,30:0.000358295):0.000179147,31:0.000537442):0.000179147):0.000716589):0.000526245):0.000996507):0.0010077):0.00206719):0.00107683);"
This dendrogram generates this plot.
Best regards,
Jose
Just to be clear. The request is to implement weights for terminal nodes?
Yes, ideally in the format specified here: https://en.wikipedia.org/wiki/Newick_format
I implemented that in the new version but the specifications does NOT account for negative numbers: Please see your Newick string: ....(12:0.000358295,13:0.000358295):0.000179147):0.00098531):0.000492655):0.000425475):0.00192583):-0.000934925):7.55778e-05) ...
I will take the maximum value of 0 and the specified distance
That's perfect, I have tested the update with all my examples and it works perfectly! Thanks you.
Can you please close the issue. Thank you
Hi Jose, Another user complaint about the new behavior for the newick parser so I needed to add a new parameter to honor the height when the newick is provided. Starting version 50.0 you will need to use varDendrogramUseHeight or smpDendrogramUseHeight to maintain the current behavior. I also added a hang parameter to draw the lines of the branches in the terminal nodes (varDendrogramHang and smpDendrogramHang) which is true by default.
smpDendrogramUseHeight: true,
smpDendrogramHang: true
smpDendrogramUseHeight: true,
smpDendrogramHang: false
smpDendrogramUseHeight: false,
smpDendrogramHang: false
The default parameters would look like this (like in previous versions):
smpDendrogramUseHeight: false,
smpDendrogramHang: true
Dear neuhausi, Thanks for letting me know. These new options give great power and flexibility to the incorporation of external dendrograms. I have adapted my code, and it is now working and tested with version 50.0. I am closing the issue.
Thank you
Get Outlook for iOShttps://aka.ms/o0ukef
From: José Córdoba Caballero @.> Sent: Wednesday, June 5, 2024 10:15:35 AM To: neuhausi/canvasXpress @.> Cc: Isaac Neuhaus @.>; State change @.> Subject: Re: [neuhausi/canvasXpress] Heatmap dendrogram do not recognizes branch length from external Newick (Issue #157)
Dear neuhausi, Thanks for letting me know. These new options give great power and flexibility to the incorporation of external dendrograms. I have adapted my code, and it is now working and tested with version 50.0. I am closing the issue.
— Reply to this email directly, view it on GitHubhttps://github.com/neuhausi/canvasXpress/issues/157#issuecomment-2150121936, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAB6HS6SBHQHNB4R3OILNXTZF4MQPAVCNFSM6AAAAABIDJS6WSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJQGEZDCOJTGY. You are receiving this because you modified the open/close state.Message ID: @.***>
Dear neuhausi,
I hope this message finds you well.
I am trying to import a precomputed dendrogram into a heatmap. I computed the dendrogram using hclust and then converted it to a Newick/New Hampshire formatted string using ape::as.phylo and ape::write.tree.
I provided this string to varDendrogramNewick/smpDendrogramNewick, and while the dendrogram is displayed, the plot seems to ignore the branch lengths. I am attaching the CanvasXpress plot and the same dendrogram, which takes the branch lengths into account, for your reference.
While working with the example in the API, I noticed that the Newick dendrogram used there does not include weights or lengths for the terminal branches. Specifically, there are no ":value" entries after any leaf node index. When I load and write the dendrogram with ape, I get NaN values.
`ape::write.tree(ape::read.tree(text ="((((9,14):2.7,((2,10):1.9,(4,8):2.4):3.6):4.0,((1,11):2.7,((7,12):2.8,((0,3):2.6,(5,(6,13):2.3):3.0):3.4):4.1):4.6):5.8,((21,((30,(16,18):2.2):2.4,(35,39):2.8):3.3):3.7,((37,(26,33):2.3):2.6,(((24,(32,(19,27):1.9):3.0):3.2,((22,38):2.0,(28,31):2.2):3.5):3.9,((20,36):3.0,((25,34):2.7,((15,29):1.9,(17,23):1.9):3.5):3.9):4.3):4.8):4.9):6.2):8.7;"))
[1] "((((9:NaN,14:NaN):2.7,((2:NaN,10:NaN):1.9,(4:NaN,8:NaN):2.4):3.6):4,((1:NaN,11:NaN):2.7,((7:NaN,12:NaN):2.8,((0:NaN,3:NaN):2.6,(5:NaN,(6:NaN,13:NaN):2.3):3):3.4):4.1):4.6):5.8,((21:NaN,((30:NaN,(16:NaN,18:NaN):2.2):2.4,(35:NaN,39:NaN):2.8):3.3):3.7,((37:NaN,(26:NaN,33:NaN):2.3):2.6,(((24:NaN,(32:NaN,(19:NaN,27:NaN):1.9):3):3.2,((22:NaN,38:NaN):2,(28:NaN,31:NaN):2.2):3.5):3.9,((20:NaN,36:NaN):3,((25:NaN,34:NaN):2.7,((15:NaN,29:NaN):1.9,(17:NaN,23:NaN):1.9):3.5):3.9):4.3):4.8):4.9):6.2):8.7;"`
When I substitute the original dendrogram with the one returned by ape in the JS Fiddle, I get the same behavior that I have seen in my code: the branch lengths are ignored. I suppose this is due to inconsistencies in the different possibilities of the Newick format, but I have read in the literature that the Newick format returned by ape is the most commonly used.
Could you please provide guidance on how to ensure that the branch lengths are correctly represented in the CanvasXpress plot? Any assistance you can offer would be greatly appreciated.
Thank you very much for your time and help.
Best regards,
Jose