Пример #1
0
def align_upper_pm(peaks, ladder, anchor_pairs, anchor_z):

    # this is another attempt to perform ladder - size standard alignment one peak by one

    anchor_pairs = sorted(anchor_pairs)
    anchor_rtimes, anchor_bpsizes = zip(*anchor_pairs)
    anchor_rtimes = list(anchor_rtimes)
    anchor_bpsizes = list(anchor_bpsizes)
    remaining_sizes = [x for x in ladder['sizes'] if x > anchor_bpsizes[-1]]
    current_sizes = anchor_bpsizes
    order = ladder['order']
    z = estimate_z(anchor_rtimes, anchor_bpsizes, order).z
    f = ZFunc(peaks, current_sizes, anchor_pairs, estimate=True)

    pairs, rss = f.get_pairs(z)

    while True:

        if not remaining_sizes:
            return pairs, z, rss, f

        current_sizes.append(remaining_sizes.pop(0))
        f.set_sizes(current_sizes)
        score, next_z = minimize_score(f, z, order)
        pairs, rss = f.get_pairs(z)
        if rss < 100:
            z = next_z
        if is_verbosity(5):
            plot(f.rtimes, f.sizes, z, pairs)
Пример #2
0
def align_lower_pm(peaks, ladder, anchor_pairs, anchor_z):

    # this is another attempt to perform ladder - size standard alignment one peak by one

    anchor_pairs = sorted(anchor_pairs)
    anchor_rtimes, anchor_bpsizes = zip(*anchor_pairs)
    anchor_rtimes = list(anchor_rtimes)
    anchor_bpsizes = list(anchor_bpsizes)
    remaining_sizes = [x for x in ladder['sizes'] if x < anchor_bpsizes[0]]
    current_sizes = anchor_bpsizes
    z = estimate_z(anchor_rtimes, anchor_bpsizes, 3).z
    f = ZFunc(peaks, current_sizes, anchor_pairs, estimate=True)

    pairs, rss = f.get_pairs(z)

    while True:

        if not remaining_sizes:
            return pairs, z, rss, f

        current_sizes.insert(0, remaining_sizes.pop(-1))
        f.set_sizes(current_sizes)
        score, z = minimize_score(f, z, 3)
        pairs, rss = f.get_pairs(z)
        if is_verbosity(5):
            plot(f.rtimes, f.sizes, z, pairs)
Пример #3
0
def align_upper_pm(peaks, ladder, anchor_pairs, anchor_z):

    # this is another attempt to perform ladder - size standard alignment one peak by one

    anchor_pairs = sorted(anchor_pairs)
    anchor_rtimes, anchor_bpsizes = zip( *anchor_pairs )
    anchor_rtimes = list(anchor_rtimes)
    anchor_bpsizes = list(anchor_bpsizes)
    remaining_sizes = [x for x in ladder['sizes'] if x > anchor_bpsizes[-1]]
    current_sizes = anchor_bpsizes
    order = ladder['order']
    zres = estimate_z(anchor_rtimes, anchor_bpsizes, order)
    z,rss = zres.z, zres.rss
    f = ZFunc(peaks, current_sizes, anchor_pairs)

    while remaining_sizes:

        current_sizes.append( remaining_sizes.pop(0) )
        if ( remaining_sizes and
             (remaining_sizes[-1] - current_sizes[-1]) < 100 and
             (remaining_sizes[0] - current_sizes[-1]) < 11 ):
            current_sizes.append( remaining_sizes.pop(0) )

        f.set_sizes(current_sizes)
        score, next_z = minimize_score(f, z, order)
        next_pairs, next_rss = f.get_pairs(z)

        if (next_rss - rss) < 70:
            z = next_z
            rss = next_rss
            pairs = next_pairs

        if is_verbosity(5):
            plot(f.rtimes, f.sizes, z, pairs )

    # finalize the alignment with stringent criteria
    dp_result = align_dp(f.rtimes, f.sizes, f.similarity, z, rss)
    if dp_result.rss - rss > 50:
        return pairs, z, rss, f
    dp_pairs = [(x[1], x[0]) for x in dp_result.sized_peaks]
    if is_verbosity(5):
        plot(f.rtimes, f.sizes, dp_result.z, dp_pairs)

    return dp_pairs, dp_result.z, dp_result.rss, f
