Skip to content

Commit

Permalink
fix wordlist
Browse files Browse the repository at this point in the history
  • Loading branch information
d-morrison committed Jul 15, 2024
1 parent ee1f434 commit f5c4984
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 64 deletions.
113 changes: 49 additions & 64 deletions R/stratify_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,45 +28,41 @@
#' noise_strata_varnames = NULL
#' )
#' }
stratify_data <- function(
data,
antigen_isos = data %>% attr("antigen_isos"),
curve_params,
noise_params,
strata_varnames = "",
curve_strata_varnames = NULL,
noise_strata_varnames = NULL) {

stratify_data <- function(data,
antigen_isos = data %>% attr("antigen_isos"),
curve_params,
noise_params,
strata_varnames = "",
curve_strata_varnames = NULL,
noise_strata_varnames = NULL) {
no_strata = is.null(strata_varnames) || all(strata_varnames == "")
if (no_strata) {
all_data <-
list(pop_data = data %>% select(
all_of(
list(
pop_data = data %>% select(all_of(
c(
data %>% get_value_var(),
data %>% get_age_var(),
"antigen_iso"
)
)
),
curve_params = curve_params %>% select(all_of(c("y1", "alpha", "r", "antigen_iso"))),
noise_params = noise_params %>% select(all_o(c("nu", "eps", "y.low", "y.high", "antigen_iso")))
)),
curve_params =
curve_params %>%
select(all_of(c(
"y1", "alpha", "r", "antigen_iso"
))),
noise_params =
noise_params %>%
select(all_of(
c("nu", "eps", "y.low", "y.high", "antigen_iso")
))

Check warning on line 58 in R/stratify_data.R

View check run for this annotation

Codecov / codecov/patch

R/stratify_data.R#L42-L58

Added lines #L42 - L58 were not covered by tests
) %>%
structure(
class = union(
"biomarker_data_and_params",
"list"
)
)
structure(class = union("biomarker_data_and_params", "list"))

Check warning on line 60 in R/stratify_data.R

View check run for this annotation

Codecov / codecov/patch

R/stratify_data.R#L60

Added line #L60 was not covered by tests

stratumDataList <-
list( # est.incidence.by() expects a list.
`all data` = all_data
) %>%
structure(
antigen_isos = antigen_isos,
strata = tibble(Stratum = NA)
)
list(# est.incidence.by() expects a list.
`all data` = all_data) %>%
structure(antigen_isos = antigen_isos, strata = tibble(Stratum = NA))

Check warning on line 65 in R/stratify_data.R

View check run for this annotation

Codecov / codecov/patch

R/stratify_data.R#L63-L65

Added lines #L63 - L65 were not covered by tests


return(stratumDataList)
Expand Down Expand Up @@ -106,19 +102,14 @@ stratify_data <- function(
list(
pop_data =
data %>%
semi_join(
cur_stratum_vals,
by = strata_varnames
) %>%
select(
all_of(
c(
data %>% get_value_var(),
data %>% get_age_var(),
"antigen_iso"
)
semi_join(cur_stratum_vals, by = strata_varnames) %>%
select(all_of(
c(
data %>% get_value_var(),
data %>% get_age_var(),
"antigen_iso"
)
)
))
)

if (length(strata_vars_curve_params) == 0) {
Expand All @@ -127,45 +118,39 @@ stratify_data <- function(
} else {
data_and_params_cur_stratum$curve_params <-
curve_params %>%
semi_join(
cur_stratum_vals,
by = strata_vars_curve_params
) %>%
semi_join(cur_stratum_vals, by = strata_vars_curve_params) %>%
select(all_of(c("y1", "alpha", "r", "antigen_iso")))

Check warning on line 122 in R/stratify_data.R

View check run for this annotation

Codecov / codecov/patch

R/stratify_data.R#L121-L122

Added lines #L121 - L122 were not covered by tests
}

if (length(strata_vars_noise_params) == 0) {
data_and_params_cur_stratum$noise_params <-
noise_params %>%
select(all_of(c("nu", "eps", "y.low", "y.high", "antigen_iso")))
select(all_of(c(
"nu", "eps", "y.low", "y.high", "antigen_iso"
)))
} else {
data_and_params_cur_stratum$noise_params <-
noise_params %>%
semi_join(
cur_stratum_vals,
by = strata_vars_noise_params
) %>%
select(all_of(c("nu", "eps", "y.low", "y.high", "antigen_iso")))
semi_join(cur_stratum_vals, by = strata_vars_noise_params) %>%
select(all_of(c(
"nu", "eps", "y.low", "y.high", "antigen_iso"
)))

Check warning on line 137 in R/stratify_data.R

View check run for this annotation

Codecov / codecov/patch

R/stratify_data.R#L134-L137

Added lines #L134 - L137 were not covered by tests
}

stratumDataList[[cur_stratum]] <-
data_and_params_cur_stratum %>%
structure(
class = union(
"biomarker_data_and_params",
class(data_and_params_cur_stratum)
)
)
structure(class = union(
"biomarker_data_and_params",
class(data_and_params_cur_stratum)
))
}



return(
structure(
stratumDataList,
antigen_isos = antigen_isos,
strata = strata,
class = c("biomarker_data_and_params.list", "list")
)
)
return(structure(
stratumDataList,
antigen_isos = antigen_isos,
strata = strata,
class = c("biomarker_data_and_params.list", "list")
))
}
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Wiens
Zota
al
behaviour
biomarker
campylobacteriosis
de
der
Expand Down

0 comments on commit f5c4984

Please sign in to comment.