library(mpxtractor) library(dplyr) knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
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.
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).")
This function can be handy when one dataset is available and we want to do a quick calculation of growth curves.
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.
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)
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)
Here the the function compute_growth_rates()
is used.
Some insights about this function:
Data imputation:
If the attribute used to calculate growth rates contain Inf/-Inf values this are transformed to NAs
and impute using k=1, this means that one value to the right and one to the left are used to calculate the mean of that missing value.
In the case that there more than one NA
the function scan both sides until it finds the next value.
Growth rates calculation:
The argument var_gr is the attribute used to calculate the growth rates.
The growth rates are calculated using sgolayfilt() from the package @signal, this function is taking: the first derivative, the windowlength given as a parameter in compute_growth_rates()
and using as a time scaling factor the time points used in the experiment.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.