Skip to content

Commit

Permalink
Merge pull request #156 from dd-harp/dev
Browse files Browse the repository at this point in the history
Major Update: blood feeding, egg laying, and resource dynamics
  • Loading branch information
smitdave authored Jan 15, 2024
2 parents 46e9f21 + 4e63744 commit bbc74c0
Show file tree
Hide file tree
Showing 146 changed files with 2,490 additions and 1,196 deletions.
91 changes: 60 additions & 31 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,24 @@ S3method(Abiotic,null)
S3method(AreaSpray,null)
S3method(AreaSprayEffectSizes,null)
S3method(AreaSprayEffects,null)
S3method(AvailableBlood,forced)
S3method(AvailableBlood,setup)
S3method(AvailableBlood,static)
S3method(AvailableHabitat,forced)
S3method(AvailableHabitat,simple)
S3method(AvailableHabitat,static)
S3method(AvailableSugar,forced)
S3method(AvailableSugar,static)
S3method(BedNetEffectSizes,lemenach)
S3method(BedNetEffectSizes,null)
S3method(BedNetEffects,null)
S3method(Behavior,forced)
S3method(Behavior,null)
S3method(Bionomics,Ldynamic)
S3method(Bionomics,Mdynamic)
S3method(Bionomics,dynamic)
S3method(Bionomics,setup)
S3method(Bionomics,static)
S3method(Births,zero)
S3method(CareSeeking,null)
S3method(Civil,forced)
Expand All @@ -21,6 +34,10 @@ S3method(Control,static)
S3method(Development,null)
S3method(DistributeBedNets,null)
S3method(EIP,static)
S3method(EggLaying,dynamic)
S3method(EggLaying,setup)
S3method(EggLaying,simple)
S3method(EggLaying,static)
S3method(F_H,SIP)
S3method(F_H,SIS)
S3method(F_H,hMoI)
Expand Down Expand Up @@ -68,43 +85,41 @@ S3method(F_sigma,static)
S3method(HTC,SIP)
S3method(HTC,SIS)
S3method(HTC,hMoI)
S3method(HabitatAvailability,forced)
S3method(HabitatAvailability,null)
S3method(HabitatDynamics,null)
S3method(HabitatSearch,dynamic)
S3method(HabitatSearch,static)
S3method(HumanAvailability,forced)
S3method(HumanAvailability,null)
S3method(HabitatDynamics,static)
S3method(Hydrology,null)
S3method(IRSeffectSizes,null)
S3method(IRSeffects,null)
S3method(LBionomics,basic)
S3method(LBionomics,trace)
S3method(LSMeffectSizes,null)
S3method(LSMeffects,null)
S3method(LocalFrac,dynamic)
S3method(LocalFrac,static)
S3method(MBionomics,GeRM)
S3method(MBionomics,Gtrace)
S3method(MBionomics,RM)
S3method(MBionomics,Ztrace)
S3method(MBionomics,basicM)
S3method(MassMedical,forced)
S3method(MassMedical,null)
S3method(OtherBloodHosts,null)
S3method(OtherBloodHosts,static)
S3method(OviTraps,null)
S3method(OwnBedNet,null)
S3method(Rainfall,null)
S3method(Relative_Humidity,null)
S3method(Resources,forced)
S3method(Resources,null)
S3method(Resources,setup)
S3method(Resources,static)
S3method(Shock,null)
S3method(SprayHouses,null)
S3method(Sugar,null)
S3method(SugarAvailability,forced)
S3method(SugarAvailability,null)
S3method(SugarBaitEffectSizes,null)
S3method(SugarBaitEffects,null)
S3method(SugarBaits,null)
S3method(SugarDynamics,static)
S3method(Temperature,null)
S3method(Transmission,dynamic)
S3method(Transmission,setup)
S3method(Transmission,static)
S3method(TreatHabitats,null)
S3method(UseBedNet,null)
S3method(VectorControl,control)
Expand All @@ -114,7 +129,7 @@ S3method(VectorControlEffectSizes,null)
S3method(VectorControlEffects,control)
S3method(VectorControlEffects,null)
S3method(Visitors,basic)
S3method(Visitors,null)
S3method(Visitors,static)
S3method(Weather,forced)
S3method(Weather,null)
S3method(check_abiotic,forced)
Expand Down Expand Up @@ -155,9 +170,9 @@ S3method(get_inits_X,SIP)
S3method(get_inits_X,SIS)
S3method(get_inits_X,hMoI)
S3method(get_inits_X,trace)
S3method(make_TaR,as_matrix)
S3method(make_TaR,athome)
S3method(make_TaR,xy)
S3method(make_TimeSpent,as_matrix)
S3method(make_TimeSpent,athome)
S3method(make_TimeSpent,xy)
S3method(make_calK,as_matrix)
S3method(make_calK,herethere)
S3method(make_calK,xy)
Expand Down Expand Up @@ -214,7 +229,7 @@ S3method(setup_control,forced)
S3method(setup_control,null)
S3method(travel_malaria,eir)
S3method(travel_malaria,foi)
S3method(travel_malaria,null)
S3method(travel_malaria,static)
S3method(update_inits_L,basic)
S3method(update_inits_L,trace)
S3method(update_inits_MYZ,GeRM_dde)
Expand Down Expand Up @@ -242,6 +257,9 @@ export(Abiotic)
export(AreaSpray)
export(AreaSprayEffectSizes)
export(AreaSprayEffects)
export(AvailableBlood)
export(AvailableHabitat)
export(AvailableSugar)
export(BedNetEffectSizes)
export(BedNetEffects)
export(Behavior)
Expand Down Expand Up @@ -276,16 +294,14 @@ export(F_q)
export(F_sigma)
export(F_tau)
export(HTC)
export(HabitatAvailability)
export(HabitatDynamics)
export(HabitatSearch)
export(HumanAvailability)
export(Hydrology)
export(IRSeffectSizes)
export(IRSeffects)
export(LBionomics)
export(LSMeffectSizes)
export(LSMeffects)
export(LocalFrac)
export(MBionomics)
export(MassMedical)
export(OtherBloodHosts)
Expand All @@ -296,11 +312,10 @@ export(Relative_Humidity)
export(Resources)
export(Shock)
export(SprayHouses)
export(Sugar)
export(SugarAvailability)
export(SugarBaitEffectSizes)
export(SugarBaitEffects)
export(SugarBaits)
export(SugarDynamics)
export(Temperature)
export(Transmission)
export(TreatHabitats)
Expand All @@ -314,13 +329,18 @@ export(approx_equal)
export(checkIt)
export(check_abiotic)
export(check_civil)
export(compute_AvailableHabitat)
export(compute_AvailableHosts)
export(compute_EIR)
export(compute_EIR_full)
export(compute_NI)
export(compute_NI_ix)
export(compute_beta)
export(compute_fqM)
export(compute_fqM_ix)
export(compute_fqZ)
export(compute_fqZ_ix)
export(compute_kappa)
export(compute_local_frac)
export(compute_terms)
export(compute_terms_steady)
Expand Down Expand Up @@ -352,8 +372,9 @@ export(make_MYZpar_Ztrace)
export(make_MYZpar_basicM)
export(make_Omega)
export(make_TaR)
export(make_TaR_athome)
export(make_TaR_xy)
export(make_TimeSpent)
export(make_TimeSpent_athome)
export(make_TimeSpent_xy)
export(make_Xinits_SIP)
export(make_Xinits_SIS)
export(make_Xinits_hMoI)
Expand All @@ -365,6 +386,7 @@ export(make_calK)
export(make_calK_xy)
export(make_calN)
export(make_calU)
export(make_calU_s)
export(make_indices)
export(make_indices_L)
export(make_indices_MYZ)
Expand Down Expand Up @@ -404,9 +426,13 @@ export(parse_deout_L)
export(parse_deout_MYZ)
export(parse_deout_X)
export(parse_deout_vec)
export(setup_BFpar_static)
export(setup_BloodFeeding)
export(setup_EGGpar_static)
export(setup_EIP)
export(setup_EggLaying)
export(setup_Hpar)
export(setup_EggLaying_simple)
export(setup_EggLaying_static)
export(setup_Hpar_static)
export(setup_Linits)
export(setup_Lpar)
export(setup_MYZinits)
Expand All @@ -419,6 +445,7 @@ export(setup_area_spray_null)
export(setup_behavior)
export(setup_behavior_forced)
export(setup_behavior_null)
export(setup_bionomics_static)
export(setup_care_seeking_null)
export(setup_civil_forced)
export(setup_civil_null)
Expand All @@ -431,31 +458,33 @@ export(setup_development_null)
export(setup_eip_static)
export(setup_exposure_nb)
export(setup_exposure_pois)
export(setup_habitat_dynamics_null)
export(setup_habitat_dynamics_static)
export(setup_hydrology_null)
export(setup_irs_null)
export(setup_itn_lemenach)
export(setup_itn_null)
export(setup_local_fraction_simple)
export(setup_lsm_null)
export(setup_mass_medical_forced)
export(setup_mass_medical_null)
export(setup_other_blood_hosts_null)
export(setup_other_blood_hosts_static)
export(setup_ovitraps_null)
export(setup_rainfall_null)
export(setup_relative_humidity_null)
export(setup_resources_forced)
export(setup_resources_null)
export(setup_resources_static)
export(setup_shock_null)
export(setup_sugar_baits_null)
export(setup_sugar_null)
export(setup_sugar_static)
export(setup_temperature_null)
export(setup_travel_eir)
export(setup_travel_foi)
export(setup_travel_null)
export(setup_travel_static)
export(setup_vc_control)
export(setup_vc_null)
export(setup_visitors_basic)
export(setup_visitors_null)
export(setup_visitors_static)
export(setup_weather_forced)
export(setup_weather_null)
export(shapeIt)
Expand Down
10 changes: 5 additions & 5 deletions R/adult-RM.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ dMYZdt.RM_ode <- function(t, y, pars, s) {
Z <- y[Z_ix]

with(pars$MYZpar[[s]],{
dMdt <- Lambda - (Omega %*% M)
dPdt <- f*(M - P) - (Omega %*% P)
dYdt <- f*q*kappa*(M - Y) - (Omega %*% Y)
dZdt <- Upsilon %*% diag(f*q*kappa, nPatches) %*% (M - Y) - (Omega %*% Z)
dM <- Lambda - (Omega %*% M)
dP <- f*(M - P) - (Omega %*% P)
dY <- f*q*kappa*(M - Y) - (Omega %*% Y)
dZ <- Upsilon %*% diag(f*q*kappa, nPatches) %*% (M - Y) - (Omega %*% Z)

return(c(dMdt, dPdt, dYdt, dZdt))
return(c(dM, dP, dY, dZ))
})
})
}
Expand Down
2 changes: 1 addition & 1 deletion R/aquatic-basic.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ F_alpha.basic <- function(t, y, pars, s) {
#' @return a [numeric] vector
#' @export
dLdt.basic <- function(t, y, pars, s) {
eta <- pars$eta[[s]]
eta <- pars$eggs_laid[[s]]
with(pars$ix$L[[s]],{
L <- y[L_ix]
with(pars$Lpar[[s]], {
Expand Down
14 changes: 1 addition & 13 deletions R/aquatic-interface.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,4 @@ make_calN = function(nPatches, membership){
return(calN)
}

#' @title Make the egg distribution matrix, calU
#' @param calN the habitat membership matrix
#' @param searchQ the habitat search weights
#' @return a [matrix] of dimensions `nHabitats` by `nPatches`
#' @export
make_calU = function(calN, searchQ=1){
calU = searchQ*t(calN)
colNorms = colSums(calU)
ix = which(colNorms == 0)
if(length(ix)>0) colNorms[ix]=1
calU = calU %*% diag(1/colNorms)
return(calU)
}

77 changes: 77 additions & 0 deletions R/available_blood.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@

#' @title Update the availability of blood hosts
#' @description This method dispatches on the type of `pars$BFpar`.
#' @param t current simulation time
#' @param y vector of state variables
#' @param pars an [list]
#' @return a [list]
#' @export
AvailableBlood <- function(t, y, pars) {
UseMethod("AvailableBlood", pars$BFpar)
}

#' @title Compute availability of local humans for blood feeding
#' @description Compute the availability for the pathogen's hosts for blood feeding
#' @param t current simulation time
#' @param y state vector
#' @param pars a [list]
#' @return a [numeric] vector of length `nPatches`
#' @export
AvailableBlood.static <- function(t, y, pars){
return(pars)
}

#' @title Compute availability of local humans for blood feeding
#' @description Compute the availability for the pathogen's hosts for blood feeding
#' @param t current simulation time
#' @param y state vector
#' @param pars a [list]
#' @return a [numeric] vector of length `nPatches`
#' @export
AvailableBlood.setup <- function(t, y, pars){
for(s in 1:pars$nVectors)
pars = compute_AvailableHosts(t, y, pars, s)

return(pars)
}

#' @title Compute availability of local humans for blood feeding
#' @description Compute the availability for the pathogen's hosts for blood feeding
#' @param t current simulation time
#' @param y state vector
#' @param pars a [list]
#' @return a [numeric] vector of length `nPatches`
#' @export
AvailableBlood.forced <- function(t, y, pars){
for(s in 1:pars$nVectors)
pars = compute_AvailableHosts(t, y, pars, s)

return(pars)
}

#' @title Compute availability blood hosts of the i^th species
#' @description Compute the availability for the pathogen's hosts for blood feeding
#' @param t current simulation time
#' @param y state vector
#' @param pars a [list]
#' @param s the vector species index
#' @return a [numeric] vector of length `nPatches`
#' @export
compute_AvailableHosts <- function(t, y, pars, s){

H = F_H(t, y, pars, 1)

pars$vars$Wi[[1]][[s]] = as.vector(with(pars$BFpar, TaR[[1]][[s]] %*% (searchWts[[1]][[s]]*H)))
pars$vars$W[[s]] = pars$vars$Wi[[1]][[s]]
if(pars$nHosts > 1){
for(i in 2:pars$nHosts){
H = F_H(t, y, pars, i)
pars$vars$Wi[[i]][[s]] = as.vector(with(pars$BFpar, TaR[[i]][[s]] %*% (searchWts[[i]][[s]]*H)))
pars$vars$W[[s]] = pars$vars$W[[s]] + pars$vars$Wi[[i]][[s]]
}
}
pars$vars$W[[s]] = as.vector(pars$vars$W[[s]])
pars$vars$B[[s]] = as.vector(with(pars$vars, W[[s]] + Visitors[[s]] + Other[[s]]))

return(pars)
}
Loading

0 comments on commit bbc74c0

Please sign in to comment.