Coder Social home page Coder Social logo

benjaminhlina / ecotox Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 5.75 MB

Analysis of Ecotoxicology

Home Page: https://benjaminhlina.github.io/ecotox/

License: GNU General Public License v3.0

R 100.00%
dose-response-modeling probit logit toxicology biology

ecotox's Introduction

ecotox

R-CMD-checkCRAN statusCoverage status

Overview

{ecotox} was created as a simple approach to using either a probit or logit analysis to calculate lethal concentration (LC) or time (LT) and the appropriate fiducial confidence limits desired for the selected LC or LT for ecotoxicology studies (Finney 1971; Wheeler et al. 2006; Robertson et al. 2007). The simplicity of {ecotox} comes from the syntax it implies within its functions which are similar to functions like glm() and lm(). In addition to the simplicity of the syntax, a comprehensive tibble is produced which gives the user a predicted LC or LT value for the desired level and a suite of parameters such as fiducial confidence limits, z-value, and slope. {ecotox} was built for and is published in Hlina et al. 2021.

Installation

You can install the CRAN released version of {ecotox} from CRAN with:

install.packages("ecotox")

You can install the developer version of {ecotox} from github with:

install.packages("devtools")
devtools::install_github("benjaminhlina/ecotox")

Example

This is an example which uses the LC_probit function to calculate a LC50 and LC99 for a probit analysis:

## Calculate LC50 and LC99
head(lamprey_tox)

## within the dataframe used, control dose, unless produced a value
## during experimentation, are removed from the dataframe,
## as glm cannot handle values of infinite. Other statistical programs
## make note of the control dose but do not include within analysis. 

## calculate LC50 and LC99 for May

m <- LC_probit((response / total) ~ log10(dose),
               p = c(50, 99),
               weights = total,
               data = lamprey_tox[lamprey_tox$nominal_dose != 0, ],
               subset = c(month == "May"))

## view calculated LC50 and LC99 for seasonal toxicity of a pisicide,
## 3-trifluoromethyl-4-nitrophenol (TFM) to lamprey in 2011

m

## several new features include 1) being able to change the output length 
## 2) you can indicate whether the x variable has been log10 transformed or 
## not if it has the output will take that into consideration

m_2 <- LC_probit((response / total) ~ dose,
                 p = c(50, 99),
                 weights = total,
                 data = lamprey_tox,
                 subset = c(month == "May"), 
                 log_x = FALSE, 
                 long_output = FALSE)
                  
## view calculated LC50 and LC99 for seasonal toxicity of a pisicide,
## 3-trifluoromethyl-4-nitrophenol (TFM) to lamprey in 2011.

m_2

See StackExchange post about differences in using cbind() vs. response / total cbind() function in R for a logistic regression.

## Additionally changes have been made to allow for the user 
## to use `cbind()` method when specificying the response variable  

m_3 <- LC_probit(cbind(response, survive) ~ log10(dose),
                 p = c(50, 99),
                 data = lamprey_tox[lamprey_tox$nominal_dose != 0, ],
                 subset = c(month == "May"))
                  

m_3 

# notice that m and m_3 produce the same results, however m_3 will produce 
# a warning to ensure you have not weighted the model as it is not necessary 

Example of using ratio_test from Wheeler et al. 2006 to determine differences in LC values:

## A new function `ratio_test` has been added 

# view lamprey_tox data

head(lamprey_tox)

# using glm() to detemine LC values using probit model for May and June

m <- glm((response / total) ~ log10(dose),
         data = lamprey_tox[lamprey_tox$nominal_dose != 0, ],
         subset = c(month == "May"),
         weights = total,
         family = binomial(link = "probit"))


j <- glm((response / total) ~ log10(dose),
         data = lamprey_tox[lamprey_tox$nominal_dose != 0, ],
         subset = c(month == "June"),
         weights = total,
         family = binomial(link = "probit"))

# now that both May and June models have been made. use ratio_test to
# compare LC50 values or whatever LC values of interest.

ratios <- ratio_test(model_1 = m, model_2 = j, 
                     percentage = 50, 
                     compare = "May - June")

# view ratio test results

ratios

# you can also use LC_* or LT_* objects to create the models and use ratio test:

m_1 <- LC_probit((response / total) ~ log10(dose), p = c(50, 99),
                 weights = total,
                 data = lamprey_tox[lamprey_tox$nominal_dose != 0, ],
                 subset = c(month == "May"))



j_1 <- LC_probit((response / total) ~ log10(dose), p = c(50, 99),
                 weights = total,
                 data = lamprey_tox[lamprey_tox$nominal_dose != 0, ],
                 subset = c(month == "June"))



ratios_2 <- ratio_test(model_1 = m_1, model_2 = j_1, 
                       percentage = 50,
                       compare = "May - June", 
                       obj_type = "df")

ratios_2

References

  • Finney, D.J., 1971. Probit analysis. Cambridge University Press, Cambridge, England. ISBN: 052108041X

  • Wheeler, M.W., Park, R.M., and Bailey, A.J. 2006. Comparing median lethal concentration values using confidence interval overlap or ratio tests. Environ. Toxic. Chem. 25(5), 1441-1444. 10.1897/05-320R.1

  • Robertson, J.L., Savin, N.E., Russell, R.M. and Preisler, H.K., 2007. Bioassays with arthropods. CRC press. ISBN: 0849323312

  • Version 1.4.4 written by Benjamin L. Hlina, Carleton University, Ottawa, Ontario, Canada. Written in 'Programming Language R', R version 4.1.1 (2021-08-10) -- "Kick Things". Source code is available at {ecotox} or by contacting Benjamin L. Hlina at [email protected]

ecotox's People

Contributors

benjaminhlina avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

ecotox's Issues

SE calculation

Add in the ability for it LCx and LTx to calculate asymptomatic SE, similar to what predict() calculates.

Add in feature similar to cf argument in dose.p()

cf argument in dose.p allows the user to select the slope and intercepts from the coefficient outputs. Currently this is quite hard coded into both LCx and LTx. If this could be adjusted more complex models could be created, e.g. synergistic dose response curves, where two compounds are used.

Suggested Features

Suggested Features

  • ecotox has now been up in operation for about 3 months. I've made some recent improvements, e.g. subset feature, and am still working on a spearman_karber function which I hope to implement within the next month or so. I have three other functions I want to implement:

    1. Ratio comparison test for comparing LCs and LTs following Wheeler et al. 2006
    1. A parallelism test following Robertson et al. 2007
    1. A equality test following Robertson et al. 2007.

What features or functions do people want to see? What do people think of current functions and those that are currently under development?

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.