Beispiel #1
0
    combined_data = test_flu.make_combined_data(prediction, test_data,
                                                otherseqsnames)

    method = methods[0]
    color_internal = True

    if params.flutype.startswith('H3N2') and year in laessig_prediction:
        seq_labels = {
            prediction.best_node(method=method[0], nodes=method[2]).name: '*',
            laessig_prediction[year].name: "L&L"
        }
    else:
        seq_labels = {prediction.best_node().name: '*'}

    tree_utils.label_nodes(prediction.T, seq_labels)
    tree_utils.erase_color(prediction.T)
    tree_utils.erase_color(combined_data.T)
    tree_utils.plot_prediction_tree(prediction, internal=color_internal)
    plt.title(
        "predicting " + params.flutype + " season " + str(year) + "/" +
        str(year + 1) + ": " + str(
            np.round(distances[method[0] + method[1]] /
                     distances['average'], 4)))
    #plt.savefig('../figures/'+base_name+'_prediction_'+method[0]+method[1]+'_'+name_mod+'.pdf')

    # 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:
Beispiel #2
0
plt.tight_layout()
tree_utils.plot_prediction_tree(prediction,
                                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' +
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')


        otherseqsnames=[]
    
    # combine the test data, the prediction data and possible other sequences
    # and build a tree
    combined_data = test_flu.make_combined_data(prediction, test_data, otherseqsnames)

    method = methods[0]
    color_internal = True
    
    if params.flutype.startswith('H3N2') and year in laessig_prediction:
        seq_labels = {prediction.best_node(method= method[0], nodes = method[2]).name:'*', laessig_prediction[year].name:"L&L"}
    else:
        seq_labels = {prediction.best_node().name:'*'}
        
    tree_utils.label_nodes(prediction.T, seq_labels)
    tree_utils.erase_color(prediction.T)
    tree_utils.erase_color(combined_data.T)
    tree_utils.plot_prediction_tree(prediction, internal=color_internal)
    plt.title("predicting "+params.flutype+" season "+str(year)+"/"+str(year+1)+": "+
              str(np.round(distances[method[0]+method[1]]/distances['average'],4)))
    #plt.savefig('../figures/'+base_name+'_prediction_'+method[0]+method[1]+'_'+name_mod+'.pdf')
    
    # 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)