示例#1
0
        for ifr, fragment in enumerate(fragments):
            if VERBOSE >= 1:
                print pname, fragment

            dg, ind, block_length, L = \
                    patient.get_divergence_trajectory_local(fragment,
                                                            block_length=block_length)
            ds, ind, block_length, L = \
                    patient.get_diversity_trajectory_local(fragment,
                                                           block_length=block_length)
            patient.dg = dg
            patient.ds = ds
            patient.ind = ind
            patient.L = L
            patient.block_length = block_length

            if use_coverage:
                (covt, ind2) = patient.get_coverage_trajectories(fragment)
                if set(ind).symmetric_difference(set(ind2)):
                    raise ValueError(
                        'Indices for allele freqs and coverage differ!')
                patient.covt = covt

            if plot:
                plot_divdiv_trajectory(patient, VERBOSE=VERBOSE)

    if plot:
        plt.ion()
        plt.show()
        for ifr, fragment in enumerate(fragments):
            if VERBOSE >= 1:
                print pname, fragment

            dg, ind, block_length, L = \
                    patient.get_divergence_trajectory_local(fragment,
                                                            block_length=block_length)
            ds, ind, block_length, L = \
                    patient.get_diversity_trajectory_local(fragment,
                                                           block_length=block_length)
            patient.dg = dg
            patient.ds = ds
            patient.ind = ind
            patient.L = L
            patient.block_length = block_length

            if use_coverage:
                (covt, ind2) = patient.get_coverage_trajectories(fragment)
                if set(ind).symmetric_difference(set(ind2)):
                    raise ValueError('Indices for allele freqs and coverage differ!')
                patient.covt = covt

            if plot:
                plot_divdiv_trajectory(patient, VERBOSE=VERBOSE)

       
    if plot:   
        plt.ion()
        plt.show()

示例#3
0
        patients = patients.iloc[patients.index.isin(pnames)]

    if not fragments:
        fragments = ['F' + str(i) for i in xrange(1, 7)]
    if VERBOSE >= 2:
        print 'fragments', fragments

    for pname, patient in patients.iterrows():
        patient = Patient(patient)
        patient.discard_nonsequenced_samples()

        for fragment in fragments:
            if VERBOSE >= 1:
                print pname, fragment

            covt, ind = patient.get_coverage_trajectories(fragment,
                                                          use_PCR1=use_PCR1)
            samples = patient.samples.iloc[ind]
            times = patient.times[ind]
            ntemplates = samples['n templates']

            if plot is not None:
                import matplotlib.pyplot as plt

                if plot in ('2D', '2d', ''):
                    labels = [
                        str(t) + ': ' + s
                        for (t, s) in izip(times, samples.index)
                    ]
                    legtitle = 'Time from transmission [days]: sample name'
                    plot_coverage_trajectories(times,
                                               covt,
        patients = patients.iloc[patients.index.isin(pnames)]

    if not fragments:
        fragments = ['F'+str(i) for i in xrange(1, 7)]
    if VERBOSE >= 2:
        print 'fragments', fragments

    for pname, patient in patients.iterrows():
        patient = Patient(patient)
        patient.discard_nonsequenced_samples()

        for fragment in fragments:
            if VERBOSE >= 1:
                print pname, fragment

            covt, ind = patient.get_coverage_trajectories(fragment,
                                                          use_PCR1=use_PCR1)
            samples = patient.samples.iloc[ind]
            times = patient.times[ind]
            ntemplates = samples['n templates']

            if plot is not None:
                import matplotlib.pyplot as plt
                
                if plot in ('2D', '2d', ''):
                    labels = [str(t)+': '+s for (t, s) in izip(times, samples.index)]
                    legtitle = 'Time from transmission [days]: sample name'
                    plot_coverage_trajectories(times, covt,
                                               title='Patient '+pname+', '+fragment,
                                               labels=labels,
                                               legendtitle=legtitle,
                                               VERBOSE=VERBOSE)