GithubHelp home page GithubHelp logo

biometryhub / biometryassist Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 1.0 10.84 MB

A package to aid in teaching experimental design and analysis through easy access and documentation of helper functions. Renaming of previous BiometryTraining package.

Home Page: https://biometryhub.github.io/biometryassist

License: Other

R 100.00%
rstats rstats-package r package experimental-design teaching biometry

biometryassist's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

igorkf

biometryassist's Issues

Template file for analyses

It might be helpful for people if there was a way they could create template analysis files, where they just "fill in the blanks". See usethis::use_test as an example.

Speed up resplot

Apparently resplot is quite slow compared to some other plots. Can we improve this?

Does not install on R 4.0

Does not install because lmeInfo (a dependency of predictmeans) requires R >= 4.1.0.
Can we investigate why, or perhaps switch away from predictmeans?

CRAN Release

To rename the package

  • Clone to new repo

BiometryTraining

  • Add notice about rename of package
  • Merge BiometryTraining dev branch to Master
  • Build final binary versions

biometryassist

  • Change all instances of BiometryTraining to biometryassist
  • Update function names
    • mct to multiple_comparison
    • logl.test to logl_test()
    • des.info() to des_info()
  • Update function arguments from . to _
  • Run check on Rhub
  • Submit

Add W2 code as test cases

We need to automatically test against W2 code, to check that updates don't introduce bugs or errors affecting the code.

Enable more powerful treatment specification in `design()`

For example, enable entering factorial treatments with labels and levels straight into treatments =
For example:

design("crossed:crd", treatments = list(PD = c(200, 260, 330), Irr = c(20, 100, 180)), reps = 4, nrows = 6, ncols = 6)

Also, allow subplot treatments to be specified in the same way in split plot if desired.

label rotation doesn't work

autoplot(pred.out, rotation = 90, label_rotation = 45)

Should rotate the axes by 90 degrees and the labels by 45 degrees, but doesn't.

Switch to using rlang

This can replace ellipsis and we can also:

  • check for interactivity to enable testing of the package startup message
  • check required packages are installed
  • check arguments missing or required
  • Tidy evaluation of arguments?

Error in `levels<-`(`*tmp*`, value = as.character(levels)) : factor level [20] is duplicated

Hi, I have a weird issue that I'm not sure how to solve. I have a data .csv file with columns 'name', 'block', 'year', 'rep', and maturity date('mat'). On the same file is a column for larvae ('la') and another column for stem breakage ('sb'), which are the response data. Everything works great with the larvae reponse data, but get a error for running the stem breakage data...

I read that there are ways to correct by how the data is read in, but not sure where to start with this since the file is the same for data that works and for the data that doesn't.

Code:
e<-read.csv2("720_raw_blocking.csv",header=TRUE,sep=",")

library(data.table)
library(ggplot2)
library(jsonlite)
library(biometryassist)
library(asreml)

e$year <- as.factor(e$year)
e$name <- as.factor(e$name)
e$Block <- as.factor(e$Block)
e$rep <- as.factor(e$rep)
e$mat <- as.numeric(e$mat)
e$la_pro <- as.numeric(e$la_pro)
e$sb_pro <- as.numeric(e$sb_pro)

current.asr <- asreml (fixed = la_pro ~ name + year + mat, random = ~Block + rep + Block:rep,
data=e,
family=asr_binomial(link = "logit", dispersion = 1, total = 5),
na.action = na.method(x="include")
)

##or wih the response variale sb_pro if running for the sb data.

wald(current.asr)

pred.out <-multiple_comparisons(
current.asr,
classify = "name",
sig = 0.05,
int.type = "ci",
trans = NA,
offset = NA,
decimals = 2,
descending = TRUE,
plot = FALSE,
label_height = 0.1,
rotation = 0,
save = TRUE,
savename = "predicted_values_la2", #savename changes pending on the analysis
)
pred.out

##Output from when code from biometryassist is run ('pred.out <- multiple comparisions..") with the sb_pro response data (no error with the la_pro response data is used):

Binomial; Logit Mu=P=1/(1+exp(-XB)); V=Mu(1-Mu)/N
Note: The LogLik value is unsuitable for comparing GLM models

Deviance from GLM fit: 1812.25
Variance heterogenity factor (Deviance/df): 0.79
(assuming 2297 degrees of freedom)
Binomial; Logit Mu=P=1/(1+exp(-XB)); V=Mu(1-Mu)/N
Note: The LogLik value is unsuitable for comparing GLM models

Deviance from GLM fit: 1812.25
Variance heterogenity factor (Deviance/df): 0.79
(assuming 2297 degrees of freedom)
Calculating denominator DF
Binomial; Logit Mu=P=1/(1+exp(-XB)); V=Mu(1-Mu)/N
Note: The LogLik value is unsuitable for comparing GLM models

Deviance from GLM fit: 1812.25
Variance heterogenity factor (Deviance/df): 0.79
(assuming 2297 degrees of freedom)
Binomial; Logit Mu=P=1/(1+exp(-XB)); V=Mu(1-Mu)/N
Note: The LogLik value is unsuitable for comparing GLM models

Deviance from GLM fit: 1812.25
Variance heterogenity factor (Deviance/df): 0.79
(assuming 2297 degrees of freedom)
Calculating denominator DF

Error in levels<-(*tmp*, value = as.character(levels)) :
factor level [20] is duplicated