Пример #4
0
def align_upper_pm(peaks, ladder, anchor_pairs, anchor_z):

    # this is another attempt to perform ladder - size standard alignment one peak by one

    anchor_pairs = sorted(anchor_pairs)
    anchor_rtimes, anchor_bpsizes = zip( *anchor_pairs )
    anchor_rtimes = list(anchor_rtimes)
    anchor_bpsizes = list(anchor_bpsizes)
    remaining_sizes = [x for x in ladder['sizes'] if x > anchor_bpsizes[-1]]
    current_sizes = anchor_bpsizes
    order = ladder['order']
    zres = estimate_z(anchor_rtimes, anchor_bpsizes, order)
    z,rss = zres.z, zres.rss
    f = ZFunc(peaks, current_sizes, anchor_pairs)

    while remaining_sizes:

        current_sizes.append( remaining_sizes.pop(0) )
        if ( remaining_sizes and
             (remaining_sizes[-1] - current_sizes[-1]) < 100 and
             (remaining_sizes[0] - current_sizes[-1]) < 11 ):
            current_sizes.append( remaining_sizes.pop(0) )

        f.set_sizes(current_sizes)
        score, next_z = minimize_score(f, z, order)
        next_pairs, next_rss = f.get_pairs(z)

        if (next_rss - rss) < 70:
            z = next_z
            rss = next_rss
            pairs = next_pairs

        if is_verbosity(5):
            plot(f.rtimes, f.sizes, z, pairs )

    # finalize the alignment with stringent criteria
    dp_result = align_dp(f.rtimes, f.sizes, f.similarity, z, rss)
    if dp_result.rss - rss > 50:
        return pairs, z, rss, f
    dp_pairs = [(x[1], x[0]) for x in dp_result.sized_peaks]
    if is_verbosity(5):
        plot(f.rtimes, f.sizes, dp_result.z, dp_pairs)

    return dp_pairs, dp_result.z, dp_result.rss, f
Пример #5
0
def align_lower_pm(peaks, ladder, anchor_pairs, anchor_z):

    # this is another attempt to perform ladder - size standard alignment one peak by one

    anchor_pairs = sorted(anchor_pairs)
    anchor_rtimes, anchor_bpsizes = zip( *anchor_pairs )
    anchor_rtimes = list(anchor_rtimes)
    anchor_bpsizes = list(anchor_bpsizes)
    remaining_sizes = [x for x in ladder['sizes'] if x < anchor_bpsizes[0]]
    current_sizes = anchor_bpsizes
    zscore = estimate_z(anchor_rtimes, anchor_bpsizes, 3)
    z = zscore.z
    rss = zscore.rss
    f = ZFunc(peaks, current_sizes, anchor_pairs)

    while True:

        if not remaining_sizes:
            return pairs, z, rss, f

        current_sizes.insert(0, remaining_sizes.pop(-1))
        f.set_sizes(current_sizes)
        score, next_z = minimize_score(f, z, 3)
        next_pairs, next_rss = f.get_pairs(next_z)

        # if delta rss (current rss - prev rss) is above certain threshold,
        # then assume the latest peak standar is not appropriate, and
        # use previous z and rss
        if (next_rss - rss) > 20:
            current_sizes.pop(0)
        else:
            z = next_z
            rss = next_rss
            pairs = next_pairs

        if is_verbosity(5):
            plot(f.rtimes, f.sizes, z, pairs )
Пример #6
0
def align_lower_pm(peaks, ladder, anchor_pairs, anchor_z):

    # this is another attempt to perform ladder - size standard alignment one peak by one

    anchor_pairs = sorted(anchor_pairs)
    anchor_rtimes, anchor_bpsizes = zip(*anchor_pairs)
    anchor_rtimes = list(anchor_rtimes)
    anchor_bpsizes = list(anchor_bpsizes)
    remaining_sizes = [x for x in ladder['sizes'] if x < anchor_bpsizes[0]]
    current_sizes = anchor_bpsizes
    zscore = estimate_z(anchor_rtimes, anchor_bpsizes, 3)
    z = zscore.z
    rss = zscore.rss
    f = ZFunc(peaks, current_sizes, anchor_pairs)

    while True:

        if not remaining_sizes:
            return pairs, z, rss, f

        current_sizes.insert(0, remaining_sizes.pop(-1))
        f.set_sizes(current_sizes)
        score, next_z = minimize_score(f, z, 3)
        next_pairs, next_rss = f.get_pairs(next_z)

        # if delta rss (current rss - prev rss) is above certain threshold,
        # then assume the latest peak standar is not appropriate, and
        # use previous z and rss
        if (next_rss - rss) > 20:
            current_sizes.pop(0)
        else:
            z = next_z
            rss = next_rss
            pairs = next_pairs

        if is_verbosity(5):
            plot(f.rtimes, f.sizes, z, pairs)