Browse Source

Update NAMESPACE and manuals by `devtools::document()`

pull/3/head
Philipp Baumann 7 years ago
parent
commit
9ddfb029e2
  1. 2
      DESCRIPTION
  2. 1
      NAMESPACE
  3. 4
      R/pls-modeling.R
  4. 42
      R/read-opus-universal.R
  5. 1
      man/average_spc.Rd
  6. 1
      man/average_spectra.Rd
  7. 1
      man/do_pretreatment.Rd
  8. 1
      man/evaluate_pls_q.Rd
  9. 1
      man/fit_pls.Rd
  10. 1
      man/fit_pls_q.Rd
  11. 1
      man/fit_rf_q.Rd
  12. 1
      man/gather_spc.Rd
  13. 1
      man/join_chem_spec.Rd
  14. 1
      man/join_spc_chem.Rd
  15. 1
      man/ken_stone_q.Rd
  16. 1
      man/plot_spc.Rd
  17. 1
      man/pls_ken_stone.Rd
  18. 1
      man/predict_from_spc.Rd
  19. 1
      man/predict_from_spectra.Rd
  20. 4
      man/preprocess_spc.Rd
  21. 1
      man/read_opus.Rd
  22. 1
      man/read_opus_bin.Rd
  23. 15
      man/read_opus_bin_univ.Rd
  24. 1
      man/read_opus_text.Rd
  25. 29
      man/read_opus_univ.Rd
  26. 1
      man/read_spectra.Rd
  27. 1
      man/remove_outliers.Rd
  28. 1
      man/resample_spc.Rd
  29. 1
      man/resample_spectra.Rd
  30. 5
      man/rf_ken_stone.Rd
  31. 1
      man/select_ref_samples.Rd
  32. 1
      man/select_ref_spc.Rd
  33. 1
      man/summary_df.Rd
  34. 1
      man/tune_model.Rd
  35. 1
      man/tune_model_loocv_q.Rd
  36. 1
      man/tune_model_none_q.Rd
  37. 1
      man/tune_model_q.Rd
  38. 1
      man/tune_model_rcv_q.Rd

2
DESCRIPTION

@ -26,4 +26,4 @@ Description: Functions that cover
using caret, and model diagnostic statistics and plots.
License: GPL-2
LazyData: TRUE
RoxygenNote: 5.0.1
RoxygenNote: 6.0.1

1
NAMESPACE

@ -18,6 +18,7 @@ export(predict_from_spectra)
export(preprocess_spc)
export(read_opus)
export(read_opus_bin)
export(read_opus_bin_univ)
export(read_opus_text)
export(read_spectra)
export(remove_outliers)

4
R/pls-modeling.R

@ -321,8 +321,8 @@ fit_pls_q <- function(x, validation = TRUE,
variable, tr_control, env = parent.frame(),
pls_ncomp_max = 20, ncomp_fixed = 5,
center, scale, tuning_method = "resampling") {
# Fit a partial least square regression (pls) model
# center and scale MIR (you can try without)
# Fit a partial least square regression (pls) model
# center and scale MIR (you can try without)
calibration <- MIR <- NULL
v <- eval(variable, x$calibration, env)
# ? Is it really necessary to evaluate this in the parent frame?

42
R/read-opus-universal.R

@ -3,7 +3,7 @@
#' Read single binary file acquired with an
#' Bruker Vertex FTIR Instrument
#' @param file_path Character vector with path to file
#' @usage read_opus_univ(file_path)
#' @usage read_opus_bin_univ(file_path)
#' @export
read_opus_bin_univ <- function(file_path, extract = c("spc"),
print_progress = TRUE) {
@ -534,3 +534,43 @@ read_opus_bin_univ <- function(file_path, extract = c("spc"),
}) # closes try() function
}
#' @title Read a list of Bruker OPUS spectrum binary files (wrapper for
#' \code{read_opus_bin_univ()})
#' @description
#' Read single binary file acquired with an
#' Bruker Vertex FTIR Instrument
#' @param fnames List of character vectors containing full path names of spectra
#' @param extract Character vector of spectra types to extract from file.
#' Possible values are: "spc" (AB block in Bruker Opus software), "spc_nocomp"
#' (Spectra before final atmospheric compensation; only present if background
#' correction has been set in Opus), "ScSm" (Single channel spectrum of the
#' sample), "ScRf" (Single channel spectrum of the sample), "IgSm" (Interferogram
#' of the sample), "IgRf" (Interferogram of the reference). Default is
#' \code{extract = c("spc")}.
#' @param parallel Logical (\code{TRUE} or \code{FALSE} indicating whether
#' files are read in parallel (multiple processors or multiple cores)).
#' Default is \code{parallel = FALSE}. If \code{TRUE} a parallel backend needs
#' to be registered, e.g. by using the \code{doParallel} package.
#' @usage read_opus_univ(fnames, extract = c("spc"), parallel = FALSE)
#' @export out List spectra and metadata (parameters) extracted from
#' Bruker OPUS spectrometer files. List names are the names of the OPUS
#' files whose spectral data were extracted.
read_opus_univ <- function(fnames, extract = c("spc"), parallel = FALSE) {
if(parallel == TRUE) {
foreach::foreach(i = 1:length(fnames), .export = "read_opus_bin",
# export the foreach package to the individual workers
.packages = c("foreach"),
.final = function(i) setNames(i, sub(".+/(.+)", "\\1", fnames))) %dopar% {
try(
read_opus_bin(file_path = fnames[[i]], extract = extract)
)
}
} else if (parallel == FALSE) {
spc_list <- lapply(fnames,
function(x) try(read_opus_bin(file_path = x, extract = extract)))
names(spc_list) <- sub(".+/(.+)", "\\1", fnames)
spc_list
}
}

