Example #1
0
    # Load gene coverage information for species_name
    sys.stderr.write("Loading pangenome data for %s...\n" % species_name)
    dummy_samples, gene_names, gene_presence_matrix, gene_depth_matrix, marker_coverages, gene_reads_matrix =     parse_midas_data.parse_pangenome_data(species_name,allowed_samples=snp_samples, disallowed_genes=shared_pangenome_genes)
    sys.stderr.write("Done!\n")
    
    desired_triplet_idxs = []
    for dummy1, initial_sample, middle_sample, final_sample in triplet_map[species_name]:
        panel_idx+=1 

        if (initial_sample in dummy_samples) and (middle_sample in dummy_samples) and (final_sample in dummy_samples):
            
            initial_idx = numpy.nonzero(dummy_samples==initial_sample)[0][0]
            middle_idx = numpy.nonzero(dummy_samples==middle_sample)[0][0]
            final_idx = numpy.nonzero(dummy_samples==final_sample)[0][0]
    
            copynum_trajectories = gene_diversity_utils.calculate_triplet_gene_copynums(gene_depth_matrix, marker_coverages, initial_idx, middle_idx, final_idx)
    
            visnos = numpy.array([1,2,3])
    
            for i in xrange(0,len(copynum_trajectories)):
            
                cs = numpy.clip(copynum_trajectories[i],5e-02,2)
                
                sfs_axes[panel_idx].plot(visnos, cs,'.-',alpha=0.5,markersize=2,markeredgewidth=0)
    
    
            sfs_axes[panel_idx].set_ylabel('%s\n%s' % (figure_utils.get_abbreviated_species_name(species_name), initial_sample))
    
fig.savefig('%s/haploid_triplet_gene_sweeps.png' % (parse_midas_data.analysis_directory),bbox_inches='tight',dpi=300)
sys.stderr.write("Done!\n")
Example #2
0
    # Plot joint SFS!
    for pair_idx in xrange(0, len(triplet_map[species_name])):

        dummy, sample_i, sample_j, sample_k = triplet_map[species_name][
            pair_idx]

        panel_idx += 1

        freqs = triplet_freqs[pair_idx]

        visnos = numpy.array([1, 2, 3])

        for i in xrange(0, len(freqs)):
            sfs_axes[panel_idx].plot(visnos,
                                     freqs[i],
                                     '.-',
                                     alpha=0.5,
                                     markersize=2,
                                     markeredgewidth=0)

        sfs_axes[panel_idx].set_ylabel(
            '%s\n%s' %
            (figure_utils.get_abbreviated_species_name(species_name),
             sample_i))

fig.savefig('%s/haploid_triplet_sweeps.png' %
            (parse_midas_data.analysis_directory),
            bbox_inches='tight',
            dpi=300)
sys.stderr.write("Done!\n")
snp_axes = []
zoomed_snp_axes = []
###################
#
# SNP change panel
#
###################
for example_idx in xrange(0, len(examples)):
    #
    snp_axis = plt.Subplot(divergence_fig, divergence_grid[example_idx, 0])
    divergence_fig.add_subplot(snp_axis)
    #
    snp_axis.set_ylabel('Divergence, $d$')
    snp_axis.set_xlabel('%s QP host pairs (random, $n=%d$)' %
                        (figure_utils.get_abbreviated_species_name(
                            examples[example_idx]), num_random_pairs))
    snp_axis.set_ylim([1e-06, 1e-01])
    snp_axis.set_xlim([-512, 5])
    snp_axis.set_xticks([])
    #
    snp_axis.spines['top'].set_visible(False)
    snp_axis.spines['right'].set_visible(False)
    snp_axis.get_xaxis().tick_bottom()
    snp_axis.get_yaxis().tick_left()
    #
    snp_axes.append(snp_axis)
    #
    zoomed_snp_axis = plt.Subplot(divergence_fig, divergence_grid[example_idx,
                                                                  1])
    divergence_fig.add_subplot(zoomed_snp_axis)
    #