role-model / roleR

R package implementing the RoLE model
https://role-model.github.io/roleR
GNU General Public License v3.0
1 stars 2 forks source link

update roleDataTo/FromCpp to reflect latest version of localComm? #102

Closed diazrenata closed 1 year ago

diazrenata commented 1 year ago

the code for roleDataFrom (orTo)Cpp seems to expect six slots - species_ids, traits, abundance_sp, traits_sp, pi_sp

roleDataFromCpp <- function(data) {
  local <- localComm(data$local$abundance_indv,data$local$species_ids,
                     data$local$traits,
                     data$local$abundance_sp,
                     data$local$traits_sp,data$local$pi_sp)

  meta <- metaComm(data$meta$abundance,data$meta$traits)
  phylo <- rolePhyloFromCpp(data$phylo)

  return(roleData(local,meta,phylo))
}

#' roleDataToCpp
#'
#' @param data some roleData
#'
#' @return for Cpp
#' @export
#'
roleDataToCpp <- function(data) {
  local <- localComm(data$local$abundance_indv, data$local$species_ids,
                     data$local$traits, data$local$abundance_sp,
                     data$local$traits_sp, data$local$pi_sp)

  meta <- metaComm(data$meta$abundance,data$meta$traits)
  phylo <- rolePhyloFromCpp(data$phylo)

  return(roleData(local,meta,phylo))

but the localComm class constructor only asks for four:

localComm <- function(indSpecies, indTrait, indSeqs, spGenDiv) { #indSppTrt, indSeqs, sppGenDiv

So I think these need to be either named or plugged back together so they reflect each other correctly.

This seems like something either @jidec or @ajrominger should weigh in on: what are the desired connections between roleCpp slots and localComm slots?

ajrominger commented 1 year ago

good catch! i'll incorporate this into the changes I'm working on with the roleModel class

ajrominger commented 1 year ago

roleDataFromCpp and roleDataToCpp are no longer used so we're removing them 7f9cc94