Title: | A 'broom'-like Interface to Lab Data |
---|---|
Description: | What the package does (one paragraph). |
Authors: | Kai Aragaki [aut, cre] |
Maintainer: | Kai Aragaki <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.0.9000 |
Built: | 2024-11-06 05:58:36 UTC |
Source: | https://github.com/KaiAragaki/mop |
Coerce object to nanodrop
as_nanodrop(x, ...) ## S3 method for class 'data.frame' as_nanodrop(x, nucleotide = NULL, is_tidy = FALSE, date = NULL, ...)
as_nanodrop(x, ...) ## S3 method for class 'data.frame' as_nanodrop(x, nucleotide = NULL, is_tidy = FALSE, date = NULL, ...)
x |
a |
... |
additional arguments passed to their respective functions |
nucleotide |
an optional character vector describing the measured nucleotide (DNA, RNA, dsDNA, dsRNA) |
is_tidy |
Logical. Is |
date |
Character coercible to a |
a nanodrop
object
Convert a scrubbed pcr object back to a pcr object
as_pcr(x)
as_pcr(x)
x |
A |
A pcr
object
Make a nanodrop object
incucyte(data, platemap)
incucyte(data, platemap)
data |
a |
date |
an optional character vector or something coercible to a |
nucleotide |
a character vector to specifying the analyte in the nanodrop experiment. Must match one of the following: RNA, DNA, dsDNA, or dsRNA. |
is_tidy |
logical. Is the supplied data tidy? |
Making a nanodrop object 'by hand' (that is, not using
read_nanodrop
) is not recommended, since it is challenging to ensure a
given data.frame
is truly a valid nanodrop file. To increase reliability,
flexibility is reduced. As such, the supplied data.frame
must at least
have the following columns if is_tidy = TRUE
:
date
sample_name
conc
a260_280
a230_280
If is_tidy = FALSE
, at least the following columns must be provided:
Date
Sample.Name
Nucleic.Acid.ng.uL.
A260.A280
A260.A230
Note: technically, the given column names will be stripped of all
non-alphanumerics and forced tolower
, then compared against the following:
date
samplename
nucleicacidngul
a260a280
a260a230
In both cases, other columns allowed are those that appear in Example A and Example B below.
If there are additional columns provided, they will be silently dropped.
an incucyte
object
Test if an object is a incucyte object
is_incucyte(incucyte)
is_incucyte(incucyte)
incucyte |
Object to be tested |
logical
Test if an object is a nanodrop object
is_nanodrop(nanodrop)
is_nanodrop(nanodrop)
nanodrop |
Object to be tested |
logical
Make a nanodrop object
nanodrop( data, date = NULL, nucleotide = c("RNA", "DNA", "dsDNA", "dsRNA"), is_tidy = FALSE )
nanodrop( data, date = NULL, nucleotide = c("RNA", "DNA", "dsDNA", "dsRNA"), is_tidy = FALSE )
data |
a |
date |
an optional character vector or something coercible to a |
nucleotide |
a character vector to specifying the analyte in the nanodrop experiment. Must match one of the following: RNA, DNA, dsDNA, or dsRNA. |
is_tidy |
logical. Is the supplied data tidy? |
Making a nanodrop object 'by hand' (that is, not using
read_nanodrop
) is not recommended, since it is challenging to ensure a
given data.frame
is truly a valid nanodrop file. To increase reliability,
flexibility is reduced. As such, the supplied data.frame
must at least
have the following columns if is_tidy = TRUE
:
date
sample_name
conc
a260_280
a230_280
If is_tidy = FALSE
, at least the following columns must be provided:
Date
Sample.Name
Nucleic.Acid.ng.uL.
A260.A280
A260.A230
Note: technically, the given column names will be stripped of all
non-alphanumerics and forced tolower
, then compared against the following:
date
samplename
nucleicacidngul
a260a280
a260a230
In both cases, other columns allowed are those that appear in Example A and Example B below.
If there are additional columns provided, they will be silently dropped.
a nanodrop
object
# Example A: colnames allowed when is_tidy = FALSE a <- system.file("extdata", "nanodrop.csv", package = "mop") |> read_nanodrop() colnames(a$data) # Technically, these are the names that are checked for after the given names # have alphanumerics removed and are converted to lowercase: colnames(a$data) |> stringr::str_remove_all("[^[:alnum:]]") |> tolower() # Example B: colnames allowed when is_tidy = TRUE b <- a |> tidy_lab() colnames(b$data)
# Example A: colnames allowed when is_tidy = FALSE a <- system.file("extdata", "nanodrop.csv", package = "mop") |> read_nanodrop() colnames(a$data) # Technically, these are the names that are checked for after the given names # have alphanumerics removed and are converted to lowercase: colnames(a$data) |> stringr::str_remove_all("[^[:alnum:]]") |> tolower() # Example B: colnames allowed when is_tidy = TRUE b <- a |> tidy_lab() colnames(b$data)
Constructor for a Incucyte object
new_incucyte( data = data.frame(), raw_data = data.frame(), date = lubridate::Date(), nucleotide = character(), is_tidy = logical() )
new_incucyte( data = data.frame(), raw_data = data.frame(), date = lubridate::Date(), nucleotide = character(), is_tidy = logical() )
data |
|
raw_data |
|
date |
|
is_tidy |
|
a nanodrop
object
As this is a low-level constructor, it will let you do some un-recommended things without error. You have been warned.
new_nanodrop( data = data.frame(), raw_data = data.frame(), date = lubridate::Date(), nucleotide = character(), is_tidy = logical() )
new_nanodrop( data = data.frame(), raw_data = data.frame(), date = lubridate::Date(), nucleotide = character(), is_tidy = logical() )
data |
|
raw_data |
|
date |
|
nucleotide |
|
is_tidy |
|
a nanodrop
object
Constructor for a pcr object
new_pcr( data = data.frame(), raw_data = raw(), header = character(), footer = character(), date = lubridate::Date(), experiment_type = character(), wells = integer(), is_tidy = logical() )
new_pcr( data = data.frame(), raw_data = raw(), header = character(), footer = character(), date = lubridate::Date(), experiment_type = character(), wells = integer(), is_tidy = logical() )
data |
|
raw_data |
|
header |
|
footer |
|
date |
|
experiment_type |
|
wells |
Number of wells in plate |
is_tidy |
|
A pcr
object
Constructor for a spectramax object
new_spectramax( data = data.frame(), raw_data = raw(), date = lubridate::Date(), wavelengths = numeric(), is_tidy = logical() )
new_spectramax( data = data.frame(), raw_data = raw(), date = lubridate::Date(), wavelengths = numeric(), is_tidy = logical() )
data |
a |
raw_data |
|
date |
|
is_tidy |
|
experiment_type |
|
a spectramax
object
Add leading 0 to sample names
pad_zero(sample_names)
pad_zero(sample_names)
sample_names |
a vector of sample names |
A sample name with up to one zero padded
c("blueberry", "Sample 1", "Sample 10", "sample 2", "john", "larry", "toxic waste", "Sample 02") |> pad_zero() # pad_zero will not pad if it doesn't need to: c("Sample 1", "Sample 2", "Sample 9") |> pad_zero() # pad_zero is case sensitive, since these will be coming off a machine in a standardized format c("sample 10", "sample 1") |> pad_zero() c("Sample 10", "Sample 1") |> pad_zero()
c("blueberry", "Sample 1", "Sample 10", "sample 2", "john", "larry", "toxic waste", "Sample 02") |> pad_zero() # pad_zero will not pad if it doesn't need to: c("Sample 1", "Sample 2", "Sample 9") |> pad_zero() # pad_zero is case sensitive, since these will be coming off a machine in a standardized format c("sample 10", "sample 1") |> pad_zero() c("Sample 10", "Sample 1") |> pad_zero()
Get or set an object's plate data
plate_data(x, ...) ## S3 method for class 'spectramax' plate_data(x, ...) plate_data(x) <- value ## S3 replacement method for class 'spectramax' plate_data(x) <- value
plate_data(x, ...) ## S3 method for class 'spectramax' plate_data(x, ...) plate_data(x) <- value ## S3 replacement method for class 'spectramax' plate_data(x) <- value
x |
Object to extract plate data from |
... |
Arguments to be passed to their respective methods |
value |
Value to set the plate to. |
A gp
object
Read an Incucyte File
read_incucyte(data, platemap)
read_incucyte(data, platemap)
data |
Plotting data output from the Incucyte analysis |
platemap |
.PlateMap file output from the platemap maker |
Read in a NanoDrop file
read_nanodrop(path, nucleotide = NULL, date = NULL, date_order = NULL)
read_nanodrop(path, nucleotide = NULL, date = NULL, date_order = NULL)
path |
path to a NanoDrop .csv |
nucleotide |
An optional character vector describing the analyte detected. If NULL (the default), it will automatically try to extract one from the file path. Valid values include RNA, DNA, dsDNA, and dsRNA (or NULL). |
date |
An optional character vector coercible to a date object. If NULL (the default), it will automatically try to extract one from the file path. See details for detection methods. |
date_order |
An optional character vector to enforce an order of date to
be read (if |
This function expects a file that has not been tampered with from the nanodrop machine itself, aside for the name.
This function calls read.delim
and guesses its encoding (usually
UTF-16LE
, unless it's been re-exported). It's less mysterious than reading
in an apparent .csv
with read.delim
, and it keeps you from having to
remember the encoding (which R often fails to auto-detect). When possible,
it attempts to extract the nucleotide type from the path provided.
if date
is NULL
, the function will attempt to extract a date from the
file name (not the whole file path). It will look for ymd, mdy, and dmy (in
order). If it detects the first format, it will not look for the second,
etc. Note how a reading taken from April 4th but written as 4_3_2021 will
be misinterpreted. This error can be remedied by specifying the argument
date_order
a nanodrop
object
system.file("extdata", "nanodrop.csv", package = "mop") |> read_nanodrop()
system.file("extdata", "nanodrop.csv", package = "mop") |> read_nanodrop()
Read in a QuantStudio pcr file
read_pcr(path)
read_pcr(path)
path |
path to a QuantStudio .xls |
a pcr
object
Read and tidy a SPECTRAmax file
read_spectramax(path, date = Sys.Date(), wavelengths = NULL)
read_spectramax(path, date = Sys.Date(), wavelengths = NULL)
path |
Path to the SPECTRAmax .txt file |
date |
Date of experiment. If not supplied, uses current date. |
wavelengths |
What wavelengths were read in this experiment? |
SPECTRAmax files cannot be read in easily without tidying them simultaneously, due to their non-rectangular structure. Therefore, tidying is required to be read in and is not an option supplied.
A list, with the following form:
a tibble
that contains two columns - the type
, and the (tidy) data
itself in a list-column.
a raw
representation of the file, before tidying
character. The date of the experiment
character. The type of experiment (currently only pq (Protein Quantification) and mtt supported)
logical. Should always return TRUE if read in using read_spectramax
Objects are a convenient way to represent lab data as it allows downstream
functions to interact with them in specific ways depending on their type.
Sometimes, however, it is more convenient to work with a flat tibble
.
scrub
converts a lab object into a tibble
scrub(x, ...)
scrub(x, ...)
x |
object to be converted into a |
... |
additional arguments to pass on to the respective object's class method |
a tibble
Convert a nanodrop object into a tibble
## S3 method for class 'nanodrop' scrub(x, raw = FALSE, ...)
## S3 method for class 'nanodrop' scrub(x, raw = FALSE, ...)
x |
a |
raw |
Should the data be pulled from |
... |
Unused |
a tibble
Convert a pcr object into a tibble
## S3 method for class 'pcr' scrub(x, include_header = FALSE, ...)
## S3 method for class 'pcr' scrub(x, include_header = FALSE, ...)
x |
a |
include_header |
Should the data from |
... |
Unused |
a tibble
Convert a spectramax object into a tibble
## S3 method for class 'spectramax' scrub(x, n = 1, ...)
## S3 method for class 'spectramax' scrub(x, n = 1, ...)
x |
a |
n |
List item number to select data from |
... |
Unused |
a tibble
Tidy an incucyte object
## S3 method for class 'incucyte_data' tidy_lab(x, force_tidy = FALSE, ...)
## S3 method for class 'incucyte_data' tidy_lab(x, force_tidy = FALSE, ...)
x |
An |
force_tidy |
|
... |
Unused |
This function:
an incucyte
object
Tidy a nanodrop object
## S3 method for class 'nanodrop' tidy_lab(x, force_tidy = FALSE, ...)
## S3 method for class 'nanodrop' tidy_lab(x, force_tidy = FALSE, ...)
x |
A |
force_tidy |
|
... |
Unused |
This function:
renames columns to sensible substitutes
converts date-times to ISO 8601-esque date-time format (YYYY-MM-DD HH:MM:SS vs YYYY-MM-DDTHH:MM:SSZ)
It's recommended that you do any manipulations to these data after you
tidy, rather than before, as tidy_nanodrop
expects the output to be
fairly similar to the output from read_nanodrop
.
A tidy nanodrop
object will (usually) contain the following columns:
date
The date-time of sample reading, as YYYY-MM-DD HH:MM:SS
sample_name
The name of the sample provided by the NanoDrop itself
conc
The concentration of nucleic acid in ng/uL
a260_280
The absorbance at 260nm / absorbance at 280nm. Typically a
marker of protein contamination. Pure nucleic acid is typically around 2.
a260_230
The absorbance at 260nm / absorbance at 230nm. Typically a
marker of guanadine salt contamination. Pure nucleic acid is typically
around 2.
a260
The absorbance at 260nm, the wavelength nucleic acids absorb most
strongly.
a280
The absorbance at 280nm, the wavelength proteins absorb most
strongly.
The remaining columns are typically unused.
a nanodrop
object
Tidy a PCR object
## S3 method for class 'pcr' tidy_lab(x, usr_standards = NULL, pad_zero = FALSE, ...)
## S3 method for class 'pcr' tidy_lab(x, usr_standards = NULL, pad_zero = FALSE, ...)
x |
a |
usr_standards |
Custom supplied standards |
pad_zero |
Should, say, Sample 1 become Sample 01? |
... |
Unused |
a pcr
object
Tidy a lab object
## S3 method for class 'spectramax' tidy_lab(x, ...) tidy_lab(x, ...)
## S3 method for class 'spectramax' tidy_lab(x, ...) tidy_lab(x, ...)
x |
An object to tidy |
... |
Arguments passed to their respective methods |