Skip to content

Commit c5e7a76

Browse files
authored
Merge pull request #14 from dd-harp/dev
minor fixes
2 parents 98a1bcb + 63af470 commit c5e7a76

18 files changed

+60
-55
lines changed

NAMESPACE

+2
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ export(setup_model)
145145
export(steady_state)
146146
export(stretch_convex_hull)
147147
export(unif_xy)
148+
importFrom(deldir,deldir)
149+
importFrom(deldir,tile.list)
148150
importFrom(igraph,E)
149151
importFrom(igraph,cluster_fast_greedy)
150152
importFrom(igraph,cluster_walktrap)

R/K_matrices.R

+10-11
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$KGV$Kbb = with(model$KGV, Kqb %*% Kbq)
31+
model$KGV$Kbb = with(model$KGV, Kbq %*% Kqb)
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$KGV$Kqq = with(model$KGV, Kbq %*% Kqb)
42+
model$KGV$Kqq = with(model$KGV, Kqb %*% Kbq)
4343
return(model)
4444
}
4545

@@ -188,10 +188,10 @@ plot_Kqb = function(model, max_pt_sz=2,
188188
clr_K="#4361eeCC", clr_b='red', clr_q ='darkblue'){
189189
with(model,with(Mpar,{
190190
frame_bq(b, q, mtl = expression(K*scriptstyle(q%<-%b)))
191-
if(exists("s")) add_points_s(s, max_pt_sz=0.5)
192191
add_arrows_xy(b, q, KGV$Kqb, min_edge_frac=min_edge_frac,
193192
r=r, arw_lng=arw_lng, lwd=lwd, clr=clr_K)
194-
add_points_b(b, clr=clr_b, max_pt_sz=0.7)
193+
with(model, if(exists("s")) add_points_s(s, max_pt_sz=0.3))
194+
add_points_b(b, clr=clr_b, max_pt_sz=0.3)
195195
add_points_qq(q, KGV$Kqb, max_pt_sz=max_pt_sz, colA=clr_q)
196196
}))
197197
return(invisible())
@@ -216,11 +216,10 @@ plot_Kbq = function(model, max_pt_sz=2,
216216
clr_K="#fe5f55CC", clr_b='darkred', clr_q="#858ae399"){
217217
with(model,with(Mpar,{
218218
frame_bq(b, q, mtl = expression(K*scriptstyle(b%<-%q)))
219-
if(exists("s")) add_points_s(s, max_pt_sz=0.5)
220219
add_arrows_xy(q, b, KGV$Kbq, min_edge_frac=min_edge_frac,
221220
r=r, arw_lng=arw_lng, lwd=lwd, clr=clr_K)
222-
with(model, if(exists("s")) add_points_s(s, max_pt_sz=0.7))
223-
add_points_q(q, max_pt_sz=0.7, clr=clr_q)
221+
with(model, if(exists("s")) add_points_s(s, max_pt_sz=0.3))
222+
add_points_q(q, max_pt_sz=0.3, clr=clr_q)
224223
add_points_bb(b, KGV$Kbq, max_pt_sz=max_pt_sz, colB=clr_b)
225224
}))
226225
return(invisible())
@@ -250,8 +249,8 @@ plot_Kbb = function(model, max_pt_sz=2,
250249
frame_bq(b, q, mtl = expression(K*scriptstyle(b %<-%b)))
251250
add_arrows_xx(b, KGV$Kbb, min_edge_frac=min_edge_frac,
252251
r=r, arw_lng=arw_lng, lwd=lwd, arw_clr=arw_clr, seg_clr=seg_clr)
253-
with(model, if(exists("s")) add_points_s(s, max_pt_sz=0.7))
254-
add_points_q(q, max_pt_sz=0.7, clr=clr_q)
252+
with(model, if(exists("s")) add_points_s(s, max_pt_sz=0.3))
253+
add_points_q(q, max_pt_sz=0.3, clr=clr_q)
255254
add_points_bb(b, KGV$Kbb, max_pt_sz=max_pt_sz, colA=arw_clr, colB=clr_b)
256255
}))
257256
return(invisible())
@@ -278,10 +277,10 @@ plot_Kqq = function(model, max_pt_sz=2,
278277
clr_q="#858ae399", clr_b="#cc444bCC"){
279278
with(model,with(Mpar,{
280279
frame_bq(b, q, mtl = expression(K*scriptstyle(q %<-%q)))
281-
with(model, if(exists("s")) add_points_s(s, max_pt_sz=0.7))
282280
add_arrows_xx(q, KGV$Kqq, min_edge_frac=min_edge_frac,
283281
r=r, arw_lng=arw_lng, lwd=lwd, arw_clr=arw_clr, seg_clr=seg_clr)
284-
add_points_b(b, max_pt_sz=0.7, clr=clr_b)
282+
with(model, if(exists("s")) add_points_s(s, max_pt_sz=0.7))
283+
add_points_b(b, max_pt_sz=0.3, clr=clr_b)
285284
add_points_qq(q, KGV$Kqq, max_pt_sz=max_pt_sz, colA=arw_clr, colB=clr_q)
286285
}))
287286
return(invisible())

R/Psi_matrices.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ plot_all_Psi = function(model, max_pt_sz=2,
7171
#' @export
7272
plot_all_Psi.BQ = function(model, max_pt_sz=2,
7373
min_edge_frac = 0.01, r=.01, arw_lng=0.05, lwd=2){
74-
with(model,with(Mpar,{plot_Psi_BQ(b,q,Psi_bb, Psi_qb, Psi_bq, Psi_qq,
74+
with(model,with(Mpar,{plot_all_Psi_BQ(b,q,Psi_bb, Psi_qb, Psi_bq, Psi_qq,
7575
max_pt_sz=max_pt_sz, min_edge_frac=min_edge_frac,
7676
r=r, arw_lng=arw_lng, lwd=lwd)}))}
7777

@@ -121,7 +121,7 @@ plot_all_Psi_BQ = function(b, q,
121121
#' @export
122122
plot_all_Psi.BQS = function(model,max_pt_sz=2,
123123
min_edge_frac = 0.01, r=.01, arw_lng=0.05, lwd=2){
124-
with(model,with(Mpar,{plot_Psi_BQS(b,q,s,
124+
with(model,with(Mpar,{plot_all_Psi_BQS(b,q,s,
125125
Psi_bb, Psi_qb, Psi_sb,
126126
Psi_bq, Psi_qq, Psi_sq,
127127
Psi_bs, Psi_qs, Psi_ss,

R/add_arrows.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#'
1414
#' @return invisible(NULL)
1515
#' @export
16-
add_arrows_xy = function(xy_launch, xy_land, M, min_edge_frac=0.95,
16+
add_arrows_xy = function(xy_launch, xy_land, M, min_edge_frac=0.01,
1717
r=0, arw_lng=0.1, lwd=2, lamp=1, clr="darkgreen"){
1818
n1 = dim(xy_launch)[1]
1919
n2 = dim(xy_land)[1]
@@ -40,7 +40,7 @@ add_arrows_xy = function(xy_launch, xy_land, M, min_edge_frac=0.95,
4040
#'
4141
#' @return invisible(NULL)
4242
#' @export
43-
add_arrows_xx = function(xy, M, min_edge_frac=.99, r=0, arw_lng=.1, lwd=5, lamp=1,
43+
add_arrows_xx = function(xy, M, min_edge_frac=.01, r=0, arw_lng=.1, lwd=5, lamp=1,
4444
arw_clr = "darkgreen", seg_clr= "#CCCCCC"){
4545
Mtot = M + t(M)
4646
Mfrac = M/Mtot

R/convex_hulls.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ plot_convex_hulls = function(net, stretch=1.1, lwd=2){
6565
n = length(net$convex_hulls)
6666
for(i in 1:n){
6767
with(net$convex_hulls[[i]],{
68-
sxy = stretchHull(xy, stretch)
68+
sxy = stretch_convex_hull(xy, stretch)
6969
polygon(sxy[,1], sxy[,2], border=clr, lwd=lwd)
7070
})
7171
}

R/egg_laying.R

+4-5
Original file line numberDiff line numberDiff line change
@@ -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$KGV$GG = with(model,Mpar$G %*% diag(as.vector(steady$M$Q)))
67+
model$KGV$GG = with(model,KGV$G %*% diag(as.vector(steady$M$Q)))
6868
return(model)
6969
})}
7070

@@ -85,7 +85,7 @@ compute_GG = function(model){with(model,{
8585
#' @return invisible(NULL)
8686
#' @export
8787
plot_dispersal_G = function(model,
88-
mx_pt_sz_b = 0.7, mx_pt_sz_q = 2,
88+
mx_pt_sz_b = 0.3, mx_pt_sz_q = 2,
8989
min_edge_frac = 0.01, r=.01, arw_lng=0.05, lwd=2, lamp=1,
9090
seg_clr="lightblue", arw_clr="salmon"){
9191
with(model,with(Mpar,{
@@ -115,15 +115,14 @@ plot_dispersal_G = function(model,
115115
#' @return invisible(NULL)
116116
#' @export
117117
plot_dispersal_GG = function(model,
118-
mx_pt_sz_b = 0.7, mx_pt_sz_q = 2,
118+
mx_pt_sz_b = 0.3, mx_pt_sz_q = 2.5,
119119
min_edge_frac = 0.01, r=.01, arw_lng=0.05, lwd=2, lamp=1,
120120
seg_clr="steelblue", arw_clr="chocolate"){
121121
with(model,with(Mpar,{
122-
par(mar=c(2,2,2,2))
123122
frame_bq(b, q, mtl = "Lifetime Egg Dispersal, Population")
124-
add_points_b(b, max_pt_sz = mx_pt_sz_b)
125123
add_arrows_xx(q, KGV$GG, min_edge_frac=min_edge_frac, r=r, arw_lng=arw_lng, lwd=lwd,
126124
lamp=lamp, arw_clr=arw_clr, seg_clr=seg_clr)
125+
add_points_b(b, max_pt_sz = mx_pt_sz_b)
127126
add_points_qq(q, KGV$GG, max_pt_sz = mx_pt_sz_q)
128127
}))
129128
return(invisible())

R/graphs.R

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ make_common_graphs = function(model){with(model,{
5757
#'
5858
#' @returns a ramp.micro model object
5959
#' @export
60-
make_all_graphs = function(model){UseMethod("make_all_graphs",model)}
60+
make_all_graphs = function(model){
61+
UseMethod("make_all_graphs",model$Mpar)
62+
}
6163

6264

6365
#' Make graphs for a BQ model

R/tiles.R

+10-6
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,35 @@
66
#' @return the model, a compound [list]
77
#' @export
88
make_tiles = function(model){
9-
UseMethod("make_tiles", model)
9+
UseMethod("make_tiles", model$Mpar)
1010
}
1111

1212
#' Make a set of tiles that tesselate space for the BQ model
1313
#'
1414
#'
1515
#' @param model a model, defined as a compound [list]
1616
#'
17+
#' @importFrom deldir deldir tile.list
18+
#'
1719
#' @return the model, a compound [list]
1820
#' @export
1921
make_tiles.BQ = function(model){with(model,{
20-
model$tilesB = tile.list(deldir::deldir(b))
21-
model$tilesQ = tile.list(deldir::deldir(q))
22+
model$tilesB = deldir::tile.list(deldir::deldir(b))
23+
model$tilesQ = deldir::tile.list(deldir::deldir(q))
2224
return(model)
2325
})}
2426

2527
#' Make a set of tiles that tesselate space for the BQS model
2628
#'
2729
#' @param model a model, defined as a compound [list]
2830
#'
31+
#' @importFrom deldir deldir tile.list
32+
#'
2933
#' @return the model, a compound [list]
3034
#' @export
3135
make_tiles.BQS = function(model){with(model,{
32-
model$tilesB = tile.list(deldir::deldir(b))
33-
model$tilesQ = tile.list(deldir::deldir(q))
34-
model$tilesS = tile.list(deldir::deldir(s))
36+
model$tilesB = tile.list(deldir(b))
37+
model$tilesQ = tile.list(deldir(q))
38+
model$tilesS = tile.list(deldir(s))
3539
return(model)
3640
})}

R/utils.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ edgeSubset = function(M, min_edge_frac=0.01){
6363
#' 5. V; 6. VV;
6464
#' 7. M; 8. MM;
6565
#'
66-
#' @param i an index for the type of model
6766
#' @param model a model defined as a compound [list]
67+
#' @param i an index for the type of model
6868
#'
6969
#' @return a dispersion matrix
7070
#' @export
71-
get_matrix = function(i, model){
71+
get_matrix = function(model, i){
7272
if(i==1) M = model$KGV$Kbb
7373
if(i==2) M = model$KGV$Kqq
7474
if(i==3) M = model$KGV$G

R/vectorial_capacity.R

+4-5
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ compute_V.BQS = function(model, Tmax=100){with(model, with(Mpar,{
7777
#' @export
7878
compute_VC = function(model){with(model,{
7979
if(!exists("model$steady$B")) model = steady_state(model)
80-
model$VC = with(model, Mpar$V %*% diag(as.vector(steady$M$B)))
80+
model$KGV$VC = with(model, KGV$V %*% diag(as.vector(steady$M$B)))
8181
return(model)
8282
})}
8383

@@ -98,7 +98,7 @@ compute_VC = function(model){with(model,{
9898
#' @return invisible(NULL)
9999
#' @export
100100
plot_dispersal_V = function(model,
101-
max_pt_sz_b = 0.7, max_pt_sz_q = 2,
101+
max_pt_sz_b = 2, max_pt_sz_q = 0.3,
102102
min_edge_frac = 0.01, r=.01, arw_lng=0.05, lwd=2, lamp=1,
103103
arw_clr="darkolivegreen4", seg_clr="orangered3"){
104104
with(model,with(Mpar,{
@@ -128,15 +128,14 @@ plot_dispersal_V = function(model,
128128
#' @return invisible(NULL)
129129
#' @export
130130
plot_dispersal_VV = function(model,
131-
max_pt_sz_b = 0.7, max_pt_sz_q = 2,
131+
max_pt_sz_b = 2.5, max_pt_sz_q = 0.3,
132132
min_edge_frac = 0.01, r=.01, arw_lng=0.05, lwd=2, lamp=1,
133133
arw_clr="springgreen4", seg_clr="firebrick3"){
134134
with(model,with(Mpar,{
135-
par(mar=c(2,2,2,2))
136135
frame_bq(b, q, mtl = "Potential Parasite Dispersal, Population")
137-
add_points_q(q, max_pt_sz = max_pt_sz_q)
138136
add_arrows_xx(b, KGV$VC, min_edge_frac=min_edge_frac, r=r, arw_lng=arw_lng, lwd=lwd,
139137
lamp=lamp, arw_clr=arw_clr, seg_clr=seg_clr)
138+
add_points_q(q, max_pt_sz = max_pt_sz_q)
140139
add_points_bb(b, KGV$VC, max_pt_sz = max_pt_sz_b)
141140
}))
142141
return(invisible())

man/add_arrows_xx.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/add_arrows_xy.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/get_matrix.Rd

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/plot_dispersal_G.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/plot_dispersal_GG.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/plot_dispersal_V.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/plot_dispersal_VV.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vignettes/visualizing_dispersal.html

+8-8
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)