bootstrap_idx]: null_low_divergence_pair_counts[bootstrap_idx][ null_pair] = 0 null_low_divergence_pair_counts[bootstrap_idx][ null_pair] += 1 divergence_matrices[species_name] = snp_substitution_matrix # # low divergence strains across species # # samples species_names = [] sample_sizes = [] for species_name in species_phylogeny_utils.sort_phylogenetically( divergence_matrices.keys()): species_names.append(species_name) sample_sizes.append(divergence_matrices[species_name].shape[0]) # sort in descending order of sample size # Sort by num haploids #sample_sizes, species_names = zip(*sorted(zip(sample_sizes, species_names),reverse=True)) sys.stderr.write("Postprocessing %d species...\n" % len(species_names)) #################################################### # # Set up Figure (1 panels, arranged in 1x1 grid) # ####################################################
closest_syn_singleton_vector), numpy.array( closest_syn_difference_vector), numpy.array( closest_syn_opportunity_vector), numpy.array( closest_non_singleton_vector), numpy.array( closest_non_difference_vector), numpy.array( closest_non_opportunity_vector) #print numpy.array(closest_opportunity_vector) # # low divergence strains across species # # samples species_names = [] sample_sizes = [] for species_name in species_phylogeny_utils.sort_phylogenetically(data.keys()): species_names.append(species_name) sample_sizes.append(len(data[species_name][0])) # sort in descending order of sample size # Sort by num haploids #sample_sizes, species_names = zip(*sorted(zip(sample_sizes, species_names),reverse=True)) sys.stderr.write("Postprocessing %d species...\n" % len(species_names)) divergences = numpy.logspace(-4, -1, 10) #################################################### # # Set up Figure (1 panels, arranged in 1x1 grid) #
if len(ld_map) > 0: distances, rsquared_numerators, rsquared_denominators, ns, intergene_distances, intergene_rsquared_numerators, intergene_rsquared_denominators, intergene_ns, control_rsquared_numerators, control_rsquared_denominators, control_n, pi = ld_map[ ('largest_clade', '4D')] if True: passed_species.append(species_name) sample_sizes.append(len(snp_samples)) else: sys.stderr.write("%s intergene LD too high: %g (%g)\n" % (species_name, control_rsquared, rsquareds[0])) sample_sizes = numpy.array(sample_sizes) passed_species = species_phylogeny_utils.sort_phylogenetically( passed_species, first_entry=focal_speciess[0], second_sorting_attribute=(-1 * sample_sizes)) #passed_species = species_phylogeny_utils.sort_phylogenetically(passed_species) num_passed_species = len(passed_species) inconsistency_axis.plot([1], [-1], '-', color=focal_colors[0], linewidth=1, alpha=1, label=figure_utils.get_pretty_species_name( focal_speciess[0], include_number=False)) inconsistency_axis.plot([1], [-1], '-', color=focal_colors[1],
# # low divergence strains across species # # samples species_names = [] sample_sizes = [] for species_name in divergence_matrices.keys(): species_names.append(species_name) if species_name == 'Bacteroides_vulgatus_57955': sample_sizes.append(-1000) else: sample_sizes.append(-divergence_matrices[species_name].shape[0]) sorted_species_names = species_phylogeny_utils.sort_phylogenetically( divergence_matrices.keys(), first_entry='Bacteroides_vulgatus_57955', second_sorting_attribute=sample_sizes) species_names = [] sample_sizes = [] for species_name in reversed(sorted_species_names): species_names.append(species_name) sample_sizes.append(divergence_matrices[species_name].shape[0]) # sort in descending order of sample size # Sort by num haploids #sample_sizes, species_names = zip(*sorted(zip(sample_sizes, species_names),reverse=True)) sys.stderr.write("Postprocessing %d species...\n" % len(species_names)) print "Analyzing %d species with %d or more QP samples" % (len(species_names), min_sample_size)
ld_map = calculate_linkage_disequilibria.load_ld_map(species_name) if len(ld_map) > 0: distances, rsquared_numerators, rsquared_denominators, ns, intergene_distances, intergene_rsquared_numerators, intergene_rsquared_denominators, intergene_ns, control_rsquared_numerators, control_rsquared_denominators, control_n, pi = ld_map[ ('largest_clade', '4D')] if True: passed_species.append(species_name) sample_sizes.append(len(snp_samples)) else: sys.stderr.write("%s intergene LD too high: %g (%g)\n" % (species_name, control_rsquared, rsquareds[0])) sorted_species_names = species_phylogeny_utils.sort_phylogenetically( passed_species, first_entry='Bacteroides_vulgatus_57955', second_sorting_attribute=sample_sizes) #passed_species = species_phylogeny_utils.sort_phylogenetically(passed_species) num_passed_species = len(passed_species) inconsistency_axis.plot([1], [-1], 'b-', linewidth=1, alpha=1, label=focal_species) inconsistency_axis.plot([1], [-1], 'r-', linewidth=0.5, alpha=0.3, label='Other species')