Skip to content

Commit

Permalink
Merge pull request #41 from bedapub/cran_slow_vignettes
Browse files Browse the repository at this point in the history
cran remove slow vignettes + remove |> pipe
  • Loading branch information
idavydov authored Mar 12, 2024
2 parents 10275bc + c9ea552 commit 1e233cc
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 35 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
^vignettes/cached/.*\.Rmd$
# large vignette excluded on CRAN
^vignettes/plate_scoring_examples.Rmd$
^vignettes/plate_layouts.Rmd$
4 changes: 2 additions & 2 deletions R/all_equal_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ all_equal_df <- function(df1, df2) {
df2 <- df2[colnames(df1)]

# convert factors to characters
df1 <- df1 |>
df1 <- df1 %>%
dplyr::mutate(dplyr::across(dplyr::where(is.factor), as.character))
df2 <- df2 |>
df2 <- df2 %>%
dplyr::mutate(dplyr::across(dplyr::where(is.factor), as.character))

# order by all columns
Expand Down
2 changes: 1 addition & 1 deletion R/batch_container.R
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ BatchContainer <- R6::R6Class("BatchContainer",
}
v
}
) |>
) %>%
purrr::flatten_dbl()
assertthat::assert_that(length(res) >= length(scoring))
assertthat::assert_that(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-scoring-names.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ samples <- data.frame(i = 1:384, x = rnorm(384))

bc <- BatchContainer$new(
dimensions = c(row = 16, column = 24)
) |>
) %>%
assign_in_order(samples)


Expand Down
56 changes: 28 additions & 28 deletions vignettes/NCS22_talk.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ It uses a subset of the `longitudinal_subject_samples` dataset.
```{r get_data, include = TRUE}
data("longitudinal_subject_samples")
dat <- longitudinal_subject_samples |>
filter(Group %in% 1:5, Week %in% c(1, 4)) |>
dat <- longitudinal_subject_samples %>%
filter(Group %in% 1:5, Week %in% c(1, 4)) %>%
select(SampleID, SubjectID, Group, Sex, Week)
# for simplicity: remove two subjects that don't have both visits
dat <- dat |>
dat <- dat %>%
filter(SubjectID %in%
(dat |> count(SubjectID) |> filter(n == 2) |> pull(SubjectID)))
(dat %>% count(SubjectID) %>% filter(n == 2) %>% pull(SubjectID)))
subject_data <- dat |>
select(SubjectID, Group, Sex) |>
subject_data <- dat %>%
select(SubjectID, Group, Sex) %>%
unique()
```

Expand All @@ -56,7 +56,7 @@ This is the experiment design:

```{r, fig.width= 4, fig.height=3, echo = FALSE}
data("plate_effect_example")
plate_effect_example |>
plate_effect_example %>%
ggplot() +
aes(x = column, y = row, fill = treatment, alpha = log_conc) +
geom_tile() +
Expand All @@ -74,7 +74,7 @@ plate_effect_example |>
These are the readouts:

```{r, fig.width= 4, fig.height=5, echo = FALSE}
p1 <- plate_effect_example |>
p1 <- plate_effect_example %>%
ggplot() +
aes(x = column, y = row, fill = readout) +
geom_tile() +
Expand All @@ -86,9 +86,9 @@ p1 <- plate_effect_example |>
scale_fill_viridis_c() +
ggtitle("Readout")
p2 <- plate_effect_example |>
filter(treatment == "control") |>
mutate(column = as.numeric(column)) |>
p2 <- plate_effect_example %>%
filter(treatment == "control") %>%
mutate(column = as.numeric(column)) %>%
ggplot() +
aes(x = column, y = readout, color = row) +
geom_point() +
Expand All @@ -114,15 +114,15 @@ set.seed(17) # gives `bad` random assignment
bc <- BatchContainer$new(
dimensions = list("batch" = 3, "location" = 11)
) |>
) %>%
assign_random(subject_data)
```

Gone wrong: Random distribution of 31 grouped subjects into 3 batches
turns out unbalanced:

```{r, fig.width= 3, fig.height=3, echo = FALSE}
bc$get_samples() |>
bc$get_samples() %>%
ggplot(aes(x = batch, fill = Group)) +
geom_bar() +
labs(y = "subject count")
Expand Down Expand Up @@ -169,7 +169,7 @@ set.seed(17) # gives `bad` random assignment
```{r}
bc <- BatchContainer$new(
dimensions = list("batch" = 3, "location" = 11)
) |>
) %>%
assign_random(subject_data)
```

