Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node sizes/color set to only zero #61

Open
MauriAndresMU1313 opened this issue Aug 31, 2022 · 2 comments
Open

Node sizes/color set to only zero #61

MauriAndresMU1313 opened this issue Aug 31, 2022 · 2 comments

Comments

@MauriAndresMU1313
Copy link

I have a tree file and a data frame that I use to create a phylogenetic tree with customized labels.
Here is my tree in Newick format with here node support:

#newick_cluster_4 = "(BCM92732.1:0.7685029303,((VTR99890.1:0.4826415409,(QEL17956.1:0.2862178948,AMV31440.1:0.4550572636)63.7/99:0.0971311784)95.5/100:0.1795637351,QVL29850.1:0.6975169956)98.6/100:0.2293084866,(((((QOV88855.1:0.8558129122,(CAD73141.1:0.3008165189,(QEG23589.1:0.3933009609,QDT05639.1:0.4379373270)71.8/98:0.0754352804)100/100:0.4457016912)27.1/13:0.0732908440,(QDU83071.1:1.2112768519,ALS34740.1:1.3915765148)86.1/85:0.1640289509)89.3/17:0.0940172822,((((((((((((QDV28174.1:0.6295593021,(QDV27814.1:0.4353988863,QDV62751.1:0.6123586065)97.6/100:0.2027746774)15.6/54:0.0719348404,AQT67197.1:0.5341720625)95.1/96:0.1476151400,((((QQL50302.1:0.4738311866,ACU03914.1:0.5933967390)99.7/100:0.3235094734,AYQ36531.1:0.5161841949)88.8/97:0.1063020966,QCX38072.1:0.5663045894)84.1/84:0.0635036223,(CAZ95099.1:0.5457493858,ASO04237.1:0.5561514804)91.5/89:0.1125239173)99.7/96:0.2677374357)89/88:0.0933869161,AQQ70479.1:0.6401124885)45.7/76:0.0673016016,((QDU69490.1:0.7709891183,QDS98805.1:0.5121905785)75.4/98:0.1410971710,QDT75624.1:0.8314702614)92.7/87:0.1555272826)97.8/92:0.1575812471,((((QDU38612.1:0.4385645115,(QXD33910.1:0.2479098491,QXD26134.1:0.3293661971)100/100:0.4813458936)99.8/100:0.3951966866,AQQ70473.1:1.0081096306)87.3/95:0.1328647306,((ARN56175.1:0.5938118896,AQQ09113.1:0.7023530184)31/94:0.0976014373,AQQ70481.1:0.6166516153)99.5/100:0.2930393386)93.7/85:0.1276708020,(((((QJB38038.1:0.4584921092,QEC78088.1:1.4242071972)80.3/96:0.2820687588,(QEC52400.1:0.3427898720,AEV96958.1:0.4055943959)86.6/99:0.1149541603)97.6/97:0.2016385238,AWI09673.1:0.6998345970)65/71:0.0320295308,(AEL27516.1:0.1677751137,AKP53111.1:0.1701471235)100/100:0.4703047274)94/96:0.1127363900,(((UBM33850.1:0.1163296130,QDU73633.1:0.1147967927)100/100:0.5753397957,QDU60405.1:0.5511690603)96.8/100:0.1716458861,((UBM58675.1:0.3792865116,QGY44258.1:0.1873872216)63/97:0.1356016071,(ULB34471.1:0.2962247924,SCM55950.1:0.4240064384)72.6/100:0.0781211253)100/100:0.7388842010)92.7/83:0.1018432955)98.1/85:0.1351038866)32.6/73:0.0466820775)98.6/78:0.1921367927,((((((QDS98827.1:1.4809458708,BDE91655.1:2.0455125718)48.5/94:0.1911637321,AWT60963.1:1.2993440517)83.6/77:0.1937548051,CAD7278645.1:1.6845843821)70.3/76:0.0863454245,ULL13658.1:0.7472402295)93.4/74:0.1297773768,(QDU29801.1:0.9537321556,QDU94646.1:0.9383580874)99.2/99:0.3170806023)94.9/72:0.1106469948,((((QDU26291.1:0.5682601165,QDU95146.1:0.5989854412)86/98:0.1613665837,(AIF01494.1:0.8551774000,(QDT38819.1:1.0388257719,QDU93959.1:1.0428698742)57.8/81:0.2120100415)84.8/82:0.0825384585)99.6/91:0.2377047601,(((BCS37145.1:0.4500351589,ABJ81207.1:0.5066945697)97.9/100:0.2943250568,QOY90981.1:0.7525007333)85.6/95:0.1376275141,AGA27092.1:0.7081717802)89.1/88:0.1019201752)69.8/33:0.0590656851,((QEL13168.1:0.3158342410,VIP09812.1:0.3121643336)100/100:0.3460450448,((ASV75391.1:0.9677689844,VTS04048.1:0.7201248884)57.8/82:0.1323101488,BCS34238.1:0.7654831448)43/32:0.0643923916)89/34:0.0804009365)87.8/46:0.0638171673)90.6/45:0.0769634491)86.2/38:0.0390481083,((((QGQ21444.1:0.2066356098,(QDT89242.1:0.1591031620,QEG16826.1:0.1487248978)100/100:0.2529138728)53.9/98:0.0474215100,(QDV50699.1:0.1002962443,QDT97753.1:0.1812827716)90.6/100:0.0683278219)100/100:0.5499584461,(QUE49644.1:0.3779995881,QJE95126.1:0.4817557468)100/100:0.8365663775)94/65:0.1613925624,((((ARN56174.1:1.1091064473,(SEH72311.1:0.5542842767,QDT09869.1:1.1981073880)99.7/100:0.6023682907)92.5/95:0.1975271951,(((UBD60394.1:0.5461066957,BDE91651.1:1.2406803435)96.1/96:0.2628804163,((BBA15866.1:0.4612785296,(QEH43526.1:0.7423722501,(((((UGU17416.1:0.4960121514,((QDM12169.1:0.0979750674,ANU58084.1:0.1176625259)100/100:0.3668006428,ULB36064.1:0.3574632826)99.9/100:0.3523019585)84.7/100:0.1263505464,QNL51687.1:0.7967088344)92.4/100:0.1478341352,AHF16456.1:0.9789627213)98.9/100:0.2618727096,SDB58825.1:1.0139659875)83.8/88:0.0738227830,(QEC45250.1:0.6085212651,QJB38037.1:0.6266805242)5.41/59:0.0883333581)34.1/83:0.0573510646)91.9/90:0.1185661136)76.9/90:0.1091171910,UAY56099.1:0.9839661692)98/98:0.2479118963)23.2/86:0.0678674510,(ASM67226.1:0.5801258567,ANU64080.1:1.2341369628)100/100:0.8360322592)49.9/89:0.0959092110)95.5/88:0.1342700442,(((ULL13659.1:0.3407878850,(ANY72720.1:0.1301234475,AYB46155.1:0.1294206237)99.9/100:0.2538038430)100/100:0.7414644349,(AQQ70483.1:0.7073724473,ARN56176.1:0.6265723413)100/100:0.5577586764)97.9/99:0.2581524524,QDS98806.1:1.0902735478)93.8/96:0.2052767841)0/18:0.0000022870,(((QDU56027.1:0.4612460752,QDT09447.1:0.4229685728)99.9/100:0.3319571889,QXD33075.1:0.7150562208)80.2/99:0.0891048164,QDT14405.1:2.3683380432)90.7/94:0.1421068447)97.1/65:0.0942286775)85.6/42:0.0328863572)99/90:0.2074630440,(((AQT68188.1:1.0532854870,AQQ70495.1:1.0846441184)98.6/100:0.3739847455,(AWI08349.1:0.6790625143,QIF01542.1:0.8509272304)100/100:0.9684655326)44.7/88:0.0586403786,SDS49230.1:1.0657885791)94.4/85:0.1680257749)49.4/58:0.0691008214,(((QEH38844.1:0.8281473625,ASV74657.1:0.5576661370)99.7/100:0.6605748736,AVM44867.1:1.9385545068)75.4/96:0.2793091518,QFU75447.1:2.0173856949)79.5/91:0.1927309878)99.8/100:0.4360312648,ARU40244.1:1.5938152237)80/15:0.0617139118,(((QDT51073.1:0.3896972044,QDU78830.1:0.8359150210)99.8/100:0.5463869449,QDT62708.1:1.2818814010)89.2/98:0.2513630493,QQL44735.1:1.5604912079)92.2/86:0.2579333772)90.6/15:0.0959879745)84.4/27:0.1077456585,(QDS99083.1:0.2741935591,QDS99096.1:0.3601791257)100/100:0.9462957039)91.8/93:0.1473784614,((AYR29523.1:0.0817798962,QWO86812.1:0.0484772316)99.6/100:0.3088630733,SEH94018.1:0.3226403167)100/100:1.2685991620)82/98:0.1033294428);"

Here the data frame (only a part of the df):

ID	Gender	Belongs
BCM92732.1	Abditibacteriota	0
VTR99890.1	Tuwongella	0
QEL17956.1	Limnoglobus	0
AMV31440.1	Pirellula	0
...

I´m using this line of code to generate the tree, everything is good except for the node support.

# Node colors
colors = ['red' if ((i) == '100.0') else 'grey' for i in tre.get_node_values('support', 1, 0)]
sizes = [10 if i else 0 for i in tre.get_node_values('support', 1, 0)]

#### Now, drawing the new version of the tree
tre2.draw(
  tip_labels_align=True,
  node_sizes=sizes,
  node_colors=colors,
  tip_labels=newNodnames,
  tip_labels_colors=newColors,
  width=1200, height=2000,
  node_labels='support',
  edge_style={
    "stroke": "darkgrey",
    "stroke-width": 3,
  },
);

Here is a part of the tree where every node has a value of zero, I don´t understand why.

Screen Shot 2022-08-31 at 13 25 45

Any suggestion to fix that?

@eaton-lab
Copy link
Owner

Hi @MauriAndresMU1313 ,

This has to do with the unusual formatting of the newick string. It lists the support values as fractions (e.g., '99/100') instead the more common representation as a digit or decimal (e.g., 99 or 0.99). The toytree.tree parsing function recognizes that these values are not numeric and thus interprets and stores them as internal node names rather than supports.

Do you mind if I ask what software was used to generate the newick string?

@eaton-lab
Copy link
Owner

Here is a hack that should work for now. The default newick parsing function will store the support values as 'name's, and then you can extract the info from names and store it as 'support' attributes on nodes using a custom function.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants