mrc-ide / SIMPLEGEN

Simulating Plasmodium Epidemiological and Genetic Data
https://mrc-ide.github.io/SIMPLEGEN/
MIT License
12 stars 0 forks source link

discrepancies with downloading from github vs using load_all() #37

Closed IzzyRou closed 2 years ago

IzzyRou commented 3 years ago

Problem: After deleting all versions of SIMPLEGEN and re-installing, installing package from github via devtools and then using the line “library(SIMPLEGEN)” and confirming simplegen is loaded using the check_simplegen_loaded function, master branch version of functions not working, despite specifying master branch in download. Also this doesn’t happen with develop branch and those updated functions, however prune_transmission_record() returns the error “no survey output detected” . However, cloning repo to local github and using load_all() function works fine. Code section: Notes: could be explained by the wrong branch version of simplegen being loaded, though not sure how as all versions were removed using remove.packages() Reproduction of bug : (For ‘no survey output detected’ error)

install.packages("devtools", repos='http://cran.us.r-project.org')
library(devtools)
remove.packages("SIMPLEGEN")
devtools::install_github("mrc-ide/SIMPLEGEN", ref= "develop")
library(SIMPLEGEN)
check_SIMPLEGEN_loaded()
n_demes <- 1

s <- simplegen_project() %>%
  define_epi_model_parameters(
    H = 1e3,
    M = 1500,
    seed_infections = 50,
    mig_mat = diag(1, 1),
    prob_infection = 0.3,
    prob_acute = seq(1, 0, l = 25),
    prob_AC = 1.0,
    duration_acute = dgeom(1:250, 1 / 50),
    duration_chronic = dgeom(1:250, 1 / 50),
    detectability_microscopy_acute = 0.95,
    detectability_microscopy_chronic = 0.3,
    treatment_seeking_mean = 0,
    infectivity_acute = 1.0,
    infectivity_chronic = 1.0
  )

# define sampling strategy
dfincid05 <-
  data.frame(
    deme = -1 ,
    measure = c("incidence"),
    state = c("A") ,
    diagnostic = c("true") ,
    age_min = c(0) ,
    age_max = c(5),
    inoculations = -1
  )
dfprev210 <-
  data.frame(
    deme = -1 ,
    measure = c("prevalence"),
    state = c("A", "C") ,
    diagnostic = c("true") ,
    age_min = c(2) ,
    age_max = c(10),
    inoculations = -1
  )
df_sample <- rbind(dfincid05, dfprev210)
s <-
define_epi_sampling_parameters(project = s, daily = df_sample)

# simulate from transmission model

s <- sim_epi(
  s,
  max_time = 20 * 365,
  save_transmission_record = TRUE,
  transmission_record_location = "ignore/trans_record.txt",
  overwrite_transmission_record = TRUE
)

# ------------------------------------------------------------------

# prune transmission record
s <- prune_transmission_record(project = s,
                            transmission_record_location = "ignore/trans_record.txt",
                            pruned_record_location = "ignore/pruned_record.txt",
                            overwrite_pruned_record = TRUE)

Doesn't happen when loaded like this instead:

remove.packages("SIMPLEGEN")
devtools:: load_all("/home/gimli/Documents/GitHub/SIMPLEGEN")
check_SIMPLEGEN_loaded()

R configuration: R version 4.0.3 SIMPLEGEN branch: epi_outputs, master, develop Computer used: Windows 10.0.18363

IzzyRou commented 2 years ago

now solved