Expand All @@ -179,11 +179,11 @@ bc <- BatchContainer$new(
```{r, fig.width= 5.5, fig.height=3, echo = FALSE}
cowplot::plot_grid(
plotlist = list(
bc$get_samples() |>
bc$get_samples() %>%
ggplot(aes(x = batch, fill = Group)) +
geom_bar() +
labs(y = "subject count"),
bc$get_samples() |>
bc$get_samples() %>%
ggplot(aes(x = batch, fill = Sex)) +
geom_bar() +
labs(y = "subject count")
Expand All @@ -198,18 +198,18 @@ bc$get_samples()

```{r, echo=FALSE}
bind_rows(
head(bc$get_samples(), 3) |>
head(bc$get_samples(), 3) %>%
mutate(across(everything(), as.character)),
tibble(
batch = "...",
location = " ...",
SubjectID = "...",
Group = "...", Sex = "..."
),
tail(bc$get_samples(), 3) |>
tail(bc$get_samples(), 3) %>%
mutate(across(everything(), as.character))
) |>
gt::gt() |>
) %>%
gt::gt() %>%
gt::tab_options(
table.font.size = 11,
data_row.padding = 0.1
Expand Down Expand Up @@ -250,11 +250,11 @@ bc <- optimize_design(
```{r, fig.width= 8, fig.height=3, echo = FALSE}
cowplot::plot_grid(
plotlist = list(
bc$get_samples() |>
bc$get_samples() %>%
ggplot(aes(x = batch, fill = Group)) +
geom_bar() +
labs(y = "subject count"),
bc$get_samples() |>
bc$get_samples() %>%
ggplot(aes(x = batch, fill = Sex)) +
geom_bar() +
labs(y = "subject count"),
Expand All @@ -267,18 +267,18 @@ cowplot::plot_grid(

```{r, echo=FALSE}
bind_rows(
head(bc$get_samples(), 3) |>
head(bc$get_samples(), 3) %>%
mutate(across(everything(), as.character)),
tibble(
batch = "...",
location = " ...",
SubjectID = "...",
Group = "...", Sex = "..."
),
tail(bc$get_samples(), 3) |>
tail(bc$get_samples(), 3) %>%
mutate(across(everything(), as.character))
) |>
gt::gt() |>
) %>%
gt::gt() %>%
gt::tab_options(
table.font.size = 11,
data_row.padding = 0.1
Expand Down Expand Up @@ -315,7 +315,7 @@ set.seed(4)
bc <- BatchContainer$new(
dimensions = list("plate" = 3, "row" = 4, "col" = 6)
) |>
) %>%
assign_in_order(dat)
```

Expand Down Expand Up @@ -496,7 +496,7 @@ see vignette `invivo_study_design` for the full story.


```{r, fig.width=4.0, fig.hight = 5.0, echo = FALSE}
layout <- crossing(row = 1:9, column = 1:12) |>
layout <- crossing(row = 1:9, column = 1:12) %>%
mutate(Questions = "no")
layout$Questions[c(
16, 17, 18, 19, 20, 21,
Expand Down
6 changes: 3 additions & 3 deletions vignettes/plate_layouts.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ We can look at the trace objects for each internal `optimize_design` run,
returned from the wrapper function.

```{r fig.width=6, fig.height=3}
bc$scores_table() |>
bc$scores_table() %>%
ggplot(aes(step, value, color = score)) +
geom_line() +
geom_point() +
Expand Down Expand Up @@ -328,7 +328,7 @@ cowplot::plot_grid(
```

```{r fig.width=5.5, fig.height=2}
bc$scores_table() |>
bc$scores_table() %>%
ggplot(aes(step, value, color = score)) +
geom_line() +
geom_point() +
Expand Down Expand Up @@ -556,7 +556,7 @@ cowplot::plot_grid(


```{r fig.width=6, fig.height=4}
bc$scores_table() |>
bc$scores_table() %>%
ggplot(aes(step, value, color = score)) +
geom_line() +
geom_point() +
Expand Down

0 comments on commit 1e233cc

Please sign in to comment.