##More info on the raw data.

'data.frame': 6144 obs. of 6 variables:
$ year : Factor w/ 2 levels "2020","2021": 1 1 1 1 1 1 1 1 1 1 ...
$ rep : Factor w/ 2 levels "1","2": 1 1 1 1 1 1 1 1 1 1 ...
$ Block : Factor w/ 5 levels "1","2","3","4",..: 2 2 2 3 3 3 3 3 3 3 ...
$ name : Factor w/ 724 levels "FC004002B","FC029333",..: 1 2 3 4 5 6 7 8 9 10 ...
$ mat : num 104 102 104 98 100 98 108 108 107 105 ...
$ la_pro : num 0.6 0.4 0.8 1 0.2 1 0.4 0.4 0.4 0.8 ...
$ sb_pro : num 0.2 0.0667 0.36 0.12 0.04 ...

Thank you in advance for looking this over!

Vignette for installing asreml

It's a common question, so let's write a vignette to explain the steps.
I wonder if we can have the asreml key behind a login website like the guest wifi password?

Refactor install_asreml()

THe install_asreml() function could be refactored into a download component and an install component, possibly even refactoring some of the other functions within it as well.
This may make testing easier and enable more robust checking across different operating systems.

Output coefficient of variation

A couple of people have suggested that coefficient of variation is sometimes requested, and they would like to be able to get it.

logl.test works if random terms are given in resid

For example:

dat.asr <- asreml(response ~ Genotype, random = ~ Row + Block, 
                  residual = ~ id(Column):id(Row), data = dat)

logl.test(dat.asr, rand.terms = NULL, resid.terms = "Row")

should fail or warn, because Row is already id(Row) in resid.

Checking if model needs the present argument (sed)

Hey Sam, as suggested:

pred.out2 <- multiple_comparisons(
  model2,
  classify = 'liming_treatment:rate:year',
  present = c('year', 'control', 'liming_treatment', 'rate')
)

werks

But:

pred.out2 <- multiple_comparisons(
  model2,
  classify = 'liming_treatment:rate:year',
  present = c('year', 'control', 'liming_treatment', 'rate'),
  sed = TRUE
)

doesn't, and errors with this:

Error in asreml::predict.asreml(model.obj, classify = classify, sed = TRUE,  : 
  formal argument "sed" matched by multiple actual arguments
Error:
! Arguments in `...` must be used.
✖ Problematic arguments:
• present = c("year", "control", "liming_treatment", "rate")
• sed = TRUE
Run `rlang::last_error()` to see where the error occurred.

Looks like it's reading in the sed argument twice, so perhaps a check to make sure that arguments passed with ... are needed or not?

Issues with next version of ggplot2

Hi

We preparing the next release of ggplot2 and our reverse dependency checks show that your package is failing with the new version. Looking into it we see that this is due to changes in the warnings and errors thrown by ggplot2 that you test for in your package

You can install the release candidate of ggplot2 using devtools::install_github('tidyverse/[email protected]') to test this out.

We plan to submit ggplot2 by the end of October and hope you can have a fix ready before then

Kind regards
Thomas

Write some Vignettes

A little more in depth example than what's shown in the examples

Some ideas:

  • Generating a complex factorial design (e.g. crossed but with control treatment(s) that aren't crossed)
  • Analysis of a complex factorial design as above
  • Interpreting residual plots
  • Interpreting variograms
  • updates in the new version

Is there an NA action?

Hi I have NA's in my data and getting an error that 'NA is not allowed'. Is there a way to say 'include' or 'omit'?

Here is my code if at all helpful:
asreml_Iblock_di <- asreml (fixed = cbind (la_pro, sb_pro) ~ name + year + mat, random = ~rep + Block + rep:Block,
residual = ~id(units):us(trait),
data=e,
family=asr_binomial(link = "logit", dispersion = 1, total = 5),
na.action = na.method(x="include")
)
wald(asreml_Iblock_di, denDF = "default", ssType = "conditional")
pred.asr <- predict(asreml_Iblock_di, classify = "name", sed = TRUE)
pred.out <- mct.out(model.obj = asreml_Iblock_di, pred.obj = pred.asr,
classify = "name", order = "descending", decimals = 5, save = TRUE, savename = "predicted_values_05_23.csv")

Better defensive programming to check column names in multiple_comparisons

If a column name is provided that is too similar to the output columns, multiple_comparisons() will change the names of all the columns between the first and the maximum matching column to factors.

See example code below:

# Any of these names will break the function
c("predicted.value", "std.error", "Df",
  "groups", "PredictedValue", "ApproxSE", "ci", "low", "up")
library(biometryassist)
dat <- design("crd", LETTERS[1:4], 4, nrow = 4, ncols = 4)$design
names(dat)[5] <- "groups"
dat$response <- rnorm(16, 10)
dat.aov <- aov(response~groups, data = dat)
multiple_comparisons(dat.aov, classify = "groups", trans = "log", offset = 0)

Kruskal wallis multiple comparison test?

Hi! This is not so much a bug but a question. Can anyone recommend a r package that can take an asreml model and do a kruskal wallis with a multiple comparison output? My data is far from normal...
Thank you for your time,
Sarah

Disable warnings in logl_test

Probably not very useful to have the warnings if the model is not converging after 10 iterations. Could try changing step size after the final iteration if not converging.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.