rosemckeon / honours-project

When rare gametes meet: an individual-based model of polyploid evolution in angiosperms.
https://github.com/rosemckeon/honours-project/blob/master/thesis/_thesis_2417024.pdf
0 stars 0 forks source link

Update sploidy function to fit mimulus life cycle #11

Closed rosemckeon closed 4 years ago

rosemckeon commented 4 years ago
rosemckeon commented 4 years ago

@bradduthie I think I've made sense of this is a realistic way. Can you take a peek and see what you think? I am particularly curious about whether you think I've gone about the germination and reproduction correctly.

A few of the transition values laid in #10 have a sexual reproduction and germination component. So not only does the transition from seed to seedling involve germinations and the transition from seedling or rosette to seed involve reproduction, but also the transition from rosette or seedling to seedling is a property of all the above. Does that make sense? (the formula for the values is laid out on #10 and might be easier to understand).

Soooo, at the moment I've ignored this for the transition from seedling to seedling and treated this purely as survival. I'm not sure this is OK.

I have also done something possibly weird with the transition from rosette to seedling. Here I have assumed that a number of seedlings appear from seeds that were not accounted for in the seed data, using the rosettes of the last generation as the mothers and the whole sexually reproductive population from the last generation as pollen donors.

So in effect, we have seeds being created for the transition from:

Does that make logical sense?

It's all working so—if that's ok—I just need to find good base values now to start running simulations.

bradduthie commented 4 years ago

@rosemckeon -- I think I understand the idea from 10. Of course, it makes sense that the transition from seed to seedling is affected by germination.

I guess I'm a bit confused on how reproduction is coded as in seedling -> rosette, rosette -> seedling, and seedling -> seedling transitions (e.g., what lines am I looking for)? Overall, the transition matrix seems to suggests that seedlings and rosettes can produce new seeds or seedlings in t + 1 (depending on germination), while surviving seedlings become rosettes (and rosettes survive to still be rosettes) with some probability.

I think that the transition from seedling to seedling as survival is fine, though the transition matrix seems to suggest that only rosettes survive from one time step to the next (all recruitment for seedlings seems to be from germination?). In other words, that all seedlings either die or become rosettes, and recruitment of new seedlings is entirely due to germination?

I'm not quite sure what you mean by 'not accounted for in the seed data'. Do you mean that you just add a fixed number of seeds in t+1 based on the number of rosettes in t?

Sorry, I'm happy to help by digging into the code. I just want to make sure I'm following the idea first!

rosemckeon commented 4 years ago

@bradduthie thanks, I think you have followed the idea!

For the rosette -> seedling transition I have done as you describe: basically adding another set of seeds which all germinate in t+1 as a proportion of the rosettes in t.

I agree that the matrix does seem to show that seedlings in t+1 are all from germination and not survival — if the method above for rosettes -> seedlings makes sense, I'll do the same for seedlings -> seedlings.

I'm debugging the code changes at the moment, but lines that show what I've done (if that helps make sense of it) are here: https://github.com/rosemckeon/honours-project/blob/5797e0fbd7604a3b5e9381e8ec106934e1d244d8/R/sploidy.R#L201 up to 221. There you'll see the seeds created from reproduction germinate, and in the next clause, the rosettes from the previous generation get manipulated into seeds that germinate too.

bradduthie commented 4 years ago

Looks good @rosemckeon -- also, if you're compiling this as an R package and importing libraries, like dplyr, then no need to call explicitly from the line as in L206

dplyr::mutate(life_stage = 2)

The package should load dplyr and all the relevant functions, so mutate(life_stage = 2) should work.

rosemckeon commented 4 years ago

@bradduthie I read somewhere it was good practice to use namespacing and I quite like how it's a reminder of which libraries are needed for each function. I've also had a few issues in other scripts with some stats packages masking some of the dplyr functions. So, I've just begun doing this out of habit now!

I think I've also used Imports in the description file too rather than Depends, so the packages are only loaded and not attached. I might change that.

rosemckeon commented 4 years ago

I've realised this needs some more attention. For instance, at the moment seed count, at the beginning of a generation depends on seed survival using trans[1,1]. Then after germination, some seeds do not germinate and they stay in the bank while the rest continue to be seedlings at a rate of trans[2,1]. So seed number in t+1 is actually depending on more than just trans[1,1]. Therefore it's wrong. That probability is calculated from figures that already take non-germinations into account.

bradduthie commented 4 years ago

Okay @rosemckeon -- is there a way to get the individual parameter values from the paper (i.e., not use the transition matrix directly, but use the germination and survival probabilities)? If not, maybe just use some reasonable values based on what you know about the biology of the system.

rosemckeon commented 4 years ago

@bradduthie Yep, they provided all the base values used to calculate the transition values. So I've just pushed some update that uses a mixture of those and the transition matrix to make sure everything is in order. I've also added a maximum seed longevity and carrying capacity as well, because the matrix is still in growth it was getting out of hand over more than 50 generations. Just debugging these updates now!

bradduthie commented 4 years ago

All sounds good @rosemckeon !