def test_plot(self): phy = PhyBo(self.inputfile, output_dir=self.tmp.as_posix()) phy.get_GLS() glm = list(phy.stats.keys())[0] phy.plot_GLS(glm) phy.plot_ACS(glm) for method in ['bc', 'td', 'mr']: phy.get_MLN(glm, method=method) phy.plot_MLN(glm) phy.plot_MLN_3d(glm) phy.analyze(runs=[('weighted', (2, 1))], output_gml=True, output_plot=True) phy.get_IVSD() phy.get_ACS(phy.best_model) phy.get_MSN(phy.best_model) phy.get_MSN(phy.best_model, deep_nodes=True) phy.plot_MSN(phy.best_model, conf=phy.conf) phy.plot_two_concepts('I', '15:2', '16:2') edge1, edge2 = list(phy.graph[phy.best_model].edges())[0] phy.get_edge(phy.best_model, edge1, edge2) phy.get_edge(phy.best_model, 'Beijing', 'Shanghai') phy.get_edge(phy.best_model, edge1, edge2, msn=True) phy.get_PDC('w-2-1', aligned_output=True) phy.plot_concept_evolution(phy.best_model, concept="I")
def test_plot(inputfile, mocker, Bmp, Sp, Plt, tmppath): mocker.patch('lingpy.compare.phylogeny.mpl', new=mocker.MagicMock()) mocker.patch('lingpy.compare.phylogeny.gls2gml', new=mocker.MagicMock()) mocker.patch('lingpy.compare.phylogeny.plot_tree', new=mocker.MagicMock()) mocker.patch('lingpy.compare.phylogeny.bmp', new=Bmp) mocker.patch('lingpy.compare.phylogeny.plt', new=Plt) mocker.patch('lingpy.compare.phylogeny.sp', new=Sp) phy = PhyBo(inputfile, output_dir=str(tmppath)) phy.get_GLS() glm = list(phy.stats.keys())[0] phy.plot_GLS(glm) phy.plot_ACS(glm) for method in ['bc', 'td', 'mr']: phy.get_MLN(glm, method=method) phy.plot_MLN(glm) phy.plot_MLN_3d(glm) phy.analyze(runs=[('weighted', (2, 1))], output_gml=True, output_plot=True) phy.get_IVSD() phy.get_ACS(phy.best_model) phy.get_MSN(phy.best_model) phy.get_MSN(phy.best_model, deep_nodes=True) phy.plot_MSN(phy.best_model, conf=phy.conf) phy.plot_two_concepts('I', '15:2', '16:2') edge1, edge2 = list(phy.graph[phy.best_model].edges())[0] phy.get_edge(phy.best_model, edge1, edge2) phy.get_edge(phy.best_model, 'Beijing', 'Shanghai') phy.get_edge(phy.best_model, edge1, edge2, msn=True) phy.get_PDC('w-2-1', aligned_output=True) phy.plot_concept_evolution(phy.best_model, concept="I")
def construct_mln(tsv_file, newick_tree): tre = PhyBo(str(tsv_file)+'.tsv', degree=175, missing=0, tree=newick_tree) tre.analyze(runs = 'default', plot_dists = True, gpl = 1, push_gains = True, missing_data = 0, homoplasy = 0.05) # get the minimal lateral network. Assume, for now a threshold of 1% of the total number of words to count as a borrowing tre.get_MLN(tre.best_model, method='mr', threshold=10) # plot the MLN tre.plot_MLN(tre.best_model) return(tre.best_model)
def test_plot(self): phy = PhyBo(self.inputfile, output_dir=self.tmp) phy.get_GLS() glm = list(phy.stats.keys())[0] phy.plot_concept_evolution(glm) phy.plot_GLS(glm) phy.plot_ACS(glm) phy.get_MLN(glm) phy.graph = defaultdict(lambda: Graph()) phy.plot_MLN(glm) phy.analyze() phy.get_IVSD() phy.get_MSN() glm = list(phy.geograph.keys())[0] phy.geograph[glm] = MagicMock( edges=lambda **kw: [(MagicMock(), MagicMock(), defaultdict(lambda: 2))]) phy._meta['conf'] = dict(linescale=2, groups_colors=defaultdict(lambda: 'a')) phy.plot_MSN(glm)
def test_plot(self): phy = PhyBo(self.inputfile, output_dir=self.tmp) phy.get_GLS() glm = list(phy.stats.keys())[0] phy.plot_concept_evolution(glm) phy.plot_GLS(glm) phy.plot_ACS(glm) phy.get_MLN(glm) phy.graph = defaultdict(lambda: Graph()) phy.plot_MLN(glm) phy.analyze() phy.get_IVSD() phy.get_MSN() glm = list(phy.geograph.keys())[0] phy.geograph[glm] = MagicMock(edges=lambda **kw: [(MagicMock( ), MagicMock(), defaultdict(lambda: 2))]) phy._meta['conf'] = dict(linescale=2, groups_colors=defaultdict(lambda: 'a')) phy.plot_MSN(glm)
method='library', output = True ) print('[i] Writing results to wordlist file.') msa.output('qlc',filename='DOGON_alignments') print("[i] Plotting the alignments.") msa.output('html',filename='DOGON') print("[i] Starting with the borrowing detection.") from lingpy.compare.phylogeny import PhyBo tre = PhyBo('DOGON_lexstat.qlc', ref='lexstatid', degree=180) tre.analyze(runs='weighted', mode='mixed') print("[i] Plotting the results.") # make nice labels for the taxon-names labels = dict( [(t,t[:9]) for t in tre.taxa] ) tre.get_MLN(tre.best_model) tre.plot_MLN( tre.best_model, filename='DOGON', fileformat='svg', figsize=(15,7), labels=labels )
cols=['concepts', 'taxa', 'counterpart', 'tokens', 'lexstatid']) print('[i] Loading data into the Alignments class.') msa = Alignments('DOGON_lexstat.qlc', ref='lexstatid') print('[i] Carrying out alignment analyses.') msa.align(method='library', output=True) print('[i] Writing results to wordlist file.') msa.output('qlc', filename='DOGON_alignments') print("[i] Plotting the alignments.") msa.output('html', filename='DOGON') print("[i] Starting with the borrowing detection.") from lingpy.compare.phylogeny import PhyBo tre = PhyBo('DOGON_lexstat.qlc', ref='lexstatid', degree=180) tre.analyze(runs='weighted', mode='mixed') print("[i] Plotting the results.") # make nice labels for the taxon-names labels = dict([(t, t[:9]) for t in tre.taxa]) tre.get_MLN(tre.best_model) tre.plot_MLN(tre.best_model, filename='DOGON', fileformat='svg', figsize=(15, 7), labels=labels)