Exemplo n.º 1
0
def qq_plot(hdf5_results_file='/home/bv25/data/Ls154/Ls154_results.hdf5',
            png_file_prefix='/home/bv25/data/Ls154/Ls154_results'):
    """
    Plot QQ-plot for a single HDF5 result
    """
    h5f = h5py.File(hdf5_results_file)
    chrom_res_group = h5f['chrom_results']
    pvals = []  # sp.empty(h5f['num_snps'][...])
    i = 0
    for chrom in chrom_res_group.keys():
        if chrom != 'chrom_5':
            crg = chrom_res_group[chrom]
            n = len(crg['ps'])
            #            pvals[i:i + n] = crg['ps'][...]
            pvals.extend(crg['ps'][...].tolist())
            i += n
    pvals = sp.array(pvals)
    quantiles = agr.get_quantiles(pvals)
    log_quantiles = agr.get_log_quantiles(pvals, max_val=7)
    qq_plot_png_filename = png_file_prefix + '_qq.png'
    qq_log_plot_png_filename = png_file_prefix + '_qq_log.png'
    agr.simple_qqplot([quantiles], png_file=qq_plot_png_filename)
    agr.simple_log_qqplot([log_quantiles],
                          png_file=qq_log_plot_png_filename,
                          max_val=7)
Exemplo n.º 2
0
def _calculate_qqplot_data_(pvals,num_dots=1000,max_val=6):
    quantiles = agr.get_quantiles(pvals, num_dots=num_dots)
    exp_quantiles = agr._getExpectedPvalueQuantiles_(num_dots)
    log_quantiles = agr.get_log_quantiles(pvals, num_dots=num_dots, max_val=max_val)
    exp_log_quantiles = scipy.arange(1, num_dots + 1, dtype='single') / (num_dots + 1) * max_val

    quantiles_dict = {'quantiles':quantiles, 'exp_quantiles':exp_quantiles,
            'log_quantiles':log_quantiles, 'exp_log_quantiles':exp_log_quantiles}
    return quantiles_dict
Exemplo n.º 3
0
def _calculate_qqplot_data_(pvals, num_dots=1000, max_val=6):
    quantiles = agr.get_quantiles(pvals, num_dots=num_dots)
    exp_quantiles = agr._getExpectedPvalueQuantiles_(num_dots)
    log_quantiles = agr.get_log_quantiles(pvals,
                                          num_dots=num_dots,
                                          max_val=max_val)
    exp_log_quantiles = scipy.arange(1, num_dots + 1,
                                     dtype='single') / (num_dots + 1) * max_val

    quantiles_dict = {
        'quantiles': quantiles,
        'exp_quantiles': exp_quantiles,
        'log_quantiles': log_quantiles,
        'exp_log_quantiles': exp_log_quantiles
    }
    return quantiles_dict
Exemplo n.º 4
0
def qq_plot(hdf5_results_file='/home/bv25/data/Ls154/Ls154_results.hdf5',
            png_file_prefix='/home/bv25/data/Ls154/Ls154_results'):
    """
    Plot QQ-plot for a single HDF5 result
    """
    h5f = h5py.File(hdf5_results_file)
    chrom_res_group = h5f['chrom_results']
    pvals = []  # sp.empty(h5f['num_snps'][...])
    i = 0
    for chrom in chrom_res_group.keys():
        if chrom !='chrom_5':
            crg = chrom_res_group[chrom]
            n = len(crg['ps'])
#            pvals[i:i + n] = crg['ps'][...]
            pvals.extend(crg['ps'][...].tolist())
            i += n
    pvals = sp.array(pvals)
    quantiles = agr.get_quantiles(pvals)
    log_quantiles = agr.get_log_quantiles(pvals, max_val=7)
    qq_plot_png_filename = png_file_prefix + '_qq.png'
    qq_log_plot_png_filename = png_file_prefix + '_qq_log.png'
    agr.simple_qqplot([quantiles], png_file=qq_plot_png_filename)
    agr.simple_log_qqplot([log_quantiles], png_file=qq_log_plot_png_filename, max_val=7)