Skip to content

Commit

Permalink
for #89 @bradduthie does this make sense to do?
Browse files Browse the repository at this point in the history
  • Loading branch information
Rose McKeon committed Jul 31, 2019
1 parent 90c957f commit e7ccaa3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
16 changes: 12 additions & 4 deletions R/disturploidy.R
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,15 @@ disturploidy <- function(
if(nrow(seeds) > 0){
tic("Germination")
# decide which seeds germimate
seeds <- seeds %>% germinate(
germination_prob
)
if(seed_survival_prob == 0){

This comment has been minimized.

Copy link
@bradduthie

bradduthie Jul 31, 2019

Collaborator

This looks fine @rozeykex -- though would the same be accomplished by setting seed_survival_prob <- 0 and germination_prob <- 1 (i.e., are you now forcing the latter when you set the former)?

# we decided the germination fate already to reduce computation
# so germinate all seeds
seeds <- seeds %>% germinate(1)
message(" Germinating all seeds (germination fate already decided).")
} else {
# germination needs to happen as usual
seeds <- seeds %>% germinate(germination_prob)
}
new_juveniles <- seeds %>% filter(
life_stage == 1
)
Expand Down Expand Up @@ -461,7 +467,9 @@ disturploidy <- function(
genome_size,
ploidy_prob,
mutation_rate,
grid_size
grid_size,
germination_prob,
seed_survival_prob
)
# make sure we have some new seeds
# (stop any mutate errors)
Expand Down
11 changes: 10 additions & 1 deletion R/functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ reproduce <- function(
genome_size = 10,
ploidy_prob = .01,
mutation_rate = .001,
grid_size
grid_size = 100,
germination_prob = .5,
seed_survival_prob = 0
){
# make sure we have the right kind of parameters
stopifnot(
Expand Down Expand Up @@ -190,6 +192,13 @@ reproduce <- function(
}
message(" ", nrow(zygotes), " zygotes created in TOTAL.")
if(nrow(zygotes) > 0){
# see if we can reduce computation and decide the germination fate now
if(seed_survival_prob == 0){
# seeds with genomes will not persist so we don't need to fill them
# we'll check for this at the germination stage too
zygotes <- zygotes %>% survive(germination_prob)
message(" ", nrow(zygotes), " zygotes destined to become seeds that will germinate.")
}
# make sure all the new zygotes become seeds with genetic info
seeds <- create_seeds(
zygotes, adults, generation, genome_size, mutation_rate
Expand Down

4 comments on commit e7ccaa3

@bradduthie
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall @rozeykex -- I'll push the output file from yesterday's simulations, though I suspect that they're now outdated?

@bradduthie
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take that back -- simulations still running.

@rosemckeon
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking @bradduthie. I'm not forcing germination prob to 1 when seed survival == 0. Although it looks like that at first! Instead, when seed survival is 0 (so no ungerminated seeds will survive and therefore don't need genomes), I'm deciding the germination fate at the end of zygote creation with the correct germination probability. Then only those that are destined to germinate survive to become seeds and get genomes added, meaning I can allow all seeds to germinate in this case and it gives the same effect but reduces time to compute by 25%.

I think I referenced the wrong commit - the right one had some explanation of my thinking!

@rosemckeon
Copy link
Owner

@rosemckeon rosemckeon commented on e7ccaa3 Jul 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your sims are probably not useful now though! I cancelled the other ones I had going yesterday, feel free to shut those ones off @bradduthie.

Please sign in to comment.