TreeSAK 1.57.2__tar.gz → 1.57.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. {treesak-1.57.2/treesak.egg-info → treesak-1.57.4}/PKG-INFO +2 -2
  2. treesak-1.57.4/TreeSAK/Tanglegram.py +84 -0
  3. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/VERSION +1 -1
  4. treesak-1.57.4/TreeSAK/cophyloplot.R +44 -0
  5. treesak-1.57.4/TreeSAK/cophyloplot.py +79 -0
  6. treesak-1.57.4/TreeSAK/guide_tree.py +149 -0
  7. {treesak-1.57.2 → treesak-1.57.4}/bin/TreeSAK +4 -3
  8. {treesak-1.57.2 → treesak-1.57.4/treesak.egg-info}/PKG-INFO +2 -2
  9. {treesak-1.57.2 → treesak-1.57.4}/treesak.egg-info/SOURCES.txt +3 -0
  10. treesak-1.57.2/TreeSAK/guide_tree.py +0 -55
  11. {treesak-1.57.2 → treesak-1.57.4}/LICENSE +0 -0
  12. {treesak-1.57.2 → treesak-1.57.4}/MANIFEST.in +0 -0
  13. {treesak-1.57.2 → treesak-1.57.4}/README.md +0 -0
  14. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/ALE.py +0 -0
  15. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/ALE1.py +0 -0
  16. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/ALE2.py +0 -0
  17. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/ALE2RTC.py +0 -0
  18. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/ALE3.py +0 -0
  19. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/ALE4.py +0 -0
  20. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/ALE5.py +0 -0
  21. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/ALE6.py +0 -0
  22. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/ALE7.py +0 -0
  23. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/ALE_backup.py +0 -0
  24. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/AssessCVG.py +0 -0
  25. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/AssessMarker.py +0 -0
  26. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/AssessMarkerDeltaLL.py +0 -0
  27. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/AssessMarkerPA.py +0 -0
  28. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/BMGE.jar +0 -0
  29. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/BMGE.py +0 -0
  30. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/C60SR4.nex +0 -0
  31. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/CompareMCMC.py +0 -0
  32. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/ConcateMSA.py +0 -0
  33. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/ConvertMSA.py +0 -0
  34. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/Dir.rb +0 -0
  35. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/ExtractMarkerSeq.py +0 -0
  36. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/FastRoot.py +0 -0
  37. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/FastRoot_backup.py +0 -0
  38. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/FigTree.py +0 -0
  39. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/GTDB_tree.py +0 -0
  40. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/GeneTree.py +0 -0
  41. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/KEGG_Luo17.py +0 -0
  42. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/LcaToLeaves.py +0 -0
  43. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/MarkerRef2Tree.py +0 -0
  44. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/MarkerRef2Tree_backup.py +0 -0
  45. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/MarkerSeq2Tree.py +0 -0
  46. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/MarkerSeq2Tree_backup.py +0 -0
  47. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/ModifyTopo.py +0 -0
  48. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/Newick_tree_plotter.py +0 -0
  49. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/OMA.py +0 -0
  50. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/OMA2.py +0 -0
  51. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/OneLineAln.py +0 -0
  52. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/PB.py +0 -0
  53. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/PMSF.py +0 -0
  54. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/PhyloBiAssoc.R +0 -0
  55. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/PhyloBiAssoc.py +0 -0
  56. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/PlotMCMC.py +0 -0
  57. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/PlotMcmcNode.py +0 -0
  58. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/PlotMcmcNode_old.py +0 -0
  59. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/RootTree.py +0 -0
  60. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/RootTreeGTDB.py +0 -0
  61. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/RootTreeGTDB214.py +0 -0
  62. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/RootTreeGTDB220.py +0 -0
  63. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/SequentialDating.py +0 -0
  64. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/SingleAleHGT.py +0 -0
  65. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/SingleLinePhy.py +0 -0
  66. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/SliceMSA.py +0 -0
  67. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/SplitScore.py +0 -0
  68. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/SplitScore1.py +0 -0
  69. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/SplitScore1OMA.py +0 -0
  70. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/SplitScore2.py +0 -0
  71. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/TaxaCountStats.R +0 -0
  72. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/TaxonTree.py +0 -0
  73. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/TimeScale.py +0 -0
  74. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/TreeSAK_config.py +0 -0
  75. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/VisHPD95.R +0 -0
  76. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/VisHPD95.py +0 -0
  77. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/__init__.py +0 -0
  78. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/ale_parser.py +0 -0
  79. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/ale_splitter.py +0 -0
  80. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/alignment_pruner.pl +0 -0
  81. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/assessOG.py +0 -0
  82. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/assessPB.py +0 -0
  83. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/batch_itol.py +0 -0
  84. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/catfasta2phy.py +0 -0
  85. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/cogTree.py +0 -0
  86. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/compare_trees.R +0 -0
  87. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/compare_trees.py +0 -0
  88. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/dating.py +0 -0
  89. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/dating_ss.py +0 -0
  90. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/deltall.py +0 -0
  91. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/do_rrtc.rb +0 -0
  92. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/fa2phy.py +0 -0
  93. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/filter_rename_ar53.py +0 -0
  94. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/format_leaf_name.py +0 -0
  95. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/gap_stats.py +0 -0
  96. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/get_SCG_tree.py +0 -0
  97. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/get_arCOG_seq.py +0 -0
  98. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/get_lca_id.py +0 -0
  99. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/global_functions.py +0 -0
  100. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/gnm_leaves.py +0 -0
  101. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/iTOL.py +0 -0
  102. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/iTOL_gene_tree.py +0 -0
  103. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/itol_msa_stats.py +0 -0
  104. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/keep_highest_rrtc.py +0 -0
  105. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/koTree.py +0 -0
  106. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/label_gene_tree_by_gnm.py +0 -0
  107. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/label_tree.R +0 -0
  108. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/label_tree.py +0 -0
  109. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/mad.py +0 -0
  110. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/mcmc2tree.py +0 -0
  111. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/mcmcTC copy.py +0 -0
  112. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/mcmcTC.py +0 -0
  113. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/mcmctree_out.py +0 -0
  114. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/mcmctree_vs_reltime.R +0 -0
  115. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/mcmctree_vs_reltime.py +0 -0
  116. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/merge_pdf.py +0 -0
  117. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/pRTC.py +0 -0
  118. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/parse_mcmctree.py +0 -0
  119. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/parse_reltime.py +0 -0
  120. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/phy2fa.py +0 -0
  121. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/plot_distruibution_th.py +0 -0
  122. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/prep_mcmctree_ctl.py +0 -0
  123. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/print_leaves.py +0 -0
  124. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/pruneMSA.py +0 -0
  125. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/recode.py +0 -0
  126. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/remove_bias.R +0 -0
  127. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/rename_leaves.py +0 -0
  128. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/replace_clade.py +0 -0
  129. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/root_with_out_group.py +0 -0
  130. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/run_TaxaCountStats_R_s1.py +0 -0
  131. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/subsample_drep_gnms.py +0 -0
  132. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/subset.py +0 -0
  133. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/subset_tree_stupid_old_way.py +0 -0
  134. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/supertree.py +0 -0
  135. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/tmp_1.py +0 -0
  136. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/tmp_2.py +0 -0
  137. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/tmp_3.py +0 -0
  138. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/tmp_4.py +0 -0
  139. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/tree_fmt.py +0 -0
  140. {treesak-1.57.2 → treesak-1.57.4}/TreeSAK/weighted_rand.rb +0 -0
  141. {treesak-1.57.2 → treesak-1.57.4}/setup.cfg +0 -0
  142. {treesak-1.57.2 → treesak-1.57.4}/setup.py +0 -0
  143. {treesak-1.57.2 → treesak-1.57.4}/treesak.egg-info/dependency_links.txt +0 -0
  144. {treesak-1.57.2 → treesak-1.57.4}/treesak.egg-info/requires.txt +0 -0
  145. {treesak-1.57.2 → treesak-1.57.4}/treesak.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: treesak
