Skip to content

Commit a8ebac9

Browse files
committed
lint for code factor
1 parent 4c7e7e0 commit a8ebac9

File tree

13 files changed

+83
-39
lines changed

13 files changed

+83
-39
lines changed

data-raw/IBD_simulation_data.R

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ sim_IBDIBD <- function(demesize, distmat, rate, Ft) {
6262
) %>%
6363
magrittr::set_colnames(c("deme1", "deme2", "geodist"))
6464
# individuals to long
65-
inds <- 1:cumsum(demesize)[length(demesize)]
65+
inds <- seq_len(cumsum(demesize)[length(demesize)])
6666
# trackers for demes
67-
d1 <- tibble::tibble(smpl1 = inds, deme1 = as.factor(rep(1:length(demesize), demesize)),
67+
d1 <- tibble::tibble(smpl1 = inds, deme1 = as.factor(rep(seq_len(length(demesize)), demesize)),
6868
demesize1 = rep(demesize, demesize))
69-
d2 <- tibble::tibble(smpl2 = inds, deme2 = as.factor(rep(1:length(demesize), demesize)),
69+
d2 <- tibble::tibble(smpl2 = inds, deme2 = as.factor(rep(seq_len(length(demesize)), demesize)),
7070
demesize2 = rep(demesize, demesize))
7171
# combinations and joins
7272
combinds <- tibble::as_tibble(t(combn(inds, 2)), .name_repair = "minimal") %>%
@@ -77,35 +77,33 @@ sim_IBDIBD <- function(demesize, distmat, rate, Ft) {
7777

7878
# function for drawing mean IBD based iso by dist
7979
draw_mean_Ftibd <- function(demesize1, demesize2, geodist, rate, Ft) {
80-
ret <- 1/(demesize1 + demesize2) * (1 - pexp(geodist, rate)) +
80+
1/(demesize1 + demesize2) * (1 - pexp(geodist, rate)) +
8181
( (1 - 1/(demesize1 + demesize2)) * (1 - pexp(geodist, rate)) * Ft )
82-
return(ret)
8382
}
8483
combinds$mft <- purrr::pmap_dbl(combinds[,c("demesize1", "demesize2", "geodist")],
8584
draw_mean_Ftibd,
8685
rate = rate, Ft = Ft)
8786

8887
# draw value of realized IBD from mean distribution
8988
draw_realized_ibdibd <- function(mft) {
90-
ribdibd <- rnorm_interval(mean = mft, sd = mft * (1-mft),
91-
a = 0, b = 1)
92-
return(ribdibd)
89+
rnorm_interval(mean = mft, sd = mft * (1-mft),
90+
a = 0, b = 1)
9391
}
9492

9593
# tidy up and out
96-
combinds <- combinds %>%
94+
combinds %>%
9795
dplyr::mutate(gendist = purrr::map_dbl(mft, draw_realized_ibdibd)) %>%
9896
dplyr::select(c("smpl1", "smpl2", "deme1", "deme2", "gendist", "geodist"))
99-
return(combinds)
97+
10098

10199
}
102100

103101
# Deme A and B are close but A is very far from C, while B is closer (eg a right triangle)
104102
set.seed(48)
105103
IBD_simulation_data <- sim_IBDIBD(demesize = c(3,3,4), distmat = matrix(c(0,500,1000,
106-
500,0,750,
107-
100,750,0), nrow = 3),
108-
rate = 1e-3, Ft = 0.3)
104+
500,0,750,
105+
100,750,0), nrow = 3),
106+
rate = 1e-3, Ft = 0.3)
109107

110108
# drop within deme
111109
IBD_simulation_data <- IBD_simulation_data[IBD_simulation_data$geodist > 0, ]

docs/404.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/LICENSE-text.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/LICENSE.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/articles/index.html

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/articles/installation.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/authors.html

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/news/index.html

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/pkgdown.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
pandoc: '2.18'
2-
pkgdown: 2.0.5
1+
pandoc: 2.19.2
2+
pkgdown: 2.0.7
33
pkgdown_sha: ~
44
articles:
55
installation: installation.html
6-
runmod: runmod.html
7-
last_built: 2022-08-10T05:33Z
6+
runvanillamod: runvanillamod.html
7+
last_built: 2024-12-20T01:15Z
88

0 commit comments

Comments
 (0)