Skip to content

Commit d9ec07e

Browse files
authored
Merge pull request #12 from dd-harp/dev
Moving towards version 0.9
2 parents 7d7d826 + e23113d commit d9ec07e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1179
-235
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
.Rhistory
33
.RData
44
.Ruserdata
5+
.rda
56
docs

NAMESPACE

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ S3method(make_Kbq,BQ)
2020
S3method(make_Kbq,BQS)
2121
S3method(make_Kqb,BQ)
2222
S3method(make_Kqb,BQS)
23+
S3method(make_all_graphs,BQ)
24+
S3method(make_all_graphs,BQS)
2325
S3method(make_movie,BQ)
2426
S3method(make_movie,BQS)
2527
S3method(make_tiles,BQ)
@@ -67,8 +69,8 @@ export(edgeSubset)
6769
export(edgeSubset_fracMass)
6870
export(frame_bq)
6971
export(frame_bqs)
70-
export(getM_i)
71-
export(getNet_i)
72+
export(get_matrix)
73+
export(get_net)
7274
export(init_adult_model)
7375
export(init_adult_model_BQ)
7476
export(init_adult_model_BQS)
@@ -86,17 +88,21 @@ export(make_Psi_BQ)
8688
export(make_Psi_BQS)
8789
export(make_Psi_xx)
8890
export(make_Psi_xy)
91+
export(make_all_graphs)
92+
export(make_all_graphs_common)
8993
export(make_convex_hull_i)
9094
export(make_convex_hulls)
9195
export(make_demography_BQ)
9296
export(make_demography_BQS)
97+
export(make_graph_obj)
9398
export(make_kF_exp)
9499
export(make_kF_mix)
95100
export(make_kF_pwr)
96101
export(make_model_squareLattice)
97102
export(make_model_unif)
98103
export(make_movie)
99104
export(make_tiles)
105+
export(net2meta)
100106
export(plotDDcmf)
101107
export(plotDDpmf)
102108
export(plot_Kbb)
@@ -122,6 +128,7 @@ export(plot_dispersal_V)
122128
export(plot_dispersal_VV)
123129
export(plot_matrix_xx)
124130
export(plot_matrix_xy)
131+
export(plot_meta)
125132
export(plot_points)
126133
export(plot_points_bq)
127134
export(plot_points_bqs)
@@ -138,3 +145,9 @@ export(setup_model)
138145
export(steady_state)
139146
export(stretch_convex_hull)
140147
export(unif_xy)
148+
importFrom(igraph,E)
149+
importFrom(igraph,cluster_fast_greedy)
150+
importFrom(igraph,cluster_walktrap)
151+
importFrom(igraph,cut_at)
152+
importFrom(igraph,graph_from_adjacency_matrix)
153+
importFrom(igraph,membership)

R/K_matrices.R

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ make_Kbq = function(model, Tmax){
2828
#' @return the model, a compound [list]
2929
#' @export
3030
make_Kbb = function(model){
31-
model$Mpar$Kbb = with(model$Mpar, Kqb %*% Kbq)
31+
model$KGV$Kbb = with(model$KGV, Kqb %*% Kbq)
3232
return(model)
3333
}
3434

@@ -39,7 +39,7 @@ make_Kbb = function(model){
3939
#' @return the model, a compound [list]
4040
#' @export
4141
make_Kqq = function(model){
42-
model$Mpar$Kqq = with(model$Mpar, Kbq %*% Kqb)
42+
model$KGV$Kqq = with(model$KGV, Kbq %*% Kqb)
4343
return(model)
4444
}
4545

@@ -59,7 +59,7 @@ make_Kbq.BQ = function(model, Tmax=100){with(model, with(Mpar,{
5959
Kbq = Kbq + diag(pB*psiB, nb) %*% Psi_bb %*% Bt
6060
Bt = diag(pB*(1-psiB), nb) %*% Psi_bb %*% Bt
6161
}
62-
model$Mpar$Kbq = Kbq
62+
model$KGV$Kbq = Kbq
6363
return(model)
6464
}))}
6565

@@ -79,7 +79,7 @@ make_Kqb.BQ = function(model, Tmax=100){with(model, with(Mpar,{
7979
Kqb = Kqb + diag(pQ*psiQ, nq) %*% Psi_qq %*% Qt
8080
Qt =diag(pQ*(1-psiQ), nq) %*% Psi_qq %*%Qt
8181
}
82-
model$Mpar$Kqb = Kqb
82+
model$KGV$Kqb = Kqb
8383
return(model)
8484
}))}
8585

