In [ ]:
import ete3

In [ ]:


In [ ]:
import random

In [ ]:
import numpy as np

In [ ]:
x=  ete3.Tree("tree")

In [ ]:
indices = np.random.choice(len(x), size=100, replace=False)

In [ ]:
indices

In [ ]:
x.prune([str(i) for i in indices], preserve_branch_length=True)

In [ ]:
x.write(outfile="subtree")

In [ ]:
x.prune?

In [ ]:
x.get_leaf_names()

In [ ]: