The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

insectecol

R-CMD-check License: MIT

Introduction

insectecol (Insect Ecology Data Analysis Toolkit) is a collection of analytical tools for insect ecology research. It currently ships two modules:

Which main function should I use?

Each module has a main function for analysing data that are already loaded in R (a data frame or plain vectors) and a one-step batch function for processing csv files on disk:

Module Main function (data in R) One-step batch (csv on disk)
Life table lifeTable_analyze() lifeTable_calculate()
Bioassay lc50_analyze() save_lc50_auto() (tables), save_lc50_plot_auto() (figures)

The main functions assemble the data, compute everything and optionally build the plots, but never write to disk - export is handled separately by save_results(), save_lc50() and save_lc50_plot(), so the results stay fully customisable inside R.

For full control, every module can also be driven step by step (read_life_table() -> lifeTable_calculate_all() -> plot_sxj() -> save_results(), and read_lc50() -> lc50_calculate() -> plot_lc50() -> save_lc50() / save_lc50_plot()); see the function reference below.

Planned extensions include more insect ecology indicators, such as the median lethal temperature/time (LT50) and thermal constants (effective accumulated temperature).

Installation

# from CRAN (once accepted)
install.packages("insectecol")

# development version from GitHub
# install.packages("devtools")
devtools::install_github("SeaGhost-0/insectecol")

Quick start: life table

library(insectecol)

# example data shipped with the package
f <- system.file("extdata", "Example.csv", package = "insectecol")
d <- read.csv(f)

# analyse straight from the columns of the loaded data frame
out <- lifeTable_analyze(
  stages = d[2:8],           # one column per immature stage
  adult_days = d$Adult,      # adult survival days
  sex = d$gender,            # "F" / "M" / "N" (died before adult)
  oviposition = d[, 11:17],  # daily oviposition of the females
  file_name = "Example"
)

out$results$N        # cohort size
out$results$R0       # net reproductive rate
out$results$lambda   # finite rate of increase

# survival analysis only: skip the reproduction-related parameters
out2 <- lifeTable_analyze(
  stages = d[2:8],
  adult_days = d$Adult,
  sex = d$gender,
  fecundity = FALSE          # no oviposition data required
)

# with the age-stage survival curve (a ggplot object)
out3 <- lifeTable_analyze(
  stages = d[2:8], adult_days = d$Adult, sex = d$gender,
  oviposition = d[, 11:17], plot = TRUE
)
print(out3$plot)

To batch-process csv files on disk instead (each csv gets its own Excel workbook with all results and the survival curve; an additional all.xlsx summarises every file):

lifeTable_calculate("path/to/lifetable_data")

Quick start: bioassay (LC)

library(insectecol)

# three parallel vectors - no csv file involved
conc   <- c(0, 1.5, 3, 6, 12, 24)
tested <- c(120, 60, 60, 60, 60, 60)
dead   <- c(7, 9, 18, 32, 48, 57)

out <- lc50_analyze(
  concentration = conc,
  tested = tested,
  dead = dead,
  name = "trial1",
  method = "all",            # traditional + improved + probit in one call
  lc = 0.5                   # LC50; any proportion works (e.g. 0.9 = LC90)
)

out$results$summary_df       # estimate, 95% CI, slope, chi-square, ...

# ... or straight from the example csv shipped with the package
f <- system.file("extdata", "bioassay.csv", package = "insectecol")
out_csv <- lc50_analyze(read_lc50(f), method = "all")
out_csv$results$summary_df

# with the regression plot (a named list of ggplot objects)
out2 <- lc50_analyze(
  concentration = conc, tested = tested, dead = dead,
  name = "trial1", method = "probit", plot = TRUE
)
print(out2$plot$trial1)

To batch-process csv files on disk instead (one xlsx / one tiff per csv, written next to the raw data; non-default settings are appended to the file names, e.g. LB_48_LC90_probit.xlsx):

save_lc50_auto("path/to/bioassay_data", method = "probit")
save_lc50_plot_auto("path/to/bioassay_data", method = "probit")

Example data

Two example csv files ship with the package in inst/extdata/; the examples in this README and in the help pages are built on them:

system.file("extdata", "Example.csv", package = "insectecol")   # life table
system.file("extdata", "bioassay.csv", package = "insectecol")  # bioassay

The file layouts are described in detail under Data formats.

Data formats

Life table csv

One row per individual. If the sex column is at position n:

Column Content
1 individual ID (header ID)
2 … n-2 days spent in each immature stage (egg, instars, prepupa, pupa)
n-1 adult survival days
n sex: F, M or N (died before the adult stage); header gender
n+1 … daily oviposition of the females (one column per day)

The first line must contain the stage names as headers. The sex column is located automatically, and the file encoding is detected automatically (UTF-8 and GBK are both supported).

Bioassay csv

One row per concentration group (replicates = repeated concentration values):

Column Content
Concentration the concentration (0 = control group, used for the Abbott correction)
Tested number of insects tested
Dead number of dead insects

Headers are matched loosely, so a header like Concentration (mg/L) is recognised as well. UTF-8 (with BOM) and GBK encodings are supported.

Function reference

Life table module

Function Purpose
lifeTable_analyze() main function - analyse data in R (build + compute + optional plot)
build_life_table() build a life_table object from user-supplied columns
read_life_table() read and validate a life table csv file
lifeTable_calculate() batch: analyse every csv in a folder and export to Excel
lifeTable_calculate_all() all parameters of one life_table object
calc_N(), calc_F(), calc_sxj(), calc_lx(), calc_fxj(), calc_mx(), calc_ex(), calc_R0(), calc_r(), calc_lambda(), calc_T() individual indicators
plot_sxj() age-stage survival rate curves
save_results() export one analysis to Excel
check_life_table(), get_stage_names(), default_stage_names() helpers

Bioassay module

Function Purpose
lc50_analyze() main function - analyse data in R (build + compute + optional plots)
read_lc50() read bioassay csv file(s)
lc50_calculate() compute the LC values; several methods (or "all") in one call
plot_lc50() regression plots
save_lc50() export results to Excel
save_lc50_plot() export figures
save_lc50_auto() one-step batch: csv file(s) -> Excel workbook(s)
save_lc50_plot_auto() one-step batch: csv file(s) -> tiff figure(s)
check_path_type() path helper (folder / csv file)

Updates

1.0.1 (CRAN submission round)

New features

CRAN fixes

Internal changes

1.0.0

Note on bundled fonts

This package bundles the Liberation Serif font (SIL Open Font License 1.1) in inst/fonts/ for publication-quality figures. The full license text is shipped as inst/fonts/OFL.txt. All other components of the package are licensed under MIT.

License

MIT (see LICENSE). The bundled Liberation Serif font is licensed under the SIL Open Font License 1.1.

Citation

citation("insectecol")

If you use the life table module in a publication, please also cite the method papers behind the age-stage, two-sex theory (Chi & Liu 1985; Chi 1988 - see the references of read_life_table()), and for probit analysis Finney (1971) together with Abbott (1925) for the correction of natural mortality.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.