Skip to contents

Make a nanodrop object

Usage

nanodrop(
  data,
  date = NULL,
  nucleotide = c("RNA", "DNA", "dsDNA", "dsRNA"),
  is_tidy = FALSE
)

Arguments

data

a data.frame - or something coercible to one - containing nanodrop data. See details for requirements.

date

an optional character vector or something coercible to a Date object with lubridate::as_date

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?

Value

a nanodrop object

Details

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.

Examples


# Example A: colnames allowed when is_tidy = FALSE
a <- system.file("extdata", "nanodrop.csv", package = "mop") |>
read_nanodrop()

colnames(a$data)
#>  [1] "Date"                     "Sample.Name"             
#>  [3] "Nucleic.Acid.ng.uL."      "A260.A280"               
#>  [5] "A260.A230"                "A260"                    
#>  [7] "A280"                     "Nucleic.Acid.Factor"     
#>  [9] "Baseline.Correction..nm." "Baseline.Absorbance"     
#> [11] "Corrected..ng.uL."        "Corrected..CV"           
#> [13] "Impurity.1"               "Impurity.1.A260"         
#> [15] "Impurity.1..CV"           "Impurity.1.mM"           
#> [17] "Impurity.2"               "Impurity.2.A260"         
#> [19] "Impurity.2..CV"           "Impurity.2.mM"           
#> [21] "Impurity.3"               "Impurity.3.A260"         
#> [23] "Impurity.3..CV"           "Impurity.3.mM"           

# 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()
#>  [1] "date"                 "samplename"           "nucleicacidngul"     
#>  [4] "a260a280"             "a260a230"             "a260"                
#>  [7] "a280"                 "nucleicacidfactor"    "baselinecorrectionnm"
#> [10] "baselineabsorbance"   "correctedngul"        "correctedcv"         
#> [13] "impurity1"            "impurity1a260"        "impurity1cv"         
#> [16] "impurity1mm"          "impurity2"            "impurity2a260"       
#> [19] "impurity2cv"          "impurity2mm"          "impurity3"           
#> [22] "impurity3a260"        "impurity3cv"          "impurity3mm"         


# Example B: colnames allowed when is_tidy = TRUE
b <- a |> tidy_lab()

colnames(b$data)
#>  [1] "date"                   "sample_name"            "conc"                  
#>  [4] "a260_280"               "a260_230"               "a260"                  
#>  [7] "a280"                   "nucleic_acid_factor"    "baseline_correction_nm"
#> [10] "baseline_absorbance"    "corrected_ngul"         "corrected_cv"          
#> [13] "impurity_1"             "impurity_1_a260"        "impurity_1_cv"         
#> [16] "impurity_1_m_m"         "impurity_2"             "impurity_2_a260"       
#> [19] "impurity_2_cv"          "impurity_2_m_m"         "impurity_3"            
#> [22] "impurity_3_a260"        "impurity_3_cv"          "impurity_3_m_m"