1
man/average_spc.Rd

@ -10,4 +10,3 @@ average_spc(spc_tbl)
Averages spectra in tibble column by sample_id after
resampling spectra by \code{simplerspec::resample_spc()}.
}

1
man/average_spectra.Rd

@ -38,4 +38,3 @@ abbreviation.}
Calculate the mean of each spectral repetitions
(absorbance average per wavenumber)
}

1
man/do_pretreatment.Rd

@ -28,4 +28,3 @@ spectra in element \code{MIR_pre}
Use commonly used preprocessing algorithms on
the spectra.
}

1
man/evaluate_pls_q.Rd

@ -35,4 +35,3 @@ Calculate model performance indices based
on observed and predicted values of validation and calibration
set, and internal cross-validation
}

1
man/fit_pls.Rd

@ -21,4 +21,3 @@ validation is performed}
Uses the caret package to perform PLS modeling.
Spectra are centered and scaled prior to modeling.
}

1
man/fit_pls_q.Rd

@ -27,4 +27,3 @@ of the desired internal validation framework}
Uses the caret package to perform PLS modeling.
Spectra are centered and scaled prior to modeling.
}

1
man/fit_rf_q.Rd

@ -27,4 +27,3 @@ Uses the caret package to perform random forest
modeling.
Spectra are centered and scaled prior to modeling.
}

1
man/gather_spc.Rd

@ -13,4 +13,3 @@ after reading binary OPUS files with \code{simplerspec::read_opus()}}
\value{
Spectral data and metadata in object of class tible
}

1
man/join_chem_spec.Rd

@ -21,4 +21,3 @@ List: xxx
Combines spectral data (data.frame) and chemical
data (data.frame).
}

1
man/join_spc_chem.Rd

@ -21,4 +21,3 @@ Tibble joined by sample_id
Combines spectral data (tibble class) and chemical
data (tibble class).
}

1
man/ken_stone_q.Rd

@ -25,4 +25,3 @@ calibration sampling is performed
Perform calibration sampling based on
the Kennard-Stones algorithm.
}

1
man/plot_spc.Rd

@ -12,4 +12,3 @@ graph_id_2 = "Validation", slice = TRUE, alpha = 1)
\description{
Plot spectra from tibble spectra objects.
}

1
man/pls_ken_stone.Rd

@ -33,4 +33,3 @@ validation is performed}
Perform calibration sampling and use selected
calibration set for model tuning
}

1
man/predict_from_spc.Rd

@ -19,4 +19,3 @@ predict_from_spc(spc_tbl, model_list, slice = TRUE)
tibble with new columns \code{model}, and predicted values with
column names of model list.
}

1
man/predict_from_spectra.Rd

@ -19,4 +19,3 @@ Function that uses pre-processed spectra, additional metadata of new
samples, and caret model output for the different soil property models
to create predicted values.
}

4
man/preprocess_spc.Rd

@ -4,10 +4,10 @@
\alias{preprocess_spc}
\title{Preprocess spectra from spectral data object (tibble)}
\usage{
preprocess_spc(spc_tbl, select, column_in = "spc_mean")
preprocess_spc(spc_tbl, select, column_in = "spc_mean",
custom_function = NULL)
}
\description{
Preprocesses spectra in tibble column by sample_id after
averaging spectra by \code{simplerspec::average_spc()}.
}

1
man/read_opus.Rd

@ -50,4 +50,3 @@ see \code{read.opus}.
\author{
Antoine Stevens and Andrew Sila (soil.spec package)
}

1
man/read_opus_bin.Rd

@ -13,4 +13,3 @@ read_opus_bin(file.name)
Read single binary file acquired with an
Bruker Vertex FTIR Instrument
}

15
man/read_opus_bin_univ.Rd