3
- Version: 1.57.2
3
+ Version: 1.57.4
4
4
  Summary: BioSAK
5
5
  Home-page: https://github.com/songweizhi/TreeSAK
6
6
  Author: Weizhi Song
@@ -24,4 +24,4 @@ Requires-Dist: kaleido
24
24
  Requires-Dist: PyPDF3
25
25
  Requires-Dist: dendropy
26
26
 
27
- TreeSAK v1.57.2
27
+ TreeSAK v1.57.4
@@ -0,0 +1,84 @@
1
+ import os
2
+
3
+ from ete3 import Tree
4
+
5
+ ########################################################################################################################
6
+
7
+ # file in
8
+ meta_data_txt = '/Users/songweizhi/Desktop/Sponge_r226/00_metadata/AOA_metadata_20260130.txt'
9
+ tree_file_host = '/Users/songweizhi/Desktop/Sponge_r226/08_Host_specificity/codiv_data_test/51_host.treefile'
10
+ tree_file_symbiont = '/Users/songweizhi/Desktop/Sponge_r226/08_Host_specificity/codiv_data_test/18_sym.treefile'
11
+ association_table = '/Users/songweizhi/Desktop/Sponge_r226/08_Host_specificity/codiv_data_test/codiv_sponge_to_AOA_all.txt'
12
+ color_code_genome_txt = '/Users/songweizhi/Desktop/Sponge_r226/00_metadata/color_code_symbiont.txt'
13
+ color_code_sponge_txt = ''
14
+ color_link_by_symbiont = True
15
+
16
+ # file out
17
+ itol_tanglegram_txt = '/Users/songweizhi/Desktop/Sponge_r226/08_Host_specificity/codiv_data_test/iTOL_Tanglegram.txt'
18
+
19
+ ########################################################################################################################
20
+
21
+ current_file_path = '/'.join(os.path.realpath(__file__).split('/')[:-1])
22
+ cophyloplot_Rscript = '%s/cophyloplot.R' % current_file_path
23
+
24
+ gnm_tax_dict = dict()
25
+ col_index = dict()
26
+ for each_gnm in open(meta_data_txt):
27
+ each_gnm_split = each_gnm.strip().split('\t')
28
+ if each_gnm.startswith('Genome\t'):
29
+ col_index = {key: i for i, key in enumerate(each_gnm_split)}
30
+ else:
31
+ gnm_id = each_gnm_split[col_index['Genome']]
32
+ gnm_tax = each_gnm_split[col_index['GTDB_Taxon_r226']]
33
+ gnm_g = 'g__'
34
+ for each_r in gnm_tax.split(';'):
35
+ if each_r.startswith('g__'):
36
+ gnm_g = each_r
37
+ gnm_tax_dict[gnm_id] = gnm_g
38
+
39
+
40
+
41
+ host_color_code_dict = dict()
42
+ if os.path.isfile(color_code_sponge_txt):
43
+ for each_line in open(color_code_sponge_txt):
44
+ each_line_split = each_line.strip().split()
45
+ host_color_code_dict[each_line_split[0]] = each_line_split[1]
46
+
47
+ symbiont_color_code_dict = dict()
48
+ if os.path.isfile(color_code_genome_txt):
49
+ for each_line in open(color_code_genome_txt):
50
+ each_line_split = each_line.strip().split()
51
+ symbiont_color_code_dict[each_line_split[0]] = each_line_split[1]
52
+
53
+ tanglegram_tree_str = ''
54
+ with open(tree_file_host, 'r') as f:
55
+ tanglegram_tree_str = f.readline()
56
+
57
+
58
+ itol_tanglegram_txt_handle = open(itol_tanglegram_txt, 'w')
59
+ itol_tanglegram_txt_handle.write('DATASET_TANGLEGRAM\nSEPARATOR TAB\n\n')
60
+ itol_tanglegram_txt_handle.write('DATASET_LABEL\tTanglegram\nCOLOR\t#00ff00\n\n')
61
+ itol_tanglegram_txt_handle.write('TANGLEGRAM_TREE\n%s\nEND_TANGLEGRAM_TREE\n\n' % tanglegram_tree_str)
62
+ itol_tanglegram_txt_handle.write('\n')
63
+ itol_tanglegram_txt_handle.write('#connection lines\n')
64
+ itol_tanglegram_txt_handle.write('CONNECTION_CURVE\t0\n')
65
+ itol_tanglegram_txt_handle.write('\n')
66
+ itol_tanglegram_txt_handle.write('\n')
67
+ itol_tanglegram_txt_handle.write('DATA\n')
68
+ itol_tanglegram_txt_handle.write('#connect\tMAIN_TREE_NODE_ID\tTANGLEGRAM_TREE_NODE_ID\tWIDTH\tCOLOR\tSTYLE\tLABEL\n')
69
+ itol_tanglegram_txt_handle.write('#colorstrip\tCOLUMN_INDEX\tTANGLEGRAM_TREE_NODE_ID\tCOLOR LABEL\n')
70
+ itol_tanglegram_txt_handle.write('#style\tTANGLEGRAM_TREE_NODE_ID\tTYPE\tWHAT\tCOLOR\tWIDTH_OR_SIZE_FACTOR\tSTYLE\tBACKGROUND_COLOR\n')
71
+ itol_tanglegram_txt_handle.write('#symbol\tTANGLEGRAM_TREE_NODE_ID\tSYMBOL\tSIZE\tCOLOR\tFILL\tPOSITION\tLABEL\n')
72
+ itol_tanglegram_txt_handle.write('\n')
73
+ for each_line in open(association_table):
74
+ each_line_split = each_line.strip().split()
75
+ leaf_l = each_line_split[0]
76
+ leaf_r = each_line_split[1]
77
+ color_by_host = host_color_code_dict.get(leaf_l, 'black')
78
+ symbiont_tax = gnm_tax_dict.get(leaf_r, 'g__')
79
+ color_by_symbiont = symbiont_color_code_dict.get(symbiont_tax, 'black')
80
+ color_to_use = color_by_host
81
+ if color_link_by_symbiont is True:
82
+ color_to_use = color_by_symbiont
83
+ itol_tanglegram_txt_handle.write('connect\t%s\t%s\t3\t%s\tnormal\ttest\n' % (leaf_r, leaf_l, color_to_use))
84
+ itol_tanglegram_txt_handle.close()
@@ -1,4 +1,4 @@
1
- 1.57.2
1
+ 1.57.4
2
2
  - fixed bugs
