SHARE
TWEET

Untitled

a guest Oct 22nd, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. import pandas as pd
  3. from ete3 import PhyloTree
  4.  
  5. def generate_simplebar(df: pd.DataFrame, save_file: str) -> None:
  6.     # df columns must be labels and values.
  7.     output = """DATASET_SIMPLEBAR\n
  8. SEPARATOR COMMA\n
  9. DATASET_LABEL,label_simplebar\n
  10. COLOR,#ff0000\n
  11. DATA\n"""+df.to_csv(header=False, index=False)
  12.    
  13.     with open(save_file, "w") as f:
  14.         f.write(output)
  15.  
  16.  
  17. tree = PhyloTree("tree.nwk")
  18. leaf_labels = [leaf.name for leaf in tree.get_leaves()]
  19. values = np.random.randint(0, 100, len(leaf_labels)).tolist()
  20. generate_simplebar(pd.DataFrame([leaf_labels, values]).T, "bar.txt")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top