@ -0,0 +1,15 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/read-opus-universal.R
\name{read_opus_bin_univ}
\alias{read_opus_bin_univ}
\title{Read a Bruker OPUS spectrum binary file}
\usage{
read_opus_bin_univ(file_path)
}
\arguments{
\item{file_path}{Character vector with path to file}
}
\description{
Read single binary file acquired with an
Bruker Vertex FTIR Instrument
}

1
man/read_opus_text.Rd

@ -14,4 +14,3 @@ Read single text file acquired with
an Bruker Vertex FTIR Instrument
(as exported from OPUS software)
}

29
man/read_opus_univ.Rd

@ -0,0 +1,29 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/read-opus-universal.R
\name{read_opus_univ}
\alias{read_opus_univ}
\title{Read a list of Bruker OPUS spectrum binary files (wrapper for
\code{read_opus_bin_univ()})}
\usage{
read_opus_univ(fnames, extract = c("spc"), parallel = FALSE)
}
\arguments{
\item{fnames}{List of character vectors containing full path names of spectra}
\item{extract}{Character vector of spectra types to extract from file.
Possible values are: "spc" (AB block in Bruker Opus software), "spc_nocomp"
(Spectra before final atmospheric compensation; only present if background
correction has been set in Opus), "ScSm" (Single channel spectrum of the
sample), "ScRf" (Single channel spectrum of the sample), "IgSm" (Interferogram
of the sample), "IgRf" (Interferogram of the reference). Default is
\code{extract = c("spc")}.}
\item{parallel}{Logical (\code{TRUE} or \code{FALSE} indicating whether
files are read in parallel (multiple processors or multiple cores)).
Default is \code{parallel = FALSE}. If \code{TRUE} a parallel backend needs
to be registered, e.g. by using the \code{doParallel} package.}
}
\description{
Read single binary file acquired with an
Bruker Vertex FTIR Instrument
}

1
man/read_spectra.Rd

@ -45,4 +45,3 @@ The function should also work for other OPUS files (eg alpha),
see \code{read.opus}. The function readOPUS() was
written by Antoine Stevens.
}

1
man/remove_outliers.Rd

@ -43,4 +43,3 @@ Remove outlier spectra based on the
This is an optional function if one wants to remove
outliers.
}

1
man/resample_spc.Rd

@ -10,4 +10,3 @@ resample_spc(spc_tbl, wn_lower = 510, wn_upper = 3988, wn_interval = 2)
Resamples spectra stored in tibble column after
gathering spectra by \code{simplerspec::gather_spc()}.
}

1
man/resample_spectra.Rd

@ -14,4 +14,3 @@ resample_spectra(list_spectra, wn_lower = 510, wn_upper = 3988,
\item{wn_upper}{Numerical value for highest wavenumber in sampling interval}
}

5
man/rf_ken_stone.Rd

@ -5,8 +5,8 @@
\title{Calibration sampling, model tuning, and random forest modeling}
\usage{
rf_ken_stone(spec_chem, split_method = "ken_stone", ratio_val, pc = 2,
print = TRUE, validation = TRUE, variable, ntree_max = 500,
env = parent.frame())
print = TRUE, validation = TRUE, variable, tuning_method = "resampling",
ntree_max = 500, env = parent.frame())
}
\arguments{
\item{spec_chem}{data.frame that contains IR spectroscopy
@ -32,4 +32,3 @@ validation is performed}
Perform calibration sampling and use selected
calibration set for model tuning
}

1
man/select_ref_samples.Rd

@ -28,4 +28,3 @@ calibration sampling is performed
Select a set of calibration spectra to develop spectral models.
Samples in this list will be analyzed using laboratory reference methods.
}

1
man/select_ref_spc.Rd

@ -27,4 +27,3 @@ calibration sampling is performed
Select a set of calibration spectra to develop spectral models.
Samples in this list will be analyzed using laboratory reference methods.
}

1
man/summary_df.Rd

@ -17,4 +17,3 @@ summary_df(df, x, y)
Calculates model statistics for predicted (y)
vs. observed (y) values
}

1
man/tune_model.Rd

@ -21,4 +21,3 @@ validation is performed.}
Uses function from caret to to model tuning
for PLS regression.
}

1
man/tune_model_loocv_q.Rd

@ -21,4 +21,3 @@ validation is performed.}
Uses function from caret to to model tuning
for PLS regression.
}

1
man/tune_model_none_q.Rd

@ -21,4 +21,3 @@ validation is performed.}
Uses function from caret to set model tuning to none
for PLS regression.
}

1
man/tune_model_q.Rd

@ -21,4 +21,3 @@ validation is performed.}
Uses function from caret to to model tuning
for PLS regression.
}

1
man/tune_model_rcv_q.Rd

@ -21,4 +21,3 @@ validation is performed.}
Uses function from caret to to model tuning
for PLS regression.
}

Loading…
Cancel
Save