Advertisement
Soniker

Sylva - sample code

Apr 20th, 2021
1,143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. from skbio.diversity import beta_diversity
  2. from skbio import TreeNode
  3. from io import StringIO
  4.  
  5.  
  6. # int data = dataFrame.values.astype('float64')
  7. # weighted_unifrac
  8.  
  9. data = [[23, 64, 14, 0, 0, 3, 1],
  10.          [0, 3, 35, 42, 0, 12, 1],
  11.          [0, 5, 5, 0, 40, 40, 0],
  12.          [44, 35, 9, 0, 1, 0, 0],
  13.          [0, 2, 8, 0, 35, 45, 1],
  14.          [0, 0, 25, 35, 0, 19, 0]]
  15. ids = list('ABCDEF')
  16. tree = TreeNode.read(StringIO(
  17.                       '(((((OTU1:0.5,OTU2:0.5):0.5,OTU3:1.0):1.0):0.0,'
  18.                       '(OTU4:0.75,(OTU5:0.5,(OTU6:0.5,OTU7:0.5):0.5):'
  19.                       '0.5):1.25):0.0)root;'))
  20. otu_ids = ['OTU1', 'OTU2', 'OTU3', 'OTU4', 'OTU5', 'OTU6', 'OTU7']
  21.  
  22. wu_dm = beta_diversity("weighted_unifrac", data, ids, tree=tree, otu_ids=otu_ids)
  23. print(wu_dm)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement