README.md

lightr: import spectral data in R

CRAN version Travis build status AppVeyor build status Coverage status Reviewed by rOpenSci JOSS paper

There is no standard file format for spectrometry data and different scientific instrumentation companies use wildly different formats to store spectral data. Vendor proprietary softwares sometimes have an option but convert those formats instead human readable files such as csv but in the process, most metadata are lost. However, those metadata are critical to ensure reproducibility (White et al, 2015).

This package aims at offering a unified user-friendly interface for users to read UV-VIS reflectance/transmittance/absorbance spectra files from various formats in a single line of code.

Additionally, it provides for the first time a fully free and open source solution to read proprietary spectra file formats on all systems.

🔧 Installation

install.packages("lightr")

You can also install the development version from GitHub:

# install.packages("remotes")
remotes::install_github("ropensci/lightr")

If you're using Windows and you want to use multiple cores for file import, you can install the development version from the future branch:

# install.package("remotes")
remotes::install_github("ropensci/[email protected]")

💻 Usage

A thorough documentation is available with the package, using R usual syntax ?function or help(function). However, users will probably mainly use two functions:

# Get a data.frame containing all useful metadata from spectra in a folder
lr_get_metadata(where = system.file("testdata/procspec_files", 
                                    package = "lightr"), 
                ext = "ProcSpec")

and

# Get a single dataframe where the first column contains the wavelengths and 
# the next columns contain a spectra each (pavo's rspec class)
lr_get_spec(where = system.file("testdata/procspec_files", package = "lightr"),
            ext = "ProcSpec")

lr_get_spec() returns a dataframe that is compatible with [pavo] custom S3 class (rspec) and can be used for further analyses using colour vision models.

All supported file formats can also be parsed using the lr_parse_$extension() function where $extension is the lowercase extension of your file. This family of functions return a list where the first element is the data dataframe and the second element is a vector with relevant metadata.

Only exceptions are .txt and .Transmission files because those extensions are too generic. Users will need to figure out which parser is appropriate in this case. lr_get_metadata() and lr_get_spec() automatically try generic parsers in this case.

Alternatively, you may simply want to convert your spectra in a readable standard format and carry on with your analysis with another software.

In this case, you can run:

# Convert every single ProcSpec file to a csv file with the same name and 
# location
lr_convert_tocsv(where = system.file("testdata/procspec_files", 
                                      package = "lightr"),
                 ext = "ProcSpec")

✔ Supported file formats

This package is still under development but currently supports:

OceanInsight (formerly OceantOptics)

| Extension | Parser | |:---------------|:----------------------| | jdx | lr_parse_jdx() | | ProcSpec | lr_parse_procspec() | | jaz | lr_parse_jaz() | | jazirrad | lr_parse_jazirrad() | | Transmission | lr_parse_jaz() | | txt | lr_parse_jaz() |

Avantes

| Extension | Parser | |:---------------|:----------------------| | ABS | lr_parse_abs() | | ROH | lr_parse_roh() | | TRM | lr_parse_trm() | | trt | lr_parse_trt() | | ttt | lr_parse_ttt() | | txt | lr_parse_generic() |

CRAIC

| Extension | Parser | |:----------|:---------------------| | txt | lr_parse_generic() |

Others

| Extension | Parser | |:----------|:------------------------------| | csv | lr_parse_generic(sep = ",") | | dpt | lr_parse_generic(sep = ",") |

Others

As a fallback, you should always try lr_parse_generic() which offers a flexible and general algorithm that manages to extract data from most files.

If you can't find the best parser for your specific file or if you believe you are using an unsupported format, please open an issue or send me an email.

🌐 Similar projects

To our knowledge, lightr is the only gratis tool to import some complex file formats such as Avantes binary files or OceanOptics .ProcSpec. Because of its user-friendly high-levels functions and low dependency philosophy, lightr may also hopefully prove useful for people working with other languages than R.

ropensci_footer



Bisaloo/lightr documentation built on Jan. 21, 2020, 4:10 p.m.