Exemplo n.º 1
0
 def _run_msprime_coalescent_stats(self, args):
     print("\t msprime:", args)
     runner = cli.get_mspms_runner(args.split())
     sim = runner.get_simulator()
     rng = msprime.RandomGenerator(random.randint(1, 2**32 - 1))
     sim.set_random_generator(rng)
     num_populations = sim.get_num_populations()
     replicates = runner.get_num_replicates()
     num_trees = [0 for j in range(replicates)]
     time = [0 for j in range(replicates)]
     ca_events = [0 for j in range(replicates)]
     re_events = [0 for j in range(replicates)]
     mig_events = [None for j in range(replicates)]
     for j in range(replicates):
         sim.reset()
         sim.run()
         num_trees[j] = sim.get_num_breakpoints() + 1
         time[j] = sim.get_time() / 4  # Convert to coalescent units
         ca_events[j] = sim.get_num_common_ancestor_events()
         re_events[j] = sim.get_num_recombination_events()
         mig_events[j] = [
             r for row in sim.get_num_migration_events() for r in row
         ]
     d = {
         "t": time,
         "num_trees": num_trees,
         "ca_events": ca_events,
         "re_events": re_events
     }
     for j in range(num_populations**2):
         events = [mig_events[k][j] for k in range(replicates)]
         d["mig_events_{}".format(j)] = events
     df = pd.DataFrame(d)
     return df
Exemplo n.º 2
0
 def _run_msprime_coalescent_stats(self, args):
     print("\t msprime:", args)
     runner = cli.get_mspms_runner(args.split())
     sim = runner.get_simulator()
     rng = msprime.RandomGenerator(random.randint(1, 2**32 - 1))
     sim.set_random_generator(rng)
     num_populations = sim.get_num_populations()
     replicates = runner.get_num_replicates()
     num_trees = [0 for j in range(replicates)]
     time = [0 for j in range(replicates)]
     ca_events = [0 for j in range(replicates)]
     re_events = [0 for j in range(replicates)]
     mig_events = [None for j in range(replicates)]
     for j in range(replicates):
         sim.reset()
         sim.run()
         num_trees[j] = sim.get_num_breakpoints() + 1
         time[j] = sim.get_time() / 4  # Convert to coalescent units
         ca_events[j] = sim.get_num_common_ancestor_events()
         re_events[j] = sim.get_num_recombination_events()
         mig_events[j] = [
             r for row in sim.get_num_migration_events() for r in row]
     d = {
         "t": time, "num_trees": num_trees,
         "ca_events": ca_events, "re_events": re_events}
     for j in range(num_populations**2):
         events = [mig_events[k][j] for k in range(replicates)]
         d["mig_events_{}".format(j)] = events
     df = pd.DataFrame(d)
     return df