library(mpxtractor) library(dplyr) knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.align = "center", fig.show = "hold", dev = "png")
This section explains two functions of mpxtractor
to visualize the layout files and the growth rates over a microplate representation. This functions are
plot_layout_file() and plot_gr_microplate() respectively.
In the next sections both functions are explained and one example is provided for
each function.
This function can take several arguments in order to improve the flexibility. The first argument is a .csv layout with the proper format(check .csv files in folder inst/extdata). The following arguments are the features that are required to identify the different conditions, like var_shape and var_colour.
Important remarks: Note that in order to obtain a better visualization the argument var_shape should contain less than six different factors. While var_color has no limits.
The implementation was taken from @plot_microtiter_plate with some minor modifications.
file_path_fl <- system.file( "extdata", "test_layout_file.csv", package = "mpxtractor" ) plot <- mpxtractor::plot_layout_file( file = file_path_fl, var_shape = "strain", var_colour = "condition", output_filename = "layout_visualization.png" )
The main objective of this function is to obtain one quick overview of the experiment performed in one microplate calculating the growth rates in each well. There are a few numbers of steps that must be followed to make this function run smoothly.
This is a very important step, here we combine the raw data with the information stored in the layout files. This can be done easily using the wrangling functions
of mpxtractor
. The first step consists of stored the data stored in the files
into a data frame, using the corresponding function depending on the type of machine
that generated the data. This can be read_spectramax_data(), read_multiscango_data()
or read_fluorstar_data(). In the following example read_spectramax_data() is used.
# 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 ) # Show tidy data head(df_sp)
In this step, the data frame obtained above is combined with the layout scheme, using df_data_combine() is possible to perform this action simply. In the example below one layout file is used to be combined with the data frame with raw data.
# get the path to file file_path_layout <- system.file( "extdata", "test_layout_file.csv", package = "mpxtractor" ) # combine raw data with layout scheme df_data_combine <- mpxtractor::combine_data_with_layout( df_data = df_sp, reader_type = "spectramax", layout_files = file_path_layout ) head(df_data_combine)
Once all the data is stored in the data frame the function can be used. However few considerations must be addressed.
file <- system.file("extdata", "test_fluorstar_fluorescence_data.txt", package = "mpxtractor") df_fl <- mpxtractor::read_fluorstar_data(file) cols <- with(df_fl, ifelse(Time == "00:02:00", 'magenta', 'white')) table1 <- head(df_fl) htmlTable::htmlTable(as.matrix(table1), col.rgroup = cols, caption = "**Table 1:** Shown in magenta the row containing the time value that breaks the time series")
The argument var_gr indicates which attribute in the data frame is used to calculate the growth rates. It is important to apply transformations to this attribute before using the function i.e apply background correction or log transformation. One possible approach is shown below.
The argument ws is a character, this is because the number to be used is followed by the string hs to remain the user the units of the argument.
# Get the minimun measurement for each well df <- df_data_combine %>% 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)
After the few steps explained before the function plot_gr_microplate() can be used to calculate growth rates and displayed over the microplate frame. This last function is inspired in @subplots.
microplateplot <- mpxtractor::plot_gr_microplate( df_data = df_corrected, var_gr = "Measurement", exp_title = "Spectramax experiment", ws = "2hs", cond_to_col = "condition", output_filename = "growth_rate_corrected.png" )
knitr::include_graphics('growth_rate_corrected.png')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.