a guest Oct 22nd, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- import numpy as np
- import pandas as pd
- from ete3 import PhyloTree
- def generate_simplebar(df: pd.DataFrame, save_file: str) -> None:
- # df columns must be labels and values.
- output = """DATASET_SIMPLEBAR\n
- SEPARATOR COMMA\n
- DATA\n"""+df.to_csv(header=False, index=False)
- with open(save_file, "w") as f:
- tree = PhyloTree("tree.nwk")
- leaf_labels = [leaf.name for leaf in tree.get_leaves()]
- values = np.random.randint(0, 100, len(leaf_labels)).tolist()
- generate_simplebar(pd.DataFrame([leaf_labels, values]).T, "bar.txt")
RAW Paste Data