3
3
 
4
4
  1.57.0
@@ -0,0 +1,44 @@
1
+ suppressMessages(suppressWarnings(library(optparse)))
2
+ suppressMessages(suppressWarnings(library(ape)))
3
+
4
+ ################################ argument parser ###############################
5
+
6
+ option_list = list(
7
+ make_option(c("-i", "--tree1"), type="character", default=NULL, help="tree file 1"),
8
+ make_option(c("-s", "--tree2"), type="character", default=NULL, help="tree file 2"),
9
+ make_option(c("-l", "--link"), type="character", default=NULL, help="connection file"),
10
+ make_option(c("-o", "--output"), type="character", default=NULL, help="output plot"));
11
+ opt_parser = OptionParser(option_list=option_list);
12
+ opt = parse_args(opt_parser);
13
+
14
+ tree_file_1 = opt$tree1
15
+ tree_file_2 = opt$tree2
16
+ link_table_file = opt$link
17
+ op_plot = opt$output
18
+
19
+ ################################################################################
20
+
21
+ # tree_file_1 = '/Users/songweizhi/Desktop/Sponge_r226/08_Host_specificity/codiv_data_test/RefSeqs_with_AOA_18S_iden99_g_representatives_with_JL_rooted.treefile'
22
+ # tree_file_2 = '/Users/songweizhi/Desktop/Sponge_r226/08_Host_specificity/codiv_data_test/AOA_tree_654_with_fixed_topo1_LG_rooted.treefile'
23
+ # link_table_file = '/Users/songweizhi/Desktop/Sponge_r226/08_Host_specificity/codiv_data_test/codiv_sponge_to_AOA_op.txt'
24
+
25
+ ################################################################################
26
+
27
+ tree_1 <- read.tree(tree_file_1)
28
+ tree_2 <- read.tree(tree_file_2)
29
+ association_df <- read.table(link_table_file, header = FALSE)
30
+ association <- cbind(association_df$V1, association_df$V2)
31
+ link_color <- association_df$V3
32
+
33
+ pdf(op_plot, width =10, height =10)
34
+
35
+ plot(tree_1, type = "c")
36
+ plot(tree_2, type = "c")
37
+
38
+ cophyloplot(tree_1, tree_2, assoc = association, # data
39
+ show.tip.label = FALSE, rotate = F, # layout
40
+ length.line = 1, space = 200, gap = 3, # layout
41
+ col=link_color, lwd=1, lty = 1) # linking lines
42
+
43
+ invisible(dev.off())
44
+ rm(list=ls())
@@ -0,0 +1,79 @@
1
+ import os
2
+
3
+ from ete3 import Tree
4
+
5
+ ########################################################################################################################
6
+
7
+ # file in
8
+ meta_data_txt = '/Users/songweizhi/Desktop/Sponge_r226/00_metadata/AOA_metadata_20260130.txt'
9
+ tree_file_host = '/Users/songweizhi/Desktop/Sponge_r226/08_Host_specificity/codiv_data_test/RefSeqs_with_AOA_18S_iden99_g_representatives_with_JL_rooted.treefile'
10
+ tree_file_symbiont = '/Users/songweizhi/Desktop/Sponge_r226/08_Host_specificity/codiv_data_test/AOA_tree_654_with_fixed_topo1_LG_rooted.treefile'
11
+ association_table = '/Users/songweizhi/Desktop/Sponge_r226/08_Host_specificity/codiv_data_test/codiv_sponge_to_AOA_all.txt'
12
+ color_code_genome_txt = '/Users/songweizhi/Desktop/Sponge_r226/00_metadata/color_code_symbiont.txt'
13
+ color_code_sponge_txt = ''
14
+ color_link_by_symbiont = True
15
+
16
+ # file out
17
+ op_association_table = '/Users/songweizhi/Desktop/Sponge_r226/08_Host_specificity/codiv_data_test/codiv_sponge_to_AOA_op.txt'
18
+ op_pdf = '/Users/songweizhi/Desktop/Sponge_r226/08_Host_specificity/codiv_data_test/test.pdf'
19
+
20
+ ########################################################################################################################
21
+
22
+ current_file_path = '/'.join(os.path.realpath(__file__).split('/')[:-1])
23
+ cophyloplot_Rscript = '%s/cophyloplot.R' % current_file_path
24
+
25
+ gnm_tax_dict = dict()
26
+ col_index = dict()
27
+ for each_gnm in open(meta_data_txt):
28
+ each_gnm_split = each_gnm.strip().split('\t')
29
+ if each_gnm.startswith('Genome\t'):
30
+ col_index = {key: i for i, key in enumerate(each_gnm_split)}
31
+ else:
32
+ gnm_id = each_gnm_split[col_index['Genome']]
33
+ gnm_tax = each_gnm_split[col_index['GTDB_Taxon_r226']]
34
+ gnm_g = 'g__'
35
+ for each_r in gnm_tax.split(';'):
36
+ if each_r.startswith('g__'):
37
+ gnm_g = each_r
38
+ gnm_tax_dict[gnm_id] = gnm_g
39
+
40
+ t_host = Tree(tree_file_host, quoted_node_names=True, format=1)
41
+ t_symbiont = Tree(tree_file_symbiont, quoted_node_names=True, format=1)
42
+ leaf_names_1 = t_host.get_leaf_names()
43
+ leaf_names_2 = t_symbiont.get_leaf_names()
44
+
45
+ host_color_code_dict = dict()
46
+ if os.path.isfile(color_code_sponge_txt):
47
+ for each_line in open(color_code_sponge_txt):
48
+ each_line_split = each_line.strip().split()
49
+ host_color_code_dict[each_line_split[0]] = each_line_split[1]
50
+
51
+ symbiont_color_code_dict = dict()
52
+ if os.path.isfile(color_code_genome_txt):
53
+ for each_line in open(color_code_genome_txt):
54
+ each_line_split = each_line.strip().split()
55
+ symbiont_color_code_dict[each_line_split[0]] = each_line_split[1]
56
+
57
+ op_association_table_handle = open(op_association_table, 'w')
58
+ for each_line in open(association_table):
59
+ each_line_split = each_line.strip().split()
60
+ leaf_l = each_line_split[0]
61
+ leaf_r = each_line_split[1]
62
+ color_by_host = host_color_code_dict.get(leaf_l, 'black')
63
+ symbiont_tax = gnm_tax_dict.get(leaf_r, 'g__')
64
+ color_by_symbiont = symbiont_color_code_dict.get(symbiont_tax, 'black')
65
+ color_to_use = color_by_host
66
+ if color_link_by_symbiont is True:
67
+ color_to_use = color_by_symbiont
68
+ if (leaf_l in leaf_names_1) and (leaf_r in leaf_names_2):
69
+ op_association_table_handle.write('%s\t%s\t"%s"\n' % (leaf_l, leaf_r, color_to_use))
70
+ op_association_table_handle.close()
71
+
72
+ # run cophyloplot.R
73
+ r_cmd = 'Rscript %s -i %s -s %s -l %s -o %s' % (cophyloplot_Rscript, tree_file_host, tree_file_symbiont, op_association_table, op_pdf)
74
+ print(r_cmd)
75
+ os.system(r_cmd)
76
+
77
+
78
+
79
+
@@ -0,0 +1,149 @@
1
+ import os
2
+ import argparse
3
+ from ete3 import Tree
4
+ from Bio import SeqIO
5
+
6
+ guide_tree_usage = '''
7
+ ============================== guide_tree example command ==============================
8
+
9
+ TreeSAK guide_tree -i in.tree -g gnm_group.txt -o out.tree
10
+ TreeSAK guide_tree -i in.tree -g gnm_group.txt -o out.tree -id interested_gnm.txt
11
+ TreeSAK guide_tree -i in.tree -g gnm_group.txt -o out.tree -id representative_gene.fa
12
+ TreeSAK guide_tree -i in.tree -g gnm_group.txt -o out.tree -id representative_gene.aln
13
+
14
+ ========================================================================================
15
+ '''
16
+
17
+ def sep_path_basename_ext(file_in):
18
+
19
+ f_path, f_name = os.path.split(file_in)
20
+ if f_path == '':
21
+ f_path = '.'
22
+ f_base, f_ext = os.path.splitext(f_name)
23
+ f_ext = f_ext[1:]
24
+
25
+ return f_name, f_path, f_base, f_ext
26
+
27
+
28
+ def guide_tree(args):
29
+
30
+ tree_in = args['i']
31
+ gnm_group_txt = args['g']
32
+ interested_gene_gnm_txt_fa = args['id']
33
+ tree_out = args['o']
34
+
35
+ if os.path.isfile(tree_in) is False:
36
+ print('%s not exist, program exited!' % tree_in)
37
+ exit()
38
+
39
+ count_all_gene_genome = True
40
+ interested_gene_genome_set = set()
41
+ if interested_gene_gnm_txt_fa is not None:
42
+
43
+ if os.path.isfile(interested_gene_gnm_txt_fa) is False:
44
+ print('%s not exist, program exited!' % interested_gene_gnm_txt_fa)
45
+ exit()
46
+
47
+ count_all_gene_genome = False
48
+ _, _, _, id_f_ext = sep_path_basename_ext(interested_gene_gnm_txt_fa)
49
+ if id_f_ext in ['fa', 'fasta','fas','ffn','faa','fna', 'aln']:
50
+ for each_seq in SeqIO.parse(open(interested_gene_gnm_txt_fa), 'fasta'):
51
+ interested_gene_genome_set.add(each_seq.id)
52
+ else:
53
+ for each_line in open(interested_gene_gnm_txt_fa):
54
+ interested_gene_genome_set.add(each_line.strip().split('')[0])
55
+
56
+ # define output/tmp file name
57
+ _, _, f_in_base, f_in_ext = sep_path_basename_ext(tree_in)
58
+ _, f_out_path, f_out_base, f_out_ext = sep_path_basename_ext(tree_out)
59
+ tree_in_subset_file = '%s/%s_subset.%s' % (f_out_path, f_in_base, f_in_ext)
60
+ seqs_not_on_guide_tree_txt = '%s/%s_seqs_not_on_guide_tree.txt' % (f_out_path, f_out_base)
61
+
62
+ t_in = Tree(tree_in, format=0)
63
+ topo_tree_leaves = [i.name for i in t_in.get_leaves()]
64
+
65
+ seq_to_tax_dict = dict()
66
+ grp_to_seq_dict = dict()
67
+ seq_to_grp_dict = dict()
68
+ seqs_not_on_topo_tree = set()
69
+ for each_seq in open(gnm_group_txt):
70
+ each_seq_split = each_seq.strip().split('\t')
71
+ seq_id = each_seq_split[0]
72
+
73
+ count_current_seq = False
74
+ if count_all_gene_genome is True:
75
+ count_current_seq = True
76
+ else:
77
+ if seq_id in interested_gene_genome_set:
78
+ count_current_seq = True
79
+
80
+ if count_current_seq is True:
81
+ seq_tax = each_seq_split[1]
82
+ seq_tax_split = seq_tax.strip().split(';')
83
+ seq_to_tax_dict[seq_id] = seq_tax
84
+
85
+ seq_grp = ''
86
+ for each_r in seq_tax_split:
87
+ if each_r in topo_tree_leaves:
88
+ seq_grp = each_r
89
+
90
+ seq_to_grp_dict[seq_id] = seq_grp
91
+ if seq_grp not in grp_to_seq_dict:
92
+ grp_to_seq_dict[seq_grp] = set()
93
+ grp_to_seq_dict[seq_grp].add(seq_id)
94
+
95
+ if seq_grp == '':
96
+ seqs_not_on_topo_tree.add(seq_id)
97
+
98
+ if len(seqs_not_on_topo_tree) > 0:
99
+ print('%s sequences can not be placed on guide tree, for details: %s' % (len(seqs_not_on_topo_tree), seqs_not_on_guide_tree_txt))
100
+ seqs_not_on_guide_tree_txt_handle = open(seqs_not_on_guide_tree_txt, 'w')
101
+ for each_seq in sorted(list(seqs_not_on_topo_tree)):
102
+ seqs_not_on_guide_tree_txt_handle.write('%s\t%s\n' % (each_seq, seq_to_tax_dict[each_seq]))
103
+ seqs_not_on_guide_tree_txt_handle.close()
104
+
105
+ # subset tree (if necessary)
106
+ topo_tree_grp_with_seq = set()
107
+ topo_tree_grp_without_seq = set()
108
+ for leaf in topo_tree_leaves:
109
+ if leaf in grp_to_seq_dict:
110
+ topo_tree_grp_with_seq.add(leaf)
111
+ else:
112
+ topo_tree_grp_without_seq.add(leaf)
113
+
114
+ # subset input topo tree
115
+ topo_tree_to_use = tree_in
116
+ if len(topo_tree_grp_without_seq) > 0:
117
+ print('Removing the following leaves from %s, as no sequence in %s belongs to these groups: %s' % (tree_in, gnm_group_txt, ','.join(topo_tree_grp_without_seq)))
118
+ subset_tree = t_in.copy()
119
+ subset_tree.prune(topo_tree_grp_with_seq)
120
+ subset_tree.write(outfile=tree_in_subset_file, format=9)
121
+ topo_tree_to_use = tree_in_subset_file
122
+
123
+ t_in = Tree(topo_tree_to_use, format=0)
124
+
125
+ for leaf in t_in:
126
+ leaf_name = leaf.name
127
+
128
+ leaf_member = grp_to_seq_dict[leaf_name]
129
+ leaf_member_str = ','.join(leaf_member)
130
+ if len(leaf_member) >= 2:
131
+ leaf_member_str = '(' + leaf_member_str + ')'
132
+ if len(leaf_member) == 1:
133
+ leaf.name = leaf_member_str
134
+ else:
135
+ leaf_p = leaf.up
136
+ leaf_p.add_child(Tree((leaf_member_str + ';'), format=0))
137
+ leaf_p.remove_child(leaf)
138
+ t_in.write(outfile=tree_out, format=9)
139
+
140
+
141
+ if __name__ == '__main__':
142
+
143
+ guide_tree_parser = argparse.ArgumentParser(usage=guide_tree_usage)
144
+ guide_tree_parser.add_argument('-i', required=True, help='input tree')
145
+ guide_tree_parser.add_argument('-g', required=True, help='gene/genome group/taxonomy')
146
+ guide_tree_parser.add_argument('-id', required=False, default=None, help='interested genes/genomes')
147
+ guide_tree_parser.add_argument('-o', required=True, help='output tree')
148
+ args = vars(guide_tree_parser.parse_args())
149
+ guide_tree(args)
@@ -966,9 +966,10 @@ if __name__ == '__main__':
966
966
  elif sys.argv[1] == 'guide_tree':
967
967
  from TreeSAK import guide_tree
968
968
  guide_tree_parser = subparsers.add_parser('guide_tree', usage=guide_tree.guide_tree_usage)
969
- guide_tree_parser.add_argument('-i', required=True, help='input tree')
970
- guide_tree_parser.add_argument('-g', required=True, help='genome group')
971
- guide_tree_parser.add_argument('-o', required=True, help='output tree')
969
+ guide_tree_parser.add_argument('-i', required=True, help='input tree')
970
+ guide_tree_parser.add_argument('-g', required=True, help='gene/genome group/taxonomy')
971
+ guide_tree_parser.add_argument('-id', required=False, default=None, help='interested genes/genomes')
972
+ guide_tree_parser.add_argument('-o', required=True, help='output tree')
972
973
  args = vars(parser.parse_args())
973
974
  guide_tree.guide_tree(args)
974
975
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: treesak
3
- Version: 1.57.2
3
+ Version: 1.57.4
4
4
  Summary: BioSAK
5
5
  Home-page: https://github.com/songweizhi/TreeSAK
6
6
  Author: Weizhi Song
@@ -24,4 +24,4 @@ Requires-Dist: kaleido
24
24
  Requires-Dist: PyPDF3
25
25
  Requires-Dist: dendropy
26
26
 