@@ -122,7 +122,7 @@ make_Kqb.BQS = function(model, Tmax=200){with(model,with(Mpar,{
122122
for(i in 1:Tmax) Kt = M%*%Kt
123123
Kt[-c(1:(nb+nq+ns)),]
124124

125-
model$Mpar$Kqb = Kt[nb+nq+ns+c(1:nb),]
125+
model$KGV$Kqb = Kt[nb+nq+ns+c(1:nb),]
126126
return(model)
127127
}))}
128128

@@ -163,7 +163,7 @@ make_Kbq.BQS = function(model, Tmax = 200){with(model,with(Mpar,{
163163
Kt = rbind(0*Mbb, Cno, 0*Mbs, Cyes)
164164
for(i in 1:Tmax) Kt = M%*%Kt
165165
Kt[-c(1:(nb+nq+ns)),]
166-
model$Mpar$Kbq = Kt[nb+nq+ns+c(1:nq),]
166+
model$KGV$Kbq = Kt[nb+nq+ns+c(1:nq),]
167167
return(model)
168168
}))}
169169

@@ -187,12 +187,12 @@ plot_Kqb = function(model, max_pt_sz=2,
187187
min_edge_frac=0.01, r=0.02, arw_lng=0.002, lwd=2,
188188
clr_K="#4361eeCC", clr_b='red', clr_q ='darkblue'){
189189
with(model,with(Mpar,{
190-
frame_bq(b, q, mtl = expression(K[q%<-%b]))
190+
frame_bq(b, q, mtl = expression(K*scriptstyle(q%<-%b)))
191191
if(exists("s")) add_points_s(s, max_pt_sz=0.5)
192-
add_arrows_xy(b, q, Kqb, min_edge_frac=min_edge_frac,
192+
add_arrows_xy(b, q, KGV$Kqb, min_edge_frac=min_edge_frac,
193193
r=r, arw_lng=arw_lng, lwd=lwd, clr=clr_K)
194194
add_points_b(b, clr=clr_b, max_pt_sz=0.7)
195-
add_points_qq(q, Kqb, max_pt_sz=max_pt_sz, colA=clr_q)
195+
add_points_qq(q, KGV$Kqb, max_pt_sz=max_pt_sz, colA=clr_q)
196196
}))
197197
return(invisible())
198198
}
@@ -215,13 +215,13 @@ plot_Kbq = function(model, max_pt_sz=2,
215215
min_edge_frac=0.01, r=0.02, arw_lng=0.002, lwd=2,
216216
clr_K="#fe5f55CC", clr_b='darkred', clr_q="#858ae399"){
217217
with(model,with(Mpar,{
218-
frame_bq(b, q, mtl = expression(K[b%<-%q]))
218+
frame_bq(b, q, mtl = expression(K*scriptstyle(b%<-%q)))
219219
if(exists("s")) add_points_s(s, max_pt_sz=0.5)
220-
add_arrows_xy(q, b, Kbq, min_edge_frac=min_edge_frac,
220+
add_arrows_xy(q, b, KGV$Kbq, min_edge_frac=min_edge_frac,
221221
r=r, arw_lng=arw_lng, lwd=lwd, clr=clr_K)
222222
with(model, if(exists("s")) add_points_s(s, max_pt_sz=0.7))
223223
add_points_q(q, max_pt_sz=0.7, clr=clr_q)
224-
add_points_bb(b, Kbq, max_pt_sz=max_pt_sz, colB=clr_b)
224+
add_points_bb(b, KGV$Kbq, max_pt_sz=max_pt_sz, colB=clr_b)
225225
}))
226226
return(invisible())
227227
}
@@ -247,12 +247,12 @@ plot_Kbb = function(model, max_pt_sz=2,
247247
){
248248
with(model,with(Mpar,
249249
{
250-
frame_bq(b, q, mtl = expression(K[b %<-%b]))
251-
add_arrows_xx(b, Psi_bb, min_edge_frac=min_edge_frac,
250+
frame_bq(b, q, mtl = expression(K*scriptstyle(b %<-%b)))
251+
add_arrows_xx(b, KGV$Kbb, min_edge_frac=min_edge_frac,
252252
r=r, arw_lng=arw_lng, lwd=lwd, arw_clr=arw_clr, seg_clr=seg_clr)
253253
with(model, if(exists("s")) add_points_s(s, max_pt_sz=0.7))
254254
add_points_q(q, max_pt_sz=0.7, clr=clr_q)
255-
add_points_bb(b, Kbb, max_pt_sz=max_pt_sz, colA=arw_clr, colB=clr_b)
255+
add_points_bb(b, KGV$Kbb, max_pt_sz=max_pt_sz, colA=arw_clr, colB=clr_b)
256256
}))
257257
return(invisible())
258258
}
@@ -277,12 +277,12 @@ plot_Kqq = function(model, max_pt_sz=2,
277277
arw_clr = "#abc4ff55", seg_clr ='#00000022',
278278
clr_q="#858ae399", clr_b="#cc444bCC"){
279279
with(model,with(Mpar,{
280-
frame_bq(b, q, mtl = expression(K[q %<-%q]))
280+
frame_bq(b, q, mtl = expression(K*scriptstyle(q %<-%q)))
281281
with(model, if(exists("s")) add_points_s(s, max_pt_sz=0.7))
282-
add_arrows_xx(q, Psi_qq, min_edge_frac=min_edge_frac,
282+
add_arrows_xx(q, KGV$Kqq, min_edge_frac=min_edge_frac,
283283
r=r, arw_lng=arw_lng, lwd=lwd, arw_clr=arw_clr, seg_clr=seg_clr)
284284
add_points_b(b, max_pt_sz=0.7, clr=clr_b)
285-
add_points_qq(q, Kqq, max_pt_sz=max_pt_sz, colA=arw_clr, colB=clr_q)
285+
add_points_qq(q, KGV$Kqq, max_pt_sz=max_pt_sz, colA=arw_clr, colB=clr_q)
286286
}))
287287
return(invisible())
288288
}

R/adult-BQ.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ save_states_M.BQ = function(t, model){
4040
#'
4141
#' @return a [numeric] value, the sum of squared differences
4242
#' @export
43-
compute_diffs_M.BQ = function(Mvars1, Mvars2){
44-
dfs = sum((Mvars1$B - Mvars2$B)^2) + sum((Mvars1$Q - Mvars2$Q)^2)
43+
compute_diffs_M.BQ = function(model){with(model,{
44+
dfs = sum((Mvars$B - steady$M$B)^2) + sum((Mvars$Q - steady$M$Q)^2)
4545
return (dfs)
46-
}
46+
})}
4747

4848
#' Save the state variables in a vector
4949
#'

R/adult-BQS.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ save_states_M.BQS = function(t, model){
4343
#'
4444
#' @return a [numeric] value, the sum of squared differences
4545
#' @export
46-
compute_diffs_M.BQS = function(Mvars1, Mvars2){
47-
dfs = sum((Mvars1$B - Mvars2$B)^2)
48-
dfs = dfs + sum((Mvars1$Q - Mvars2$Q)^2)
49-
dfs = dfs + sum((Mvars1$S - Mvars2$S)^2)
46+
compute_diffs_M.BQS = function(model){with(model,{
47+
dfs = sum((Mvars$B - steady$M$B)^2)
48+
dfs = dfs + sum((Mvars$Q - steady$M$Q)^2)
49+
dfs = dfs + sum((Mvars$S - steady$M$S)^2)
5050
return (dfs)
51-
}
51+
})}
5252

5353
#' Save the state variables in a vector
5454
#'

R/adult-interface.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,12 @@ init_adult_model = function(model, M0_opts){
4444

4545
#' The some of squared differences between two sets of variables
4646
#'
47-
#' @param Mvars1 variables describing adult mosquitoes, set 1
48-
#' @param Mvars2 variables describing adult mosquitoes, set 2
47+
#' @param model a model
4948
#'
5049
#' @return a [numeric] value, the sum of squared differences
5150
#' @export
52-
compute_diffs_M = function(Mvars1, Mvars2){
53-
UseMethod("compute_diffs_M", Mvars1)
51+
compute_diffs_M = function(model){
52+
UseMethod("compute_diffs_M", model$Mpar)
5453
}
5554

5655
#' Setup an adult model

R/aquatic-basicL.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ save_states_L.basicL = function(t, model){
5858
#'
5959
#' @return a [numeric] value, the sum of squared differences
6060
#' @export
61-
compute_diffs_L.basicL = function(Lvars1, Lvars2){
62-
dfs = sum((Lvars1$L - Lvars2$L)^2)
61+
compute_diffs_L.basicL = function(model){with(model,{
62+
dfs = sum((Lvars$L - steady$L$L)^2)
6363
return (dfs)
64-
}
64+
})}
6565

6666
#' Save the state variables in a vector
6767
#'

R/aquatic-interface.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@ save_states_L=function(t, model){
3434

3535
#' The some of squared differences between two sets of variables
3636
#'
37-
#' @param Lvars1 variables describing adult mosquitoes, set 1
38-
#' @param Lvars2 variables describing adult mosquitoes, set 2
37+
#' @param model a model
3938
#'
4039
#' @return a [numeric] value, the sum of squared differences
4140
#' @export
42-
compute_diffs_L = function(Lvars1, Lvars2){
43-
UseMethod("compute_diffs_L", Lvars1)
41+
compute_diffs_L = function(model){
42+
UseMethod("compute_diffs_L", model$Lpar)
4443
}
4544

4645
#' Initialize the Lstates

R/dispersal_distances.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
#' Compute distances dispersed
33
#'
4-
#' @param xy a set of point locations
4+
#' @param xy locations of a set of points
55
#' @param M a dispersal matrix
66
#'
77
#' @return a [list] with the PMF, CMF, mean distance dispersed, and the distance matrix

R/egg_laying.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ compute_G.BQ = function(model, Tmax=50){with(model, with(Mpar,{
2828
G = G + eggs
2929
B = Bt; Q=Qt
3030
}
31-
model$G = G
31+
model$KGV$G = G
3232
return(model)
3333
}))}
3434

@@ -52,7 +52,7 @@ compute_G.BQS = function(model, Tmax=50){with(model, with(Mpar,{
5252
G = G + eggs
5353
B = Bt; Q=Qt; S=St
5454
}
55-
model$Mpar$G = G
55+
model$KGV$G = G
5656
return(model)
5757
}))}
5858

@@ -64,7 +64,7 @@ compute_G.BQS = function(model, Tmax=50){with(model, with(Mpar,{
6464
#' @export
6565
compute_GG = function(model){with(model,{
6666
if(!exists("model$steady$Q")) model = steady_state(model)
67-
model$GG = with(model,Mpar$G %*% diag(as.vector(steady$Q)))
67+
model$KGV$GG = with(model,Mpar$G %*% diag(as.vector(steady$M$Q)))
6868
return(model)
6969
})}
7070

@@ -92,9 +92,9 @@ plot_dispersal_G = function(model,
9292
par(mar=c(2,2,2,2))
9393
frame_bq(b, q, mtl = "Lifetime Egg Dispersal, per Mosquito")
9494
add_points_b(b, max_pt_sz = mx_pt_sz_b)
95-
add_arrows_xx(q, G, min_edge_frac=min_edge_frac, r=r, arw_lng=arw_lng, lwd=lwd,
95+
add_arrows_xx(q, KGV$G, min_edge_frac=min_edge_frac, r=r, arw_lng=arw_lng, lwd=lwd,
9696
lamp=lamp, arw_clr=arw_clr, seg_clr=seg_clr)
97-
add_points_qq(q, G, max_pt_sz = mx_pt_sz_q)
97+
add_points_qq(q, KGV$G, max_pt_sz = mx_pt_sz_q)
9898
}))
9999
return(invisible())
100100
}
@@ -122,9 +122,9 @@ plot_dispersal_GG = function(model,
122122
par(mar=c(2,2,2,2))
123123
frame_bq(b, q, mtl = "Lifetime Egg Dispersal, Population")
124124
add_points_b(b, max_pt_sz = mx_pt_sz_b)
125-
add_arrows_xx(q, GG, min_edge_frac=min_edge_frac, r=r, arw_lng=arw_lng, lwd=lwd,
125+
add_arrows_xx(q, KGV$GG, min_edge_frac=min_edge_frac, r=r, arw_lng=arw_lng, lwd=lwd,
126126
lamp=lamp, arw_clr=arw_clr, seg_clr=seg_clr)
127-
add_points_qq(q, GG, max_pt_sz = mx_pt_sz_q)
127+
add_points_qq(q, KGV$GG, max_pt_sz = mx_pt_sz_q)
128128
}))
129129
return(invisible())
130130
}

0 commit comments

Comments
 (0)