Real life example
This vignette has two goals:
- demonstrate that
lightrparsers produce the same output as the official software
- show an example of analysis you can run once you’ve imported your data with
For this, we use spectral data of the beak of the atlantic puffin, Fratercula arctica. This data was collected by Dr Claire Doutrelant, using an OceanOptics spectrometer.
By default, OceanInsight spectrometers produce
.ProcSpec files, which R cannot readily import. To help with this, OceanInsight official software, SpectraSuite has a conversion feature, which turns
.ProcSpec files into tab separated values files (
So, let’s start by comparing the
.ProcSpec spectra imported by
lightr and the
.txt files produced by OceanOptics.
raw_files <- lr_get_spec(file.path("data", "puffin"), ext = "ProcSpec") #> 2 files found; importing spectra: txt_files <- lr_get_spec(file.path("data", "puffin"), ext = "txt") #> 2 files found; importing spectra:
We can visually inspect these two file using the dedicated S3 function
Spectra imported by
lightr and converted by SpectraSuite look pretty similar upon visual inspection and we can confirm this with
all.equal(raw_files, txt_files, tol = 1e-4) #>  TRUE
One possibly biologically relevant question would be to look at the interspecific variability in beak colour. I.e., do all puffin individuals have roughly the same colour or are some individuals brighter, more colourful than others?
Okay, these two individuals seem to differ quite a lot in terms of hue and brightness. Now, one might ask if these difference can be perceived in bird vision. We can test this with the
vis_beak <- vismodel(beak, visual = "avg.uv", achromatic = "ch.dc") tcs_beak <- colspace(vis_beak) coldist(tcs_beak, achromatic = TRUE) #> Quantum catch are relative, distances may not be meaningful #> Calculating unweighted Euclidean distances and Weber luminance contrast #> patch1 patch2 dS dL #> 1 BR_PF26_1 BR_PF27_3 0.005867583 0.2004935
The values of
dL are below the 1 JND (just noticeable differences) threshold, which means that the colour of the two individuals, in spite of their difference, looks the same to the birds.