Package 'fluoSurv'

Title: Estimate Insect Survival from Fluorescence Data
Description: Use spectrophotometry measurements performed on insects as a way to infer pathogens virulence. Insect movements cause fluctuations in fluorescence signal, and functions are provided to estimate when the insect has died as the moment when variance in autofluorescence signal drops to zero. The package provides functions to obtain this estimate together with functions to import spectrophotometry data from a Biotek microplate reader. Details of the method are given in Parthuisot et al. (2018) <doi:10.1101/297929>.
Authors: Jean-Baptiste Ferdy <[email protected]>
Maintainer: Jean-Baptiste Ferdy <[email protected]>
License: GPL-3
Version: 1.0.0
Built: 2024-09-19 03:42:53 UTC
Source: https://github.com/cran/fluoSurv

Help Index


Estimation of time to death

Description

Estimation of time to death

Usage

estimate.LT(y, t, threshold.value = NULL, offset.dead = NULL,
  offset.alive = NULL, verbose = F, ndeps = 0.01)

Arguments

y

The signal to analize

t

The time values

threshold.value

Detection threshold below which signal is considered as pure noise

offset.dead

Offset derived from variance in signal in dead insects

offset.alive

Offset derived from variance in signal in living insects

verbose

If true additionnal informations on computations are displayed

ndeps

Step size used in optim to estimate parameters

Details

The model adjusted in this procedure assumes that random variance in signal drops after insect death, because insect has ceased to move. The time value at which this drop occurs can therefore be used as an estimate of lethal time. First guess of variance estimates can be provided as offset.dead (for dead insects) or offset.alive (for living insects).

Value

A vector with TL estimate for the given sample, corresponding log-likelihood and number of values used in the computation.

Examples

##Loading data
data("galleria")
## dataset may contain NA if microplate reader has been stoped before the programmed
## end of the experiment
d <- subset(galleria,!is.na(value))
l  <- lapply(split(d,d$well),extract.well)

data(setup)
setup <- setup[match(setup$well,names(l)),]

## Computes rough estimates of variance in autofluorescence signal for dead and living insects
## These values serve as initial guess to fit the model.
offset.alive <- estimate.offset(l,"1_330_405",min.t=1,max.t=5)
    # all insects are assumed to be alive during the
    # first five hours that follow injection

offset.dead <- estimate.offset(l[which(setup$dead==1)],"1_330_405",min.t=72-5)
    # insects that were dead at the end of the experiment are
    # assumed to have died earlier than 5 hours before then
    # end of the experiment


## LT estimation or for a single well
## Check out well D9, to see what happens when an insect stayed alive.
well <- "A3"
plot(log(value_1_485_535,10)~t_1_485_535,type="l",col="green",ylim=c(2,5),data=l[[well]])
points(log(value_1_330_405,10)~t_1_330_405,type="l",col="gray",data=l[[well]])
    # Rough estimate obtained using no offsets
est1 <- with(l[[well]], estimate.LT(value_1_330_405,t_1_330_405,threshold.value=3))
abline(v=est1[["LT"]],lty=2,col="red")
    # Much better estimate obtained using offset for dead insects
est2 <- with(l[[well]], estimate.LT(value_1_330_405,t_1_330_405,
                                         offset.dead = offset.dead,threshold.value=3))
abline(v=est2["LT"],lty=3,col="red")
    # Using offset.alive does not change anything to the estimate for well A3
    # It may help for insect that have a larger variance in signal than others even after death
est3 <- with(l[[well]], estimate.LT(value_1_330_405,t_1_330_405,
                                         offset.dead = offset.dead,
                                         offset.alive = offset.alive,threshold.value=3))
abline(v=est3["LT"],col="red")
    # Detection of significant GFP fluorescence (i.e. log fluorescence exceed
    # by 5% the maximum value observed during the first five hours)
with(l[[well]],abline(v=when.threshold(t_1_485_535,log(value_1_485_535,10),
                                                            threshold=0.1),col="green"))


##LT estimation for all wells
if(FALSE) { #example takes time! Set to TRUE if you want to run it
   res <- sapply(l,function(x) estimate.LT(x$value_1_330_405,x$t_1_330_405,
                                               threshold.value=2,offset.dead=offset.dead,
                                               offset.alive=offset.alive))
  res <- as.data.frame(t(res))
##Adds LT estimates to the experimental setup data.frame
  setup <- cbind(setup,res[match(setup$well,rownames(res)),])
## Time of injection is added to LT, so that LT really corresponds to time post injection
  time <- with(setup,strptime(as.character(time_injection),format="%H:%M:%S"))
  time <- as.numeric((max(time)-time)/(60^2))
  setup$LT <- setup$LT+time


## Survival curves by dilution of bacterial culture injected
  library(survival)
  plot(survfit(Surv(LT,dead)~dilution,data=setup),
     lwd=c(3:1,1),lty=c(1,1,1,2),
     xlab="hours post injection",ylab="proportion of surviving insects")
  abline(h=0.5,col="red")
  legend("topright",lwd=c(1,3:1),lty=c(2,1,1,1),legend=c("LB",10^(3:1)))

## When does scepticemia start?
  res <- sapply(l,function(x) when.threshold(x$t_1_485_535,log(x$value_1_485_535,10),
                                                                    threshold=0.1))
  setup$T_gfp <- res[match(setup$well,names(res))]
  setup$T_gfp <- setup$T_gfp + time

## Relation between time of death and moment when scepticemia is detected.
## Only points where scepticemia has been detected are represented here.
  plot(LT~T_gfp,data=setup,col=ifelse(dead,1,2),pch=as.numeric(dilution))
  abline(0,1)
  with(setup,legend("topleft",legend=levels(dilution),pch=1:4))
  # Most insects have died after scepticemia has started.
  }

