I ran a single population simulation in SLiM for 50 generations, loaded the SLiM recorded tree sequence file into python and then call pyslim recapitate:
It seems the time scaling is not right for the ancestral part. All the time > 50 is clumped together.
After a look at the source code of recapitate, I think the following line might be problematic.
demography = msprime.Demography.from_tree_sequence(ts)
# must set pop sizes to >0 even though we merge immediately
demography.populations[0].initial_size = 0.0 # <---------------------------------------------
demography.populations[1].initial_size = self.N # <---------------------------------------------
ancestral_name = "ancestral"
derived_names = [pop.name for pop in demography.populations] # <---------------------------------------------
ancestral_metadata = {}
ancestral_metadata["slim_id"] = ts.num_populations
demography.add_population(
name=ancestral_name,
description="ancestral population simulated by msprime",
initial_size=self.N,
extra_metadata=ancestral_metadata,
)
# the split has to come slightly longer ago than slim_generation,
# since that's when all the linages are at, and otherwise the event
# won't apply to them
demography.add_population_split(
np.nextafter(
ts.metadata["SLiM"]["generation"],
2 * ts.metadata["SLiM"]["generation"],
),
derived=derived_names,
ancestral=ancestral_name,
)
kwargs = {}
kwargs["demography"] = demography
recap = msprime.sim_ancestry(initial_state=ts, **kwargs)
rts = pyslim.SlimTreeSequence(recap)
Now it seems to work, but I am not that sure, could you take a look at it? Thanks
I ran a single population simulation in SLiM for 50 generations, loaded the SLiM recorded tree sequence file into python and then call pyslim recapitate:
I checked the node time:
Got this:
It seems the time scaling is not right for the ancestral part. All the time > 50 is clumped together. After a look at the source code of recapitate, I think the following line might be problematic.
https://github.com/tskit-dev/pyslim/blob/55d25fb9021d3d475842b11a97d8fe238e34974d/pyslim/methods.py#L51-L52
I made a few edits:
Now it seems to work, but I am not that sure, could you take a look at it? Thanks