Skip to content
Open

Cran2 #170

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
^pkgdown$
^vignettes/articles$
^DO_NOT_COMMIT*
^demon.org
^\.#.*$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ docs
tools/lib
tools/*.html
\#\*R:scripts\*\#
demon.org
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: pcvr
Type: Package
Title: Plant Phenotyping and Bayesian Statistics
Version: 1.4.0
Version: 1.4.1
Authors@R:
c(person("Josh", "Sumner", email = "jsumner@danforthcenter.org",
role = c("aut", "cre"), comment = c(ORCID = "0000-0002-3399-9063")),
Expand All @@ -21,7 +21,7 @@ License: GPL-2
Encoding: UTF-8
LazyData: true
LazyDataCompression: xz
Additional_repositories: https://mc-stan.org/r-packages/
Additional_repositories: https://stan-dev.r-universe.dev
RoxygenNote: 7.3.2
Imports:
FactoMineR,
Expand Down
19 changes: 10 additions & 9 deletions R/barg.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,16 @@
#' "sigmaA" = 20, "sigmaB" = 10, "sigmaC" = 2
#' ), type = "brms"
#' )
#' fit_test <- fitGrowth(ss,
#' iter = 600, cores = 1, chains = 1, backend = "cmdstanr",
#' sample_prior = "only" # only sampling from prior for speed
#' )
#' b <- barg(fit_test, ss)
#' fit_2 <- fit_test
#' fit_list <- list(fit_test, fit_2)
#' x <- barg(fit_list, list(ss, ss))
#'
#' if (rlang::is_installed("cmdstanr")) {
#' fit_test <- fitGrowth(ss,
#' iter = 600, cores = 1, chains = 1, backend = "cmdstanr",
#' sample_prior = "only" # only sampling from prior for speed
#' )
#' b <- barg(fit_test, ss)
#' fit_2 <- fit_test
#' fit_list <- list(fit_test, fit_2)
#' x <- barg(fit_list, list(ss, ss))
#' }
#' x <- conjugate(
#' s1 = rnorm(10, 10, 1), s2 = rnorm(10, 13, 1.5), method = "t",
#' priors = list(
Expand Down
7 changes: 5 additions & 2 deletions R/brmPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#' @import ggplot2
#' @import viridis
#' @importFrom stats as.formula
#' @importFrom rlang is_installed
#' @examples
#' \donttest{
#' simdf <- growthSim(
Expand All @@ -36,8 +37,10 @@
#' list("A" = 130, "B" = 10, "C" = 3),
#' df = simdf, type = "brms"
#' )
#' fit <- fitGrowth(ss, backend = "cmdstanr", iter = 500, chains = 1, cores = 1)
#' growthPlot(fit = fit, form = y ~ time | group, groups = "a", df = ss$df)
#' if (rlang::is_installed("cmdstanr")) {
#' fit <- fitGrowth(ss, backend = "cmdstanr", iter = 500, chains = 1, cores = 1)
#' growthPlot(fit = fit, form = y ~ time | group, groups = "a", df = ss$df)
#' }
#' }
#'
#' @return Returns a ggplot showing a brms model's credible
Expand Down
14 changes: 9 additions & 5 deletions R/brmSurvPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#' @import ggplot2
#' @import viridis
#' @importFrom stats as.formula
#' @importFrom rlang is_installed
#' @examples
#' \donttest{
#' set.seed(123)
Expand All @@ -28,17 +29,20 @@
#' model = "survival weibull", form = y > 100 ~ time | id / group,
#' df = df, start = c(0, 5)
#' )
#' fit1 <- fitGrowth(ss1, iter = 600, cores = 2, chains = 2, backend = "cmdstanr")
#' brmSurvPlot(fit1, form = ss1$pcvrForm, df = ss1$df)
#'
#' if (rlang::is_installed("cmdstanr")) {
#' fit1 <- fitGrowth(ss1, iter = 600, cores = 2, chains = 2, backend = "cmdstanr")
#' brmSurvPlot(fit1, form = ss1$pcvrForm, df = ss1$df)
#' }
#' # note that using the cumulative hazard to calculate survival is likely to underestimate
#' # survival in these plots if events do not start immediately.
#' ss2 <- growthSS(
#' model = "survival binomial", form = y > 100 ~ time | id / group,
#' df = df, start = c(-4, 3)
#' )
#' fit2 <- fitGrowth(ss2, iter = 600, cores = 2, chains = 2, backend = "cmdstanr")
#' brmSurvPlot(fit2, form = ss2$pcvrForm, df = ss2$df)
#' if (rlang::is_installed("cmdstanr")) {
#' fit2 <- fitGrowth(ss2, iter = 600, cores = 2, chains = 2, backend = "cmdstanr")
#' brmSurvPlot(fit2, form = ss2$pcvrForm, df = ss2$df)
#' }
#' }
#'
#' @return Returns a ggplot showing a brms model's credible
Expand Down
13 changes: 7 additions & 6 deletions R/brmViolin.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@
#' list("A" = 130, "B" = 10, "C" = 3),
#' df = simdf, type = "brms"
#' )
#'
#' fit <- fitGrowth(ss, backend = "cmdstanr", iter = 500, chains = 1, cores = 1)
#' brmViolin(fit, ss, ".../A_groupd > 1.05") # all groups used
#' brmViolin(fit, ss, "abs(1 - ((...)/(C_groupd - B_groupd))) > 0.05") # rather arbitrary
#' brmViolin(fit, ss, "abs(1 - ((...)/(C_groupa - B_groupd))) > 0.05") # totally arbitrary
#' brmViolin(fit, ss, "A_groupa/A_groupd > 1.05") # only these two groups
#' if (rlang::is_installed("cmdstanr")) {
#' fit <- fitGrowth(ss, backend = "cmdstanr", iter = 500, chains = 1, cores = 1)
#' brmViolin(fit, ss, ".../A_groupd > 1.05") # all groups used
#' brmViolin(fit, ss, "abs(1 - ((...)/(C_groupd - B_groupd))) > 0.05") # rather arbitrary
#' brmViolin(fit, ss, "abs(1 - ((...)/(C_groupa - B_groupd))) > 0.05") # totally arbitrary
#' brmViolin(fit, ss, "A_groupa/A_groupd > 1.05") # only these two groups
#' }
#' }
#'
#' @return Returns a ggplot showing a brms model's posterior distributions
Expand Down
8 changes: 0 additions & 8 deletions R/growthSS.R
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,6 @@
#' lapply(ss, class)
#' ss$initfun()
#' # the next step would typically be compiling/fitting the model
#' # here we use very few chains and very few iterations for speed, but more of both is better.
#' \donttest{
#' fit_test <- fitGrowth(ss,
#' iter = 500, cores = 1, chains = 1, backend = "cmdstanr",
#' control = list(adapt_delta = 0.999, max_treedepth = 20)
#' )
#' }
#'
#'
#' # formulas and priors will look different if there is only one group in the data
#'
Expand Down
14 changes: 7 additions & 7 deletions R/mvSS.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#' optionally with a plot of simulated growth curves using draws from those priors.
#' @seealso \link{fitGrowth} for fitting the model specified by this list.
#' @examples
#' \donttest{
#' set.seed(123)
#' mv_df <- mvSim(dists = list(rnorm = list(mean = 100, sd = 30)), wide = FALSE)
#' mv_df$group <- rep(c("a", "b"), times = 900)
Expand All @@ -34,11 +35,11 @@
#' model = "linear", form = label | value ~ group, df = mv_df,
#' start = list("A" = 5), type = "brms", spectral_index = "none"
#' )
#' \donttest{
#' mod1 <- fitGrowth(ss1, backend = "cmdstanr", iter = 1000, chains = 1, cores = 1)
#' growthPlot(mod1, ss1$pcvrForm, df = ss1$df)
#' library(ggplot2)
#' ggplot() + stat_brms_model(fit = mod1, ss = ss1)
#' if (rlang::is_installed("cmdstanr")) {
#' mod1 <- fitGrowth(ss1, backend = "cmdstanr", iter = 1000, chains = 1, cores = 1)
#' growthPlot(mod1, ss1$pcvrForm, df = ss1$df)
#' library(ggplot2)
#' ggplot() + stat_brms_model(fit = mod1, ss = ss1)
#' }
#'
#' # when the model is longitudinal the same model is possible with growthSS
Expand Down Expand Up @@ -97,8 +98,7 @@
#' }
#' }))
#'
#' \donttest{
#' if (rlang::is_installed("mnormt")) {
#' if (rlang::is_installed(c("cmdstanr", "mnormt"))) {
#' m2 <- fitGrowth(ss_mv1, backend = "cmdstanr", iter = 1000, chains = 1, cores = 1)
#' growthPlot(m2, ss_mv1$pcvrForm, df = ss_mv1$df)
#' }
Expand Down
8 changes: 4 additions & 4 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# pcvr 1.3.1
# pcvr 1.4.1

## R CMD check results

0 errors ✔ | 0 warnings ✔ | 2 notes ✖
0 errors ✔ | 0 warnings ✔ | 1 notes ✖

❯ checking CRAN incoming feasibility ... [4s/6s] NOTE
Maintainer: ‘Josh Sumner <jsumner@danforthcenter.org>’
Expand All @@ -15,14 +15,14 @@
Suggests or Enhances not in mainstream repositories:
cmdstanr
Availability using Additional_repositories specification:
cmdstanr yes https://mc-stan.org/r-packages/
cmdstanr yes https://stan-dev.r-universe.dev
❯ checking package namespace information ... OK
❯ checking package dependencies ... NOTE
Package suggested but not available for checking: ‘cmdstanr’

## Notes

Resubmitting due to large changes in the development version.
Resubmitting due to an error on cran when cmdstanr failed to install in testing.

No notes seem critical.
Names (PlantCV, Kruschke) and words (phenotyping) in DESCRIPTION are not misspelled.
Expand Down
19 changes: 10 additions & 9 deletions man/barg.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/brmPlot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions man/brmSurvPlot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions man/brmViolin.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions man/growthSS.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions man/mvSS.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions tests/testthat/test-mvSSModels.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,22 @@ test_that("Test brms mv trait longitudinal model", {
expect_s3_class(p, "ggplot")
})

test_that("Test brms mv trait longitudinal model from growthSS", {
skip_if_not_installed("brms")
skip_if_not_installed("cmdstanr")
skip_on_cran()
ss_mv1 <- growthSS(
model = "linear",
form = label | resp_weights(value) + trunc(lb = -1, ub = Inf) ~ time | group,
df = mv_df2, start = list("A" = 50)
)
fit <- fitGrowth(ss_mv1, backend = "cmdstanr", iter = 100, chains = 1, cores = 1,
refresh = 0, silent = 2)
expect_s3_class(fit, "brmsfit")
p <- growthPlot(fit, ss_mv1$pcvrForm, df = ss_mv1$df)
expect_s3_class(p, "ggplot")
})

test_that("Test nls mv trait longitudinal model", {
skip_on_cran()
ss_mv1 <- mvSS(
Expand Down
Binary file added tools/pcvrCoverage.rdata
Binary file not shown.
6 changes: 6 additions & 0 deletions vignettes/articles/field_capacity.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,8 @@ head(d)
Target field capacities are in the data that the phenotyping core provides and observed field capacities can be calculated from the watering metadata.

```{r}
#| fig.alt: >
#| Example of field capacity in a drought treatment that is working well
set.seed(123)
d2 <- data.frame(
day = rep(1:20, 4),
Expand Down Expand Up @@ -619,7 +621,11 @@ ggplot(d[d$variable == "field_capacity", ],
) +
pcv_theme() +
theme(legend.position = "none")
```

```{r}
#| fig.alt: >
#| Example of field capacity in a drought treatment that is not working well
ggplot(d[d$variable == "field_capacity", ],
aes(x = day, y = value)) +
facet_wrap(~treatment) +
Expand Down
Loading
Loading