예제 #1
0
def create_het_distribution(
    seqs, distrib_fhand=None, plot_fhand=None, summary_fhand=None, group_kind=None, groups=None, ploidy=2
):
    """It creates the distribution of the heterozygosity
    (not takes in account ref allele)"""
    title = "heterozygosity"
    if groups and group_kind:
        title = "heterozygosity (%s: %s)" % (group_kind, ",".join(groups))

    hets = CachedArray("f")
    for seq in seqs:
        for snv in seq.get_features("snv"):
            if not group_kind and "heterozygosity" in snv.qualifiers:
                het = snv.qualifiers["heterozygosity"]
            else:
                het = calculate_heterozygosity(snv, ploidy, group_kind=group_kind, groups=groups)
            if het is not None:
                hets.append(het)
    if list(hets):
        create_distribution(
            hets,
            labels={"title": title},
            distrib_fhand=distrib_fhand,
            bins=None,
            plot_fhand=plot_fhand,
            range_=None,
            summary_fhand=summary_fhand,
            calculate_freqs=False,
            remove_outliers=False,
        )
예제 #2
0
def create_maf_distribution(
    seqs, distrib_fhand=None, plot_fhand=None, summary_fhand=None, groups=None, group_kind=None
):
    "It creates the distribution of the maf (not takes in account ref allele)"
    title = "maf"
    if groups and group_kind:
        title = "maf (%s: %s)" % (group_kind, ",".join(groups))

    mafs = CachedArray("f")
    for seq in seqs:
        for snv in seq.get_features("snv"):
            maf = calculate_maf_frequency(snv, groups=groups, group_kind=group_kind)
            if maf:
                mafs.append(maf)
    if list(mafs):
        create_distribution(
            mafs,
            labels={"title": title},
            distrib_fhand=distrib_fhand,
            bins=None,
            plot_fhand=plot_fhand,
            range_=None,
            summary_fhand=summary_fhand,
            calculate_freqs=False,
            remove_outliers=False,
        )
예제 #3
0
def create_pic_distribution(
    seqs, distrib_fhand=None, plot_fhand=None, summary_fhand=None, read_groups=None, group_kind=None, groups=None
):
    "It creates the distribution of the pic (not takes in account ref allele)"
    title = "pic"
    if groups and group_kind:
        title = "pic (%s: %s)" % (group_kind, ",".join(groups))

    pics = CachedArray("f")
    for seq in seqs:
        for snv in seq.get_features("snv"):
            if not group_kind and "pic" in snv.qualifiers:
                pic = snv.qualifiers["pic"]
            else:
                pic = calculate_pic(snv, group_kind=group_kind, groups=groups)
            if pic is not None:
                pics.append(pic)
    if list(pics):
        create_distribution(
            pics,
            labels={"title": title},
            distrib_fhand=distrib_fhand,
            bins=None,
            plot_fhand=plot_fhand,
            range_=None,
            summary_fhand=summary_fhand,
            calculate_freqs=False,
            remove_outliers=False,
        )