コード例 #1
0
    # plot a combined figure
    # color according to season
    pred_names = [c.name for c in prediction.terminals]
    tree_utils.erase_color(combined_data.T)
    for c in combined_data.T.get_terminals():
        if c.name in pred_names:
            c.color = (178, 34, 34)
        else:
            c.color = (0, 255, 255)
    prediction.interpolate_color(combined_data.T)

    tree_utils.label_nodes(combined_data.T, seq_labels)
    fig = plt.figure(figsize=(10, 6))
    ax = plt.subplot(121)
    plt.title('until Feb ' + str(year))
    tree_utils.draw_tree(prediction.T, axes=ax, cb=True)
    ax = plt.subplot(122)
    plt.title('before Mar ' + str(year) + ' (red) + season ' + str(year) +
              "/" + str(year + 1) + " (cyan)")
    tree_utils.draw_tree(combined_data.T, axes=ax, cb=False)
    plt.tight_layout()
    plt.savefig(tree_figure_folder + base_name + '_' + method[0] + method[1] +
                '_' + name_mod + '.pdf')

# perform additional analysis on the tree and the prediction
if params.analysis:
    # calculate the fitness differentials for each internal branch and associate with
    # different types of mutations that happen on these branches
    dfit = []
    for node in prediction.non_terminals:
        for child in node.clades:
コード例 #2
0
                                method='polarizer',
                                axes=ax,
                                cb=True,
                                offset=0.0005,
                                internal=False)

#subplot 2: prediction data and test data
ax = plt.subplot(122)
#add panel label
plt.text(-0.06, 0.95, 'B', transform=plt.gca().transAxes, fontsize=36)
plt.title('until Feb ' + str(year) + ' + season ' + str(year) + "/" +
          str(year + 1) + " (grey)")
pred_names = [c.name for c in prediction.terminals]
tree_utils.erase_color(combined_data.T)
prediction.color_other_tree(combined_data.T.get_terminals(),
                            method='polarizer',
                            offset=0.0005)
for c in combined_data.T.get_terminals():
    if c.name in pred_names:
        pass
    #   c.color = (178, 34, 34 )
    else:
        c.color = (0, 255, 255)
        c.color = (100, 100, 100)
prediction.interpolate_color(combined_data.T)
tree_utils.draw_tree(combined_data.T, axes=ax, cb=False)

for ff in file_formats:
    plt.savefig('../figures_ms/Fig4AB_' + base_name + '_combined_polarizer' +
                ff)
コード例 #3
0
fig = plt.figure(figsize = (12,6))
#subplot 1: only the prediction data
ax = plt.subplot(121)
#add panel label
plt.text(-0.06,0.95,'A', transform = plt.gca().transAxes, fontsize = 36)
plt.title('until Feb '+str(year))
plt.tight_layout()
tree_utils.plot_prediction_tree(prediction, axes=ax, cb=True, offset = 0.0005, internal=False)

#subplot 2: prediction data and test data
ax = plt.subplot(122)
#add panel label
plt.text(-0.06,0.95,'B', transform = plt.gca().transAxes, fontsize = 36)
plt.title('until Feb '+str(year)+' + season '+str(year)+"/"+str(year+1)+" (grey)")
pred_names = [c.name for c in prediction.terminals]
tree_utils.erase_color(combined_data.T)
prediction.color_other_tree(combined_data.T.get_terminals(), offset = 0.0005)
for c in combined_data.T.get_terminals():
    if c.name in pred_names:
        pass
    #   c.color = (178, 34, 34 )
    else:
        c.color = (0,255,255)
        c.color = (100,100,100)
prediction.interpolate_color(combined_data.T)
tree_utils.draw_tree(combined_data.T, axes=ax, cb=False)

plt.savefig('../figures/Fig3AB_'+base_name+'_combined_'+name_mod+'.svg')


コード例 #4
0
    # plot a combined figure
    # color according to season
    pred_names = [c.name for c in prediction.terminals]
    tree_utils.erase_color(combined_data.T)
    for c in combined_data.T.get_terminals():
        if c.name in pred_names:
            c.color = (178, 34, 34 )
        else:
            c.color = (0,255,255)
    prediction.interpolate_color(combined_data.T)
    
    tree_utils.label_nodes(combined_data.T, seq_labels)
    fig = plt.figure(figsize = (10,6))
    ax = plt.subplot(121)
    plt.title('until Feb '+str(year))
    tree_utils.draw_tree(prediction.T, axes=ax, cb=True)
    ax = plt.subplot(122)
    plt.title('before Mar '+str(year)+' (red) + season '+str(year)+"/"+str(year+1)+" (cyan)")
    tree_utils.draw_tree(combined_data.T, axes=ax, cb=False)
    plt.tight_layout()
    plt.savefig(tree_figure_folder+base_name+'_'+method[0]+method[1]+'_'+name_mod+'.pdf')


# perform additional analysis on the tree and the prediction
if params.analysis:
    # calculate the fitness differentials for each internal branch and associate with 
    # different types of mutations that happen on these branches
    dfit = []
    for node in prediction.non_terminals:
        for child in node.clades:
            delta_fitness = child.mean_fitness - node.mean_fitness