library(mpxtractor)
library(dplyr)
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Overview

As a part of mpxtractor some functions that are present in wrangling functions or plotting functions can be used independently. Here are explained some auxiliary functions that can be used separately.

1. format_time()

This function transform the attribute Time from hh:mm:ss to time in hours.

file <- system.file("extdata", "test_spectramax_data_1.txt", package = "mpxtractor")

df_spectramax_outdata <- mpxtractor::read_spectramax_data(file)
data_spectra <- head(df_spectramax_outdata)

htmlTable::htmlTable(as.matrix(data_spectra), caption = "**Table 1:** Shows a capture of the data with the time in hh:mm:ss format.")

Once the dataframe is created is passed to the function and the time is formatted. In the case of multiscanGO files this function return the same dataframe given as input. In this case a one warning is shown.

# Time in hours
df_hh <- mpxtractor::format_time(data_spectra)
# Time in minutes
df_mm <- mpxtractor::format_time(data_spectra, time_format = "minutes")
knitr::kable(list(df_hh, df_mm), caption = "**Table 2:** Shows a capture of
the data with the time in hours (left) and in minutes (right).")

2. compute_growth_rates()

This function can be handy when one dataset is available and we want to do a quick calculation of growth curves.

Example:

In this example the data is transform in the same way used in the example in the vignette plotting_functions. The background is subtracted followed by the log transform.

2.1 Read and load the data

In this example because is an output file from SpectraMax we use read_spectramax_data().

# Get the file path 
file_path_sp <- system.file(
  "extdata",
  "test_gr_spectramax.txt",
  package = "mpxtractor"
)
# Extract the data stored in the files into a data frame using proper wrangling function
df_sp <- mpxtractor::read_spectramax_data(
  file = file_path_sp
)

head(df_sp)

2.2 Background correction and log transform

Here we correct by the minimum measurement followed by the logarithmic transformation.

# Get the minimun measurement for each well
df <- df_sp %>%
  group_by(Wells) %>%
  mutate(min_measurement = min(Measurement))

# Subtract the minimun to each measurement
df_tmp <- df %>%
  mutate(bg_corrected = Measurement - min_measurement)

# Apply log transform and clean the dataframe
df_corrected <- df_tmp %>%
  mutate(Measurement = log(bg_corrected)) %>%
  select(-c(min_measurement, bg_corrected))

head(df_corrected)  

2.3 Compute the growth rates.

Here the the function compute_growth_rates() is used.

Some insights about this function:

Data imputation:

Growth rates calculation:

Is very important to note that the difference between time points must be equal for all them. Otherwise the time series is not complete. Remember the example with fluorstar machines.

 df_gr_data <- mpxtractor::compute_growth_rates(
   df_data = df_corrected,
   var_gr = "Measurement",
   ws = "2hs"
)
head(df_gr_data)

References



MartinBanchero/mpxtractor documentation built on March 30, 2022, 10:56 p.m.