Title: | Processing 'Gen5' 2.06 Exported Data |
---|---|
Description: | A collection of functions for processing 'Gen5' 2.06 exported data. 'Gen5' is an essential data analysis software for BioTek plate readers <https://www.biotek.com/products/software-robotics-software/gen5-microplate-reader-and-imager-software/>. This package contains functions for data cleaning, modeling and plotting using exported data from 'Gen5' version 2.06. It exports technically correct data defined in (Edwin de Jonge and Mark van der Loo (2013) <https://cran.r-project.org/doc/contrib/de_Jonge+van_der_Loo-Introduction_to_data_cleaning_with_R.pdf>) for customized analysis. It contains Boltzmann fitting for general kinetic analysis. See <https://www.github.com/yanxianUCSB/gen5helper> for more information, documentation and examples. |
Authors: | Yanxian Lin [aut, cre] |
Maintainer: | Yanxian Lin <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.1 |
Built: | 2025-03-06 03:32:52 UTC |
Source: | https://github.com/ylin00/gen5helper |
Cast an object to match class of another object
as.is(x, vec)
as.is(x, vec)
x |
object to transform |
vec |
object to extract class |
as.is(c("1", "2", "3"), 1:3)
as.is(c("1", "2", "3"), 1:3)
Boltzmann model for fitting time series data
Boltzmann(time_, val_, A0 = 1, k0 = 1, t20 = 1)
Boltzmann(time_, val_, A0 = 1, k0 = 1, t20 = 1)
time_ |
time series |
val_ |
normalized value |
A0 |
amplititude |
k0 |
rate constant |
t20 |
halt time |
a model
Boltzmann(1:10, c(0,0,1,3,5,7,9,10,10,10), A0 = 10, k0 = 10, t20 = 5)
Boltzmann(1:10, c(0,0,1,3,5,7,9,10,10,10), A0 = 10, k0 = 10, t20 = 5)
this is a file for functions that are universally useful at common data manipulations Convert factor to numeric
factor2num(x)
factor2num(x)
x |
factor |
factor2num(factor(c('1', '10', '100')))
factor2num(factor(c('1', '10', '100')))
fit.boltzmann() using Boltzmann model to fit readings and time intervals with unit of hours, using start as initial guesses. It appends A, y0, k, t2 and val.predict, while preserving existing variables.
fit.boltzmann(.data, A0 = 1, k0 = 1, t20 = 1)
fit.boltzmann(.data, A0 = 1, k0 = 1, t20 = 1)
.data |
data.frame with x as time, y as value |
A0 |
initial guess of amplititue, default 1 |
k0 |
initial guess, default 1 |
t20 |
initial guess, default 1 |
data.frame with fitted parameter and predicted value
fit.boltzmann(data.frame(x=1:10,y=c(0,0,1,3,5,7,9,10,10,10)), A0 = 10, k0 = 10, t20 = 5)
fit.boltzmann(data.frame(x=1:10,y=c(0,0,1,3,5,7,9,10,10,10)), A0 = 10, k0 = 10, t20 = 5)
Add time interval in hour from the oldest timestamp
g5h.annotate(.data, by = "col")
g5h.annotate(.data, by = "col")
.data |
data.frame cleaned by g5h.clean() |
by |
'col' or 'row', default is 'col'. See ?g5h.gather_col for more info. |
data.frame
# suppose "gen5_export.txt" is the export from Gen5 2.06 g5h.clean2("gen5_export.txt") %>% g5h.annotate()
# suppose "gen5_export.txt" is the export from Gen5 2.06 g5h.clean2("gen5_export.txt") %>% g5h.annotate()
g5h.clean_() returns technically correct data.frame from Gen5 2.06 exported tab-delim data. The exported data can be generated using default export protocol in Gen5 2.06. See Gen5 User Guide for more information.
g5h.clean_(file)
g5h.clean_(file)
file |
the name of the file which the data are to be read from. If it does not contain an absolute path, the file name is relative to the current working directory, getwd(). |
technically correct data.frame.
g5h.clean2() returns technically correct data.frame from Gen5 2.06 exported tab-delim data. The exported data can be generated using default export protocol in Gen5 2.06. See Gen5 User Guide for more information.
g5h.clean2(files)
g5h.clean2(files)
files |
a vector of names of the file which the data are to be read from. If it does not contain an absolute path, the file name is relative to the current working directory, getwd(). |
technically correct data.frame.
# suppose "exported_data_1.txt" and "exported_data_2.txt" are the exports from Gen5 2.06 # this line will clean one exported data data <- g5h.clean2("exported_data_1.txt") # this line will clean two exported data and return one appended dataset data <- g5h.clean2(c("exported_data_1.txt", "exported_data_2.txt"))
# suppose "exported_data_1.txt" and "exported_data_2.txt" are the exports from Gen5 2.06 # this line will clean one exported data data <- g5h.clean2("exported_data_1.txt") # this line will clean two exported data and return one appended dataset data <- g5h.clean2(c("exported_data_1.txt", "exported_data_2.txt"))
g5h.set_time() preserves existing variables and add new variable, time, which are time intervals in hours.
g5h.set_time2(.data, units = "hours")
g5h.set_time2(.data, units = "hours")
.data |
data.frame cleaned by g5h.clean() |
units |
"hours" or "minutes" |
input data.frame appended with time
A collection of functions for processing Gen5 2.06 exported data. Gen 5 is a popular data analysis software for BioTek plate readers. This packages contains functions for data cleaning, modeling and plotting using exported data from Gen5 version 2.06. It exports technically correct data defined in (Edwin de Jonge and Mark van der Loo, 2013) for customized analysis. It contains Boltzmann fitting for general kinetic analysis. It also implement line plot and bar plot for generating publishable figures. See https://www.github.com/yanxianUCSB/gen5helper for more information, documentation and examples.
get half time according to http://www.amylofit.ch.cam.ac.uk The algorithm for the extraction of the half times proceeds as follows: first the middle part of the curve is selected, by determining when the average over several points is first above 0.3 and when the average is last below 0.7. The number of points to be averaged over depends on the number of points in the curve. A straight line is then fitted to this middle part of the curve, the point at which it crosses the value of 0.5 is recorded as the half time. (source: DOI: nprot.2016.010)
get.halftime(time, val)
get.halftime(time, val)
time |
vector of time |
val |
vector of values |
half time
get.halftime(c(1:10), c(0,1,2,3,4,5,6,7,8,9)) get.halftime(c(1:10), c(0,0,1,3,5,7,9,10,10,10))
get.halftime(c(1:10), c(0,1,2,3,4,5,6,7,8,9)) get.halftime(c(1:10), c(0,0,1,3,5,7,9,10,10,10))
Map the unique values of a vector
mapvalues_(x, facs, bNaturalSort = FALSE)
mapvalues_(x, facs, bNaturalSort = FALSE)
x |
factor or character |
facs |
character. It maps unique(x) to facs |
bNaturalSort |
binary. Whether to convert factor in natural order. |
factor
mapvalues_(c("A","A","B","C"), c("one", "two", "three")) mapvalues_(c("apple", "apple", "banana", "pineable", "pineable"), c(3, 2, 1), bNaturalSort = TRUE)
mapvalues_(c("A","A","B","C"), c("one", "two", "three")) mapvalues_(c("apple", "apple", "banana", "pineable", "pineable"), c(3, 2, 1), bNaturalSort = TRUE)
get the n most frequent elements in an array
most.freq(x, n = 1)
most.freq(x, n = 1)
x |
an array of elements |
n |
integer, default is 1 |
the most n elements
most.freq(c('a', 'a', 'b', 'b', 'b', 'c'), n = 2) most.freq(c(1, 1, 2, 3, 3, 3, 4, 4), n = 2)
most.freq(c('a', 'a', 'b', 'b', 'b', 'c'), n = 2) most.freq(c(1, 1, 2, 3, 3, 3, 4, 4), n = 2)
Scale a vector to 0-1 by min and max
normalize(x, na.rm = TRUE)
normalize(x, na.rm = TRUE)
x |
numeric |
na.rm |
bool whether to remove NA values. |
a normalized vector
normalize(0:10) normalize(c(1, 100, NA, 10), na.rm = TRUE)
normalize(0:10) normalize(c(1, 100, NA, 10), na.rm = TRUE)
This computes the range of a vector as a value.
range_(x, na.rm = TRUE)
range_(x, na.rm = TRUE)
x |
numeric |
na.rm |
bool whether to remove NA values. |
numeric value
range_(c(1, 5, 10)) range_(c(1, 5, 10, NA), na.rm = TRUE)
range_(c(1, 5, 10)) range_(c(1, 5, 10, NA), na.rm = TRUE)
This function returns the object passed in, can be used for dplyr pipeline.
saveRDS_(.data, file, ...)
saveRDS_(.data, file, ...)
.data |
object to be saved |
file |
filename to save |
... |
for saveRDS |
whatever object passed in.
data <- data.frame(a=1, b=2, c=3) data %>% saveRDS_(file.path(tempdir(), "data.rds")) %>% print()
data <- data.frame(a=1, b=2, c=3) data %>% saveRDS_(file.path(tempdir(), "data.rds")) %>% print()
Smooth a vector using moving average
smooth.mean(vec, naverage)
smooth.mean(vec, naverage)
vec |
numeric vector |
naverage |
width of moving average |
smoothed
smooth.mean(1:10, 2) smooth.mean(1:10, 3) smooth.mean(1:10, 5)
smooth.mean(1:10, 2) smooth.mean(1:10, 3) smooth.mean(1:10, 5)
Run ungroup() and as.data.frame()
ungroup_(.data)
ungroup_(.data)
.data |
grouped data.frame |
an ungrouped data.frame()
data <- data.frame(m=c(1,2), n=c(2,3), group=c('a','b')) data %>% group_by(group) %>% ungroup_()
data <- data.frame(m=c(1,2), n=c(2,3), group=c('a','b')) data %>% group_by(group) %>% ungroup_()
This function returns the object passed in, can be used for dplyr pipeline.
write.csv_(x, file)
write.csv_(x, file)
x |
object |
file |
filename for write.csv |
whatever object passed in
write.csv_(data.frame(a=1, b=2, c=3), file.path(tempdir(), "data.csv")) data <- data.frame(a=1, b=2, c=3) data %>% file.path(tempdir(), "data.csv") %>% print()
write.csv_(data.frame(a=1, b=2, c=3), file.path(tempdir(), "data.csv")) data <- data.frame(a=1, b=2, c=3) data %>% file.path(tempdir(), "data.csv") %>% print()