27
- TreeSAK v1.57.2
27
+ TreeSAK v1.57.4
@@ -59,6 +59,7 @@ TreeSAK/SplitScore.py
59
59
  TreeSAK/SplitScore1.py
60
60
  TreeSAK/SplitScore1OMA.py
61
61
  TreeSAK/SplitScore2.py
62
+ TreeSAK/Tanglegram.py
62
63
  TreeSAK/TaxaCountStats.R
63
64
  TreeSAK/TaxonTree.py
64
65
  TreeSAK/TimeScale.py
@@ -77,6 +78,8 @@ TreeSAK/catfasta2phy.py
77
78
  TreeSAK/cogTree.py
78
79
  TreeSAK/compare_trees.R
79
80
  TreeSAK/compare_trees.py
81
+ TreeSAK/cophyloplot.R
82
+ TreeSAK/cophyloplot.py
80
83
  TreeSAK/dating.py
81
84
  TreeSAK/dating_ss.py
82
85
  TreeSAK/deltall.py
@@ -1,55 +0,0 @@
1
- import os
2
- import argparse
3
- from ete3 import Tree
4
-
5
-
6
- guide_tree_usage = '''
7
- ======================== guide_tree example command ========================
8
-
9
- TreeSAK guide_tree -i in.tree -g gnm_group.txt -o out.tree
10
-
11
- ============================================================================
12
- '''
13
-
14
-
15
- def guide_tree(args):
16
-
17
- tree_in = args['i']
18
- tree_out = args['o']
19
- gnm_group_txt = args['g']
20
-
21
- group_to_member_dict = dict()
22
- for each in open(gnm_group_txt):
23
- each_split = each.strip().split('\t')
24
- gnm_id = each_split[0]
25
- gnm_grp = each_split[1]
26
- if gnm_grp not in group_to_member_dict:
27
- group_to_member_dict[gnm_grp] = set()
28
- group_to_member_dict[gnm_grp].add(gnm_id)
29
-
30
- t = Tree(tree_in, format=0)
31
- for leaf in t:
32
- leaf_name = leaf.name
33
- if leaf_name in group_to_member_dict:
34
- leaf_member = group_to_member_dict[leaf_name]
35
- leaf_member_str = ','.join(leaf_member)
36
- if len(leaf_member) >= 2:
37
- leaf_member_str = '(' + leaf_member_str + ')'
38
- if len(leaf_member) == 1:
39
- leaf.name = leaf_member_str
40
- else:
41
- leaf_p = leaf.up
42
- leaf_p.add_child(Tree((leaf_member_str + ';'), format=0))
43
- leaf_p.remove_child(leaf)
44
- t.write(outfile=tree_out, format=9)
45
-
46
-
47
- if __name__ == '__main__':
48
-
49
- guide_tree_parser = argparse.ArgumentParser(usage=guide_tree_usage)
50
- guide_tree_parser.add_argument('-i', required=True, help='input tree')
51
- guide_tree_parser.add_argument('-g', required=True, help='genome group')
52
- guide_tree_parser.add_argument('-o', required=True, help='output tree')
53
- args = vars(guide_tree_parser.parse_args())
54
- guide_tree(args)
55
-
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes