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

Suggest: uniform 'island_replicates' datatype

richelbilderbeek opened this issue · comments

Dear DAISIEmainland maintainers,

Thanks for DAISIEmainland as well as its increasing clarity in its data types.

The data type called island_replicates, however, has two different layouts, hence I will recommend to change one of the two.

To start: format_to_daisie_data is a function that works on a island_replicates, as is created in the sim_island_with_mainland function:

sim_island_with_mainland <- function(
  #...
) {
  # ...
  island_replicates <- list()

  for (rep in seq_len(replicates)) {
    # ...
    island_replicates[[rep]] <- full_list
  }

  # ...
  daisie_data <- format_to_daisie_data(
    island_replicates = island_replicates,
    # ...
  )

  # ...
}

Zooming on on format_to_daisie_data, the island_replicates are modified and then used in format_to_daisie_data_core with the same name:

format_to_daisie_data <- function(island_replicates,
                                  total_time,
                                  m) {
  # Good: check input
  DAISIEmainland::check_island_replicates(island_replicates)

  
  ideal_island_replicates <- list()
  empirical_island_replicates <- list()
  for (i in seq_along(island_replicates)) {
    # ...
  }

  # here, 'island_replicates' is of a different type!
  # Suggest: emperical_or_ideal_island_replicates (yes, it is an awkwardly long name)
  ideal_islands <- format_to_daisie_data_core(
    island_replicates = ideal_island_replicates, 
    total_time = total_time,
    m = m)

  # here, 'island_replicates' is of a different type!
  # Suggest: emperical_or_ideal_island_replicates (yes, it is an awkwardly long name)
  empirical_islands <- format_to_daisie_data_core(
    island_replicates = empirical_island_replicates,
    total_time = total_time,
    m = m)

  #...
  daisie_data
}

I suggest that format_to_daisie_data_core uses a emperical_or_ideal_island_replicates (yes, it is an awkwardly long name) as its input, to ensure to have uniform data types (#38, #37).

@joshwlambert what do you think?

The awkward name can be prevented by refactoring sim_island_with_mainland. For examples, making island_replicates a list of island would be a clean step in the right direction.