def plotMDS(tree, treehome, model, mn=False, maj=False):
    os.chdir(treehome)
    model_label = "_" + model + "_"
    titlest = "All trees with base "
    titleend = "under MDS"
    if (mn == True and maj == True):
        suffix = "_mn_maj_"
        titlest = titlest + " mean and majority trees "
    elif (mn == True):
        suffix = "_mn_"
        titlest = titlest + " and mean tree "
    else:
        suffix = "_"
        
    if not os.path.exists(tree + suffix + "2D.r"):
        temp = make_rMDSscript(tree, tree + model_label + "dist_matrix", titlest + titleend, 1, mn, maj)
        temp.plot_MDS(2)
        command = "rscript " + tree + "_2D.r"
        call(command.split())
    else:
        print ("MDS plots already exist for 2D trees - skipping")
Example #2
0
     call(command.split())
 else:
     print ("Distance file already exists for base mean maj - skipping running GTP")
 if not os.path.exists(trees_mn_maj_dist_matrix):
     get_diss_matrix(trees_mn_maj_distances,trees_mn_maj_dist_matrix,"symmetric")
 else:
     print ("Distance matrix already exists for base mean maj- skipping")
     
    
 # Create R script for MDS
 # Part one: geodesic
 
 # 2D:
 
 if not os.path.exists(tree + "_2D.r"):
     all_trees = make_rMDSscript(tree, tree_dist_matrix, "All trees and base tree under MDS", 1)
     all_trees.plot_MDS(2)
     command = "rscript " + tree + "_2D.r"
     call(command.split())
 else:
     print ("MDS plots already exist for 2D trees - skipping")
     
 # Second, all trees with the mean:
 if not os.path.exists(tree + "_mean" + "_2D.r"):
     all_trees_and_mean = make_rMDSscript(tree, trees_mn_dist_matrix, "All trees, base tree, and mean tree under MDS",1,mean=True)
     all_trees_and_mean.plot_MDS(2)
     command = "rscript " + tree + "_mean" + "_2D.r"
     call(command.split())
 
 # Third, all trees with mean and majority:
 if not os.path.exists(tree + "_mean_maj" + "_2D.r"):