예제 #1
0
def calc_stats_total(af_lst, callable_sites):

    segs = len(af_lst)
    theta_w = pg.thetaW(n, segs)
    theta_w_site = theta_w / callable_sites

    pi = pg.pi_tajima(n, af_lst)
    pi_site = pi / callable_sites

    tajd = pg.TajimasD(n, segs, theta_w, pi)

    if tajd is None:
        tajd = 'NA'

    return callable_sites, segs, theta_w_site, pi_site, tajd
예제 #2
0
def calc_stats_region(pop, chrom, feature_id, feature_type, af_lst, callable_sites, out):

    segs = len(af_lst)
    theta_w = pg.thetaW(n, segs)
    theta_w_site = theta_w / callable_sites

    pi = pg.pi_tajima(n, af_lst)
    pi_site = pi / callable_sites

    tajd = pg.TajimasD(n, segs, theta_w, pi)

    if tajd is None:
        tajd = 'NA'

    print(pop, chrom, feature_id, feature_type, callable_sites, segs, theta_w_site, pi_site, tajd, sep='\t', file=out)
예제 #3
0
def calc_stats_chr(pop, af_lst, chrom, callable_file, out):

    callable_sites = count_callable(callable_file, chrom)

    segs = len(af_lst)
    theta_w = pg.thetaW(n, segs)
    theta_w_site = theta_w / callable_sites[1]

    pi = pg.pi_tajima(n, af_lst)
    pi_site = pi / callable_sites[1]

    tajd = pg.TajimasD(n, segs, theta_w, pi)

    if tajd is None:
        tajd = 'NA'

    print(pop, chrom, callable_sites[0], callable_sites[1], segs, theta_w_site, pi_site, tajd, sep='\t', file=out)

    return callable_sites[0], callable_sites[1]
예제 #4
0
            total_af += af

            sites = calc_stats_chr(args.pop_id, af, c, args.callable, outfile)
            total_sites += sites[0]
            total_callable += sites[1]

            del af[:]

        if args.sfs:
            for c in total_ac:
                sfs[min(n - c, c)] += 1

            sfs[0] += (total_callable - len(total_ac))

        S = len(total_af)
        thetaw = pg.thetaW(n, S)
        thetaw_site = thetaw / total_callable
        pi_taj = pg.pi_tajima(n, total_af)
        pisite = pi_taj / total_callable
        taj_d = pg.TajimasD(n, S, thetaw, pi_taj)

        print(args.pop_id, 'Total', total_sites, total_callable, S, thetaw_site, pisite, taj_d, sep='\t', file=outfile)

if args.bed:
    compressed = False
    bed_dict = {}

    wwss_alleles = [('A', 'T'), ('T', 'A'), ('C', 'G'), ('G', 'C')]

    ac_dict = {}
    af_dict = {}