Exemplo n.º 1
0
    patients = load_patients()
    if pnames is not None:
        patients = patients.loc[pnames]

    for pname, patient in patients.iterrows():

        patient = Patient(patient)
        patient.discard_nonsequenced_samples()

        if VERBOSE >= 1:
            print patient.name, roi
    
        if VERBOSE >= 2:
            print 'Get haplotype trajectories'
        try:
            (ht, indt, htseqs) = patient.get_region_count_trajectories(roi[0],
                                                                    VERBOSE=VERBOSE)
        except IOError:
            (ht, indt, htseqs) = patient.get_local_haplotype_count_trajectories(roi,
                                                                    VERBOSE=VERBOSE)
    
        if VERBOSE >= 2:
            print 'Align haplotypes and delete rare ones'
        indht = (ht > 5).any(axis=0)
        ht = ht[:, indht]
        htseqs = htseqs[indht]
        
        # Eliminate time points that are empty after this filter
        ind_keep = ht.any(axis=1)
        indt = indt[ind_keep]
        ht = ht[ind_keep]
    patients = load_patients()
    if pnames is not None:
        patients = patients.loc[pnames]

    data = []
    for pname, patient in patients.iterrows():
        patient = Patient(patient)

        for region in regions:
            if VERBOSE >= 1:
                print patient.name, region

            if VERBOSE >= 2:
                print 'Get haplotype counts'
            (hct, ind, seqs) = patient.get_region_count_trajectories(region,
                                                                     VERBOSE=VERBOSE)
            
            times = patient.times[ind]

            if VERBOSE >= 2:
                print 'Align sequences'
            ali = align_muscle(*seqs, sort=True)
            alim = np.array(ali)

            if VERBOSE >= 2:
                print 'Get distributions'
            ds = get_distance_distributions(hct, alim, VERBOSE=VERBOSE)

            data.append({'pname': pname, 'ds': ds, 't': times,
                         'region': region})
        
Exemplo n.º 3
0
    if pnames is not None:
        patients = patients.loc[pnames]

    for pname, patient in patients.iterrows():

        patient = Patient(patient)
        patient.discard_nonsequenced_samples()

        if VERBOSE >= 1:
            print patient.name, roi

        if VERBOSE >= 2:
            print 'Get haplotype trajectories'
        try:
            (ht, indt,
             htseqs) = patient.get_region_count_trajectories(roi[0],
                                                             VERBOSE=VERBOSE)
        except IOError:
            (ht, indt,
             htseqs) = patient.get_local_haplotype_count_trajectories(
                 roi, VERBOSE=VERBOSE)

        if VERBOSE >= 2:
            print 'Align haplotypes and delete rare ones'
        indht = (ht > 5).any(axis=0)
        ht = ht[:, indht]
        htseqs = htseqs[indht]

        # Eliminate time points that are empty after this filter
        ind_keep = ht.any(axis=1)
        indt = indt[ind_keep]
        ht = ht[ind_keep]