Reconstruct tree by Trisicell-Boost#

This example shows how to construct a phylogenetic tree using Trisicell-Boost on a binary single-cell genotype matrix.

import scphylo as scp

# sphinx_gallery_thumbnail_path = "_static/thumbnails/trisicell-boost.png"

First, we load a binary test single-cell genotype data.

df_in = scp.datasets.test()
df_in.head()
mut0 mut1 mut2 mut3 mut4 mut5 mut6 mut7 mut8 mut9 mut10 mut11 mut12 mut13 mut14 mut15 mut16 mut17 mut18 mut19
cellIDxmutID
cell0 1 1 1 1 1 1 1 0 3 3 0 3 0 0 0 3 0 0 0 0
cell1 3 0 0 0 0 0 3 0 1 1 3 1 0 0 3 0 0 1 1 1
cell2 0 0 0 0 0 0 0 1 1 3 1 1 0 0 3 1 1 1 1 0
cell3 0 0 0 0 0 0 0 3 1 0 0 1 0 0 0 1 1 1 0 0
cell4 0 0 0 0 0 0 0 1 1 1 1 1 0 0 3 0 0 0 0 0


Next, using scphylo.tl.booster() we remove the single-cell noises from the input.

df_out = scp.tl.booster(
    df_in,
    alpha=0.0000001,
    beta=0.1,
    solver="PhISCS",
    sample_on="muts",
    sample_size=15,
    n_samples=88,
    begin_index=0,
    n_jobs=1,
    dep_weight=50,
)
df_out.head()
SUBSAMPLING    (1/3):   0%|                                                  | 0/88 [00:00<?, ?it/s]
SUBSAMPLING    (1/3):   0%|                                                  | 0/88 [00:03<?, ?it/s]

DEPENDENCIES   (2/3):   0%|                                                  | 0/88 [00:00<?, ?it/s]
DEPENDENCIES   (2/3):  83%|#################################1      | 73/88 [00:00<00:00, 721.52it/s]
DEPENDENCIES   (2/3): 100%|########################################| 88/88 [00:00<00:00, 721.99it/s]

RECONSTRUCTION (3/3):   0%|                                                  | 0/20 [00:00<?, ?it/s]
RECONSTRUCTION (3/3): 100%|######################################| 20/20 [00:00<00:00, 11220.72it/s]
input -- size: 20x20
input -- 0: 226#, 56.5%
input -- 1: 94#, 23.5%
input -- NA: 80#, 20.0%
input -- CF: False
output -- size: 20x20
output -- 0: 278#, 69.5%
output -- 1: 122#, 30.5%
output -- NA: 0#, 0.0%
output -- CF: True
output -- time: 3.7s (0:00:03.729374)
flips -- #0->1: 10
flips -- #1->0: 0
flips -- #NA->0: 62
flips -- #NA->1: 18
rates -- FN: 0.096
rates -- FP: 0.00000000
rates -- NA: 0.200
score -- NLL: 32.92976100177747
TREE_SCORE: 180.41491262103506
mut0 mut1 mut2 mut3 mut4 mut5 mut6 mut7 mut8 mut9 mut10 mut11 mut12 mut13 mut14 mut15 mut16 mut17 mut18 mut19
cellIDxmutID
cell0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
cell1 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 1 1 1 1 1
cell2 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 1 1 1 1 0
cell3 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 0 0
cell4 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 1 1 1 0 0


Finally, using scphylo.ul.is_conflict_free_gusfield() we check whether the inferred genotype matrix is conflict-free or not.

is_cf = scp.ul.is_conflict_free_gusfield(df_out)
print(is_cf)
True

Total running time of the script: (0 minutes 4.348 seconds)

Estimated memory usage: 12 MB

Gallery generated by Sphinx-Gallery