コード例 #1
0
  # Create two files, 
    # a map file, giving the map positions
    # a stats file, that give stats for each locus, for quality control purposes

map_chum_08 = Map('chum_08_mst', 'mst', file_path = "/olympus/WORK/WAPLES/Stacks_mapping/Chum_data/mst/chum_08_iter0_mstmap.map")
write_generic_map("/olympus/WORK/WAPLES/Stacks_mapping/Chum_data/psv/chum_08_finalmap.txt", map_chum_08)


#Examine number of crossovers 
# Perhaps read genotype directly from the mstmap input file.
# read mst map output file as above or with parse_map_file.
# kick out LG and loci sitting alone
# How to best count the number of crossovers along a LG???
# need to switch alleles
ini_map, num_loci_on_lg = parse_map_file_MST("Y:\WORK\WAPLES\Stacks_mapping\Chum_data\mst\chum_08_iter0_mstmap.map")
int_arr = convert_genotypes_to_int_array(mappable_08, ini_map)

# This should be move into the psv_working pipeline, so that stats_08 is not needed here (it cannot be pickled).
def write_stats(filename, stats):
    with open(filename, 'w') as OUTFILE:
        for catID, values in stats.items():
            OUTFILE.write("{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\n".format(
                catID, 
                values.epsilon,
                values.best_model,
                values.best_likelihood,
                values.second_best_model,
                values.second_best_likelihood,
                values.x1_seg_pval,
                values.x2_seg_pval
                )
コード例 #2
0
# Go to Rqtl, rebuild linkage groups







#Parameters


genotypes_of_locus = switchAlleles.combine_mappable_loci(mappable)

ini_map, loci_on_lg = switchAlleles.parse_map_file(linkage_map_file)

int_arr = switchAlleles.convert_genotypes_to_int_array(genotypes_of_locus, ini_map)

num_loci = int_arr.shape[0]
num_pairs =  int((num_loci * (num_loci-1))/2)
pairs = itertools.combinations(int_arr, 2)

#import timeit
#timeit.timeit('next(switchAlleles.getR(pairs))', setup = "import switch_allele_functions as switchAlleles; from __main__ import int_arr; from __main__ import pairs", number = 100000)

R = numpy.fromiter(switchAlleles.getR(pairs), dtype = numpy.float64, count = num_pairs)

pairs = itertools.combinations(int_arr, 2)
NR = numpy.fromiter(switchAlleles.getNR(pairs), dtype = numpy.float64, count = num_pairs)

ml_R_frac = switchAlleles.get_ml_R_frac(R = R, NR = NR)
Z = switchAlleles.get_LOD(R = R, NR = NR, R_frac = ml_R_frac)