Estimate variance in signal

Description

Estimate variance in signal

Usage

estimate.offset(l, var, min.t = NULL, max.t = NULL)

Arguments

l

A list object with each element being measurement for a sample

var

A character string corresponding to the name of the signal used to estimate lethal time

min.t

The time after which signal will be used to compute offset

max.t

The time before which signal will be used to compute offset

Value

A value that can be used as an offset in estimate.LT


Extract data for a single well

Description

Extract data for a single well

Usage

extract.well(data)

Arguments

data

A data.frame containing fluorescence measurements for the 96 wells of a plate and several time values. See read.kinetics for a way to obtain such a data.frame from data files produced by a Biotech plate-reader.

Details

The number of measurements might differ between wavelengths. In the Biotek reader used here, this can happen if fluorescence value exceeds the maximum value of 10^6. NA are then added to the data.frame.

Value

A data.frame


fluoSurv: A package for estimating insect survival data from spectrophotometry measurements

Description

The fluoSurv package provides functions to import fluorescence data as exported from a BioTek microplate reader and functions to estimate insect survival from these fluorescence data.

The function to import data

read.kinetic

The function to estimate survival

estimate.LT


Fluorescence data measured on Galleria mellonella

Description

A dataset containing fluoresence measurements produced by a BioTek microplate reader. Measurements are taken from 96 larvae of Galleria mellonella which have been injected with a culture of the bacterium Xenorhabdus nematophila.

Format

A data frame with 382944 rows and 8 variables:

well

Well name.

value

Intensity measurement.

t

Time.

num

Is the insect dead at the end of the experiment?

read

Read number, usually 1. This number will be greater than one when a combination of excitation and emission wavelengths is measured several times, with different gains.

exc

Excitation wavelength.

em

Emission wavelength.

ID_read

ID of the read. Combines read number and wavelengths to produce a unique ID for each set of fluorescence measurement. For example, if GFP fluoerscence has been measured with two different gains, the two measurements will be 1_485_535 and 2_485_535.


Reads a kinetic file, as produced by a Biotek plate reader.

Description

Reads a kinetic file, as produced by a Biotek plate reader.

Usage

read.kinetic(name, path = NULL, readTime = TRUE, saveData = TRUE)

Arguments

name

The name of the file to be read

path

The path where the file is to be found

readTime

Should time data be read?

saveData

Should the resulting data.frame be saved?

Value

Returns a data.frame if saveData is set to FALSE. If saveData is set to TRUE, the data.frame is saved and the file name is returned.

Examples

## reads data. Warning: files are large, and this operation takes time!
d <- read.kinetic("kinetics_xenorhabdus_galleria.txt",
                     path=system.file('extdata', package = 'fluoSurv'),
                     saveData=FALSE)
str(d)

## saveData should rather be set to TRUE so that converted data are saved
## in a csv file and can be re-used later on.

An injection experimental setup

Description

A dataset containing the description of an experimental setup where 96 larvae of Galleria mellonella have been injected with a culture of the bacterium Xenorhabdus nematophila.

Format

A data frame with 96 rows and 4 variables:

well

Well name.

dilution

Dilution factor (log-transformed) of the injected culture. 1 therefore means 10 fold dilution, while LB corresponds to negative control where insects have been injected with sterile LB culture medium.

time_injection

Time of the injection.

dead

Is the insect dead at the end of the experiment?


Computes when fluorescence exceeds a given threshold value

Description

Computes when fluorescence exceeds a given threshold value

Usage

when.threshold(t, x, min.t = 5, threshold = 0.1, n = 50)

Arguments

t

The time value

x

The fluorescence value

min.t

The time value after which threshold value is searched

threshold

Threshold value, as a proportion above the maximum intensity value observed before min.t

n

Width of the moving average window used to smooth signal

Examples

data(galleria)
d <- subset(galleria,!is.na(value))
l  <- lapply(split(d,d$well),extract.well)   #complete kinetics for each well

with(l[["A3"]],plot(t_2_485_535,log(value_2_485_535,10),type="l"))
with(l[["A3"]],abline(v=when.threshold(t_2_485_535,value_2_485_535)))