TreeSAK 1.57.2__tar.gz → 1.57.3__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.
- {treesak-1.57.2/treesak.egg-info → treesak-1.57.3}/PKG-INFO +2 -2
- treesak-1.57.3/TreeSAK/Tanglegram.py +84 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/VERSION +1 -1
- treesak-1.57.3/TreeSAK/cophyloplot.R +44 -0
- treesak-1.57.3/TreeSAK/cophyloplot.py +79 -0
- treesak-1.57.3/TreeSAK/guide_tree.py +130 -0
- {treesak-1.57.2 → treesak-1.57.3/treesak.egg-info}/PKG-INFO +2 -2
- {treesak-1.57.2 → treesak-1.57.3}/treesak.egg-info/SOURCES.txt +3 -0
- treesak-1.57.2/TreeSAK/guide_tree.py +0 -55
- {treesak-1.57.2 → treesak-1.57.3}/LICENSE +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/MANIFEST.in +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/README.md +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/ALE.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/ALE1.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/ALE2.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/ALE2RTC.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/ALE3.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/ALE4.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/ALE5.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/ALE6.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/ALE7.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/ALE_backup.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/AssessCVG.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/AssessMarker.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/AssessMarkerDeltaLL.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/AssessMarkerPA.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/BMGE.jar +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/BMGE.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/C60SR4.nex +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/CompareMCMC.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/ConcateMSA.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/ConvertMSA.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/Dir.rb +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/ExtractMarkerSeq.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/FastRoot.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/FastRoot_backup.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/FigTree.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/GTDB_tree.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/GeneTree.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/KEGG_Luo17.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/LcaToLeaves.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/MarkerRef2Tree.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/MarkerRef2Tree_backup.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/MarkerSeq2Tree.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/MarkerSeq2Tree_backup.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/ModifyTopo.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/Newick_tree_plotter.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/OMA.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/OMA2.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/OneLineAln.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/PB.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/PMSF.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/PhyloBiAssoc.R +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/PhyloBiAssoc.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/PlotMCMC.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/PlotMcmcNode.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/PlotMcmcNode_old.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/RootTree.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/RootTreeGTDB.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/RootTreeGTDB214.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/RootTreeGTDB220.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/SequentialDating.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/SingleAleHGT.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/SingleLinePhy.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/SliceMSA.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/SplitScore.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/SplitScore1.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/SplitScore1OMA.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/SplitScore2.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/TaxaCountStats.R +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/TaxonTree.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/TimeScale.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/TreeSAK_config.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/VisHPD95.R +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/VisHPD95.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/__init__.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/ale_parser.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/ale_splitter.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/alignment_pruner.pl +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/assessOG.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/assessPB.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/batch_itol.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/catfasta2phy.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/cogTree.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/compare_trees.R +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/compare_trees.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/dating.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/dating_ss.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/deltall.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/do_rrtc.rb +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/fa2phy.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/filter_rename_ar53.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/format_leaf_name.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/gap_stats.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/get_SCG_tree.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/get_arCOG_seq.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/get_lca_id.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/global_functions.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/gnm_leaves.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/iTOL.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/iTOL_gene_tree.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/itol_msa_stats.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/keep_highest_rrtc.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/koTree.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/label_gene_tree_by_gnm.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/label_tree.R +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/label_tree.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/mad.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/mcmc2tree.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/mcmcTC copy.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/mcmcTC.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/mcmctree_out.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/mcmctree_vs_reltime.R +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/mcmctree_vs_reltime.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/merge_pdf.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/pRTC.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/parse_mcmctree.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/parse_reltime.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/phy2fa.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/plot_distruibution_th.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/prep_mcmctree_ctl.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/print_leaves.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/pruneMSA.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/recode.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/remove_bias.R +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/rename_leaves.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/replace_clade.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/root_with_out_group.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/run_TaxaCountStats_R_s1.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/subsample_drep_gnms.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/subset.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/subset_tree_stupid_old_way.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/supertree.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/tmp_1.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/tmp_2.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/tmp_3.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/tmp_4.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/tree_fmt.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/TreeSAK/weighted_rand.rb +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/bin/TreeSAK +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/setup.cfg +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/setup.py +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/treesak.egg-info/dependency_links.txt +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/treesak.egg-info/requires.txt +0 -0
- {treesak-1.57.2 → treesak-1.57.3}/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.
|
|
3
|
+
Version: 1.57.3
|
|
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.
|
|
27
|
+
TreeSAK v1.57.3
|
|
@@ -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()
|
|
@@ -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,130 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import argparse
|
|
3
|
+
from ete3 import Tree
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def sep_path_basename_ext(file_in):
|
|
7
|
+
|
|
8
|
+
f_path, f_name = os.path.split(file_in)
|
|
9
|
+
if f_path == '':
|
|
10
|
+
f_path = '.'
|
|
11
|
+
f_base, f_ext = os.path.splitext(f_name)
|
|
12
|
+
f_ext = f_ext[1:]
|
|
13
|
+
|
|
14
|
+
return f_name, f_path, f_base, f_ext
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
guide_tree_usage = '''
|
|
18
|
+
======================== guide_tree example command ========================
|
|
19
|
+
|
|
20
|
+
TreeSAK guide_tree -i in.tree -g gnm_group.txt -o out.tree
|
|
21
|
+
|
|
22
|
+
cd /Users/songweizhi/Desktop/Sponge_r226/07_Sponge_tree/sponge_phylogeny_Maria
|
|
23
|
+
TreeSAK guide_tree -i sponge_phylogeny_Maria.tre -g 18S_taxa.txt -o sponge_phylogeny_Maria_guide_tree.tre
|
|
24
|
+
|
|
25
|
+
============================================================================
|
|
26
|
+
'''
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def guide_tree(args):
|
|
30
|
+
|
|
31
|
+
tree_in = args['i']
|
|
32
|
+
tree_out = args['o']
|
|
33
|
+
gnm_group_txt = args['g']
|
|
34
|
+
|
|
35
|
+
_, _, f_in_base, f_in_ext = sep_path_basename_ext(tree_out)
|
|
36
|
+
_, f_out_path, f_out_base, f_out_ext = sep_path_basename_ext(tree_out)
|
|
37
|
+
tree_in_subset_file = '%s/%s_subset.%s' % (f_out_path, f_in_base, f_in_ext)
|
|
38
|
+
seqs_not_on_guide_tree_txt = '%s/%s_seqs_not_on_guide_tree.txt' % (f_out_path, f_out_base)
|
|
39
|
+
|
|
40
|
+
if os.path.isfile(tree_in) is False:
|
|
41
|
+
print('%s is not exist' % tree_in)
|
|
42
|
+
exit()
|
|
43
|
+
|
|
44
|
+
t_in = Tree(tree_in, format=0)
|
|
45
|
+
topo_tree_leaves = [i.name for i in t_in.get_leaves()]
|
|
46
|
+
|
|
47
|
+
group_to_member_dict = dict()
|
|
48
|
+
for each in open(gnm_group_txt):
|
|
49
|
+
each_split = each.strip().split('\t')
|
|
50
|
+
gnm_id = each_split[0]
|
|
51
|
+
gnm_grp = each_split[1]
|
|
52
|
+
if gnm_grp not in group_to_member_dict:
|
|
53
|
+
group_to_member_dict[gnm_grp] = set()
|
|
54
|
+
group_to_member_dict[gnm_grp].add(gnm_id)
|
|
55
|
+
|
|
56
|
+
seq_to_tax_dict = dict()
|
|
57
|
+
grp_to_seq_dict = dict()
|
|
58
|
+
seq_to_grp_dict = dict()
|
|
59
|
+
seqs_not_on_topo_tree = set()
|
|
60
|
+
for each_seq in open(gnm_group_txt):
|
|
61
|
+
each_seq_split = each_seq.strip().split('\t')
|
|
62
|
+
seq_id = each_seq_split[0]
|
|
63
|
+
seq_tax = each_seq_split[1]
|
|
64
|
+
seq_tax_split = seq_tax.strip().split(';')
|
|
65
|
+
seq_to_tax_dict[seq_id] = seq_tax
|
|
66
|
+
|
|
67
|
+
seq_grp = ''
|
|
68
|
+
for each_r in seq_tax_split:
|
|
69
|
+
if each_r in topo_tree_leaves:
|
|
70
|
+
seq_grp = each_r
|
|
71
|
+
|
|
72
|
+
seq_to_grp_dict[seq_id] = seq_grp
|
|
73
|
+
if seq_grp not in grp_to_seq_dict:
|
|
74
|
+
grp_to_seq_dict[seq_grp] = set()
|
|
75
|
+
grp_to_seq_dict[seq_grp].add(seq_id)
|
|
76
|
+
|
|
77
|
+
if seq_grp == '':
|
|
78
|
+
seqs_not_on_topo_tree.add(seq_id)
|
|
79
|
+
|
|
80
|
+
if len(seqs_not_on_topo_tree) > 0:
|
|
81
|
+
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))
|
|
82
|
+
seqs_not_on_guide_tree_txt_handle = open(seqs_not_on_guide_tree_txt, 'w')
|
|
83
|
+
for each_seq in sorted(list(seqs_not_on_topo_tree)):
|
|
84
|
+
seqs_not_on_guide_tree_txt_handle.write('%s\t%s\n' % (each_seq, seq_to_tax_dict[each_seq]))
|
|
85
|
+
seqs_not_on_guide_tree_txt_handle.close()
|
|
86
|
+
|
|
87
|
+
# subset tree (if necessary)
|
|
88
|
+
topo_tree_grp_with_seq = set()
|
|
89
|
+
topo_tree_grp_without_seq = set()
|
|
90
|
+
for leaf in topo_tree_leaves:
|
|
91
|
+
if leaf in grp_to_seq_dict:
|
|
92
|
+
topo_tree_grp_with_seq.add(leaf)
|
|
93
|
+
else:
|
|
94
|
+
topo_tree_grp_without_seq.add(leaf)
|
|
95
|
+
|
|
96
|
+
# subset input topo tree
|
|
97
|
+
topo_tree_to_use = tree_in
|
|
98
|
+
if len(topo_tree_grp_without_seq) > 0:
|
|
99
|
+
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)))
|
|
100
|
+
subset_tree = t_in.copy()
|
|
101
|
+
subset_tree.prune(topo_tree_grp_with_seq)
|
|
102
|
+
subset_tree.write(outfile=tree_in_subset_file, format=9)
|
|
103
|
+
topo_tree_to_use = tree_in_subset_file
|
|
104
|
+
|
|
105
|
+
t_in = Tree(topo_tree_to_use, format=0)
|
|
106
|
+
|
|
107
|
+
for leaf in t_in:
|
|
108
|
+
leaf_name = leaf.name
|
|
109
|
+
|
|
110
|
+
leaf_member = grp_to_seq_dict[leaf_name]
|
|
111
|
+
leaf_member_str = ','.join(leaf_member)
|
|
112
|
+
if len(leaf_member) >= 2:
|
|
113
|
+
leaf_member_str = '(' + leaf_member_str + ')'
|
|
114
|
+
if len(leaf_member) == 1:
|
|
115
|
+
leaf.name = leaf_member_str
|
|
116
|
+
else:
|
|
117
|
+
leaf_p = leaf.up
|
|
118
|
+
leaf_p.add_child(Tree((leaf_member_str + ';'), format=0))
|
|
119
|
+
leaf_p.remove_child(leaf)
|
|
120
|
+
t_in.write(outfile=tree_out, format=9)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
if __name__ == '__main__':
|
|
124
|
+
|
|
125
|
+
guide_tree_parser = argparse.ArgumentParser(usage=guide_tree_usage)
|
|
126
|
+
guide_tree_parser.add_argument('-i', required=True, help='input tree')
|
|
127
|
+
guide_tree_parser.add_argument('-g', required=True, help='genome group/taxonomy')
|
|
128
|
+
guide_tree_parser.add_argument('-o', required=True, help='output tree')
|
|
129
|
+
args = vars(guide_tree_parser.parse_args())
|
|
130
|
+
guide_tree(args)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: treesak
|
|
3
|
-
Version: 1.57.
|
|
3
|
+
Version: 1.57.3
|
|
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.
|
|
27
|
+
TreeSAK v1.57.3
|
|
@@ -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
|
|
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
|