13
13
import tszip
14
14
import numpy as np
15
15
import pandas as pd
16
+
16
17
# TODO where do we use this? This is a *great* example of why not to use
17
18
# this style, because we have loads of variables called "tree" in this file.
18
19
from sklearn import tree
@@ -326,7 +327,6 @@ def __init__(self, ts, show_progress=True, pango_source="Viridian_pangolin"):
326
327
self .recombinants = get_recombinants (ts )
327
328
self .nodes_max_descendant_samples = max_descendant_samples (ts )
328
329
self .nodes_date = np .zeros (ts .num_nodes , dtype = "datetime64[D]" )
329
- self .nodes_submission_date = np .zeros (ts .num_nodes , dtype = "datetime64[D]" )
330
330
self .nodes_num_masked_sites = np .zeros (ts .num_nodes , dtype = np .int32 )
331
331
self .nodes_metadata = {}
332
332
iterator = tqdm .tqdm (
@@ -348,7 +348,6 @@ def __init__(self, ts, show_progress=True, pango_source="Viridian_pangolin"):
348
348
if node .is_sample ():
349
349
self .strain_map [md ["strain" ]] = node .id
350
350
self .nodes_date [node .id ] = md ["date" ]
351
- self .nodes_submission_date [node .id ] = md ["date_submitted" ]
352
351
pango = md .get (pango_source , "unknown" )
353
352
self .pango_lineage_samples [pango ].append (node .id )
354
353
if "sc2ts" in md :
@@ -362,8 +361,6 @@ def __init__(self, ts, show_progress=True, pango_source="Viridian_pangolin"):
362
361
self .ts .nodes_time [node .id ]
363
362
)
364
363
365
- self .nodes_submission_delay = self .nodes_submission_date - self .nodes_date
366
-
367
364
self .sites_num_masked_samples = np .zeros (self .ts .num_sites , dtype = int )
368
365
if ts .table_metadata_schemas .site .schema is not None :
369
366
for site in ts .sites ():
@@ -393,7 +390,6 @@ def __init__(self, ts, show_progress=True, pango_source="Viridian_pangolin"):
393
390
# # Corresponding sample-set names for this array
394
391
# self.pango_lineage_keys = np.array(list(self.pango_lineage_samples.keys()))
395
392
396
-
397
393
def _compute_mutation_stats (self ):
398
394
ts = self .ts
399
395
@@ -511,7 +507,6 @@ def summary(self):
511
507
512
508
data = [
513
509
("latest_sample" , latest_sample ),
514
- ("max_submission_delay" , np .max (self .nodes_submission_delay [samples ])),
515
510
("samples" , self .ts .num_samples ),
516
511
("nodes" , self .ts .num_nodes ),
517
512
("mc_nodes" , mc_nodes ),
@@ -622,7 +617,6 @@ def _node_summary(self, u, child_mutations=True):
622
617
"children" : np .sum (self .ts .edges_parent == u ),
623
618
"descendants" : self .nodes_max_descendant_samples [u ],
624
619
"date" : self .nodes_date [u ],
625
- "delay" : self .nodes_submission_delay [u ],
626
620
"qc" : qc ,
627
621
** self ._node_mutation_summary (u , child_mutations = child_mutations ),
628
622
}
@@ -1547,7 +1541,13 @@ def sort_mutation_label(s):
1547
1541
except ValueError :
1548
1542
if s [0 ] == "$" :
1549
1543
# matplotlib mathtext - remove the $ and the formatting
1550
- s = s .replace ("$" , "" ).replace (r"\bf" , "" ).replace ("\it" , "" ).replace ("{" , "" ).replace ("}" , "" )
1544
+ s = (
1545
+ s .replace ("$" , "" )
1546
+ .replace (r"\bf" , "" )
1547
+ .replace ("\it" , "" )
1548
+ .replace ("{" , "" )
1549
+ .replace ("}" , "" )
1550
+ )
1551
1551
try :
1552
1552
return float (s [1 :- 1 ])
1553
1553
except ValueError :
@@ -1572,7 +1572,14 @@ def sort_mutation_label(s):
1572
1572
if exterior_edge_len is None :
1573
1573
exterior_edge_len = 0.4
1574
1574
1575
- if show_descendant_samples not in {"samples" , "tips" , "sample_tips" , "all" , "" , False }:
1575
+ if show_descendant_samples not in {
1576
+ "samples" ,
1577
+ "tips" ,
1578
+ "sample_tips" ,
1579
+ "all" ,
1580
+ "" ,
1581
+ False ,
1582
+ }:
1576
1583
raise ValueError (
1577
1584
"show_descendant_samples must be one of 'samples', 'tips', 'sample_tips', 'all', or '' / False"
1578
1585
)
@@ -1616,7 +1623,7 @@ def sort_mutation_label(s):
1616
1623
if show :
1617
1624
s = ti .nodes_max_descendant_samples [u ]
1618
1625
if node .is_sample ():
1619
- s -= 1 # don't count self
1626
+ s -= 1 # don't count self
1620
1627
if s > 0 :
1621
1628
nodelabels [u ].append (f"+{ s } { 'samples' if s > 1 else 'sample' } " )
1622
1629
@@ -1675,14 +1682,18 @@ def sort_mutation_label(s):
1675
1682
lpos = "lft"
1676
1683
elif edge .left > 0 and edge .right == ts .sequence_length :
1677
1684
lpos = "rgt"
1678
- # Add spaces between or in front of labels if
1679
- # multiple lft or rgt labels (i.e. intervals) exist for an edge
1685
+ # Add spaces between or in front of labels if
1686
+ # multiple lft or rgt labels (i.e. intervals) exist for an edge
1680
1687
if interval_labels [lpos ][pc ]: # between same side labels
1681
1688
interval_labels [lpos ][pc ] += " "
1682
- if lpos == "rgt" and interval_labels ["lft" ][pc ]: # in front of rgt label
1689
+ if (
1690
+ lpos == "rgt" and interval_labels ["lft" ][pc ]
1691
+ ): # in front of rgt label
1683
1692
interval_labels [lpos ][pc ] = " " + interval_labels [lpos ][pc ]
1684
1693
interval_labels [lpos ][pc ] += f"{ int (edge .left )} …{ int (edge .right )} "
1685
- if lpos == "lft" and interval_labels ["rgt" ][pc ]: # at end of lft label
1694
+ if (
1695
+ lpos == "lft" and interval_labels ["rgt" ][pc ]
1696
+ ): # at end of lft label
1686
1697
interval_labels [lpos ][pc ] += " "
1687
1698
1688
1699
if label_replace is not None :
0 commit comments