joshwlambert / DAISIEmainland

Simulate phylogenetic data on islands with a evolving mainland pool

Home Page:https://joshwlambert.github.io/DAISIEmainland/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: mainland with 1 clade

richelbilderbeek opened this issue · comments

Dear DAISIEmainland maintainer,

Thanks for DAISIEmainland and its many tests to ensure its correctness!

Here I suggest to loosen up a contraint, as I feel (and tested informally) that this is not a real constraint.
Currently, m (the number of mainland clades) has to be more than 1 (i.e. at least 2).
I suggest to allow m to be more than zero (i.e. at least 1), as this nicely matches the examples as given in the (excellent!) PDF in inst/extdata.

In code, I suggest to make the following test pass:

test_that("sim_island_with_mainland with 1 mainland clade", {
  expect_silent(
    sim_island_with_mainland(
      total_time = 1, # Irrelevant
      m = 1, # Number of mainland clades
      island_pars = c(1, 1, 10, 0.1, 1), # Irrelevant
      mainland_ex = 1, # Irrelevant
      mainland_sample_prob = 1, # Irrelevant
      mainland_sample_type = "undiscovered", # Irrelevant
      replicates = 1 # Irrelevant
    )
  )
})

I have checked in the code if replacing testit::assert(m > 1) by testit::assert(m >= 1) gave any problems, but no, that worked great!

I'd be happy to do the replacement myself, but I want to be sure I do not overlook something here :-)

I've added this on the branch richel_allow_1_mainland_clade with commit 4005805 (in the case I need to revert this myself :-) )

Note that I do feel that, when using only 1 clade, the mainland extinction rate must be zero. I am unsure if this is correct. I do understand that if the one species goes extinct, there needs to be a new species somewhere (and now the code will give an error, e.g. the code below)

  mainland <- sim_mainland(
    total_time = 100,
    m = 1,
    mainland_ex = 1)

gives:

Error in sample.int(length(x), size, replace, prob) : 
  invalid first argument 

as

branch_spec <- DDD::sample2(spec_id_sample, 1)

is called with spec_id_sample is NULL.

@richelbilderbeek Thanks for the great start on this issue, I will use this to complete the issue.

Issue finished, will close when merged to main.