Package LCF. November 22, 2017

Similar documents
Package datasets.load

Package ASICS. January 23, 2018

Package SEMrushR. November 3, 2018

Package strat. November 23, 2016

Package IATScore. January 10, 2018

Package ECctmc. May 1, 2018

Package validara. October 19, 2017

Package weco. May 4, 2018

Package cattonum. R topics documented: May 2, Type Package Version Title Encode Categorical Features

Package readobj. November 2, 2017

Package fastdummies. January 8, 2018

Package quadprogxt. February 4, 2018

Package geojsonsf. R topics documented: January 11, Type Package Title GeoJSON to Simple Feature Converter Version 1.3.

Package fitbitscraper

Package ggimage. R topics documented: November 1, Title Use Image in 'ggplot2' Version 0.0.7

Package gggenes. R topics documented: November 7, Title Draw Gene Arrow Maps in 'ggplot2' Version 0.3.2

Package gridgraphics

Package bigreadr. R topics documented: August 13, Version Date Title Read Large Text Files

Package canvasxpress

Package repec. August 31, 2018

Package ggimage. R topics documented: December 5, Title Use Image in 'ggplot2' Version 0.1.0

Package estprod. May 2, 2018

Package apastyle. March 29, 2017

Package QCAtools. January 3, 2017

Package dbx. July 5, 2018

Package gtrendsr. August 4, 2018

Package gtrendsr. October 19, 2017

Package docxtools. July 6, 2018

Package pwrab. R topics documented: June 6, Type Package Title Power Analysis for AB Testing Version 0.1.0

Package kirby21.base

Package sfc. August 29, 2016

Package spark. July 21, 2017

Package shinyfeedback

Package reval. May 26, 2015

Package ecoseries. R topics documented: September 27, 2017

Package bisect. April 16, 2018

Package deductive. June 2, 2017

Package robotstxt. November 12, 2017

Package ether. September 22, 2018

Package rxylib. December 20, 2017

Package MOST. November 9, 2017

Package autoshiny. June 25, 2018

Package comparedf. February 11, 2019

Package TVsMiss. April 5, 2018

Package jstree. October 24, 2017

Package manet. September 19, 2017

Package available. November 17, 2017

Package TestDataImputation

Package jpmesh. December 4, 2017

Package pairsd3. R topics documented: August 29, Title D3 Scatterplot Matrices Version 0.1.0

Package effectr. January 17, 2018

Package preprosim. July 26, 2016

Package oec. R topics documented: May 11, Type Package

Package vesselr. R topics documented: April 3, Type Package

Package HiResTEC. August 7, 2018

Package smapr. October 20, 2017

Package ConvergenceClubs

Package LVGP. November 14, 2018

Package dalmatian. January 29, 2018

Package DRaWR. February 5, 2016

Package humanize. R topics documented: April 4, Version Title Create Values for Human Consumption

Package meme. November 2, 2017

Package regexselect. R topics documented: September 22, Version Date Title Regular Expressions in 'shiny' Select Lists

Package d3plus. September 25, 2017

Package censusr. R topics documented: June 14, Type Package Title Collect Data from the Census API Version 0.0.

Package Combine. R topics documented: September 4, Type Package Title Game-Theoretic Probability Combination Version 1.

Package ArCo. November 5, 2017

Package mdftracks. February 6, 2017

Package shinyhelper. June 21, 2018

Package websearchr. R topics documented: October 23, 2018

Package fasttextr. May 12, 2017

Package slickr. March 6, 2018

Package tidyselect. October 11, 2018

Package messaging. May 27, 2018

Package PCADSC. April 19, 2017

Package birtr. October 4, 2017

Package clipr. June 23, 2018

Package rnaturalearth

Package CorrectOverloadedPeaks

Package sessioninfo. June 21, 2017

Package EvolutionaryGames

Package crossword.r. January 19, 2018

Package areaplot. October 18, 2017

Package readmzxmldata

Package NFP. November 21, 2016

Package BibPlots. January 23, 2018

Package goodpractice

Package coga. May 8, 2018

Package SSRA. August 22, 2016

Package testit. R topics documented: June 14, 2018

Package spelling. December 18, 2017

Package crossrun. October 8, 2018

Package rtext. January 23, 2019

Package utilsipea. November 13, 2017

Package IRkernel. January 7, 2019

Package hyphenatr. August 29, 2016

Package qualmap. R topics documented: September 12, Type Package

Package dkanr. July 12, 2018

Package editdata. October 7, 2017

Package sure. September 19, 2017

Transcription:

Title Linear Combination Fitting Version 1.7.0 Date 2017-11-22 Author Florian Werner [aut, cre] Package LCF November 22, 2017 Maintainer Florian Werner <florian.werner@wzw.tum.de> Baseline correction, normalization and linear combination fitting (LCF) of X-ray absorption near edge structure (XANES) spectra. The package includes data loading of.xmu files exported from 'ATHENA' (Ravel and Newville, 2005) <doi:10.1107/s0909049505012719>. Loaded spectra can be background corrected and all standards can be fitted at once. Two linear combination fitting functions can be used: (1) fit_athena(): Simply fitting combinations of standards as in ATHENA, (2) fit_float(): Fitting all standards with changing baseline correction and edgestep normalization parameters. Depends R (>= 3.2.1) License GPL-3 Imports quadprog Repository CRAN LazyData true RoxygenNote 6.0.1 NeedsCompilation no Date/Publication 2017-11-22 14:10:01 UTC R topics documented: bkg_corr........................................... 2 fit_athena.......................................... 2 fit_float........................................... 3 initial_load......................................... 4 LCF_solve_QP....................................... 5 LC_fit............................................ 6 1

2 fit_athena plot_lcf.......................................... 6 read_raw_spec....................................... 8 specdat........................................... 8 std_df............................................ 9 Index 10 bkg_corr Background correction function This function allows you to base-line correct and edge-step normalize XANES spectra (background correction). Raw spectra are loaded, then base-line corrected and edge-step normalized. The spectrum is flattened after E0. The function returns the corrected, normalized and flattened spectrum bkg_corr(raw.spec, corr.norm) raw.spec corr.norm Raw spectrum Vector of the base-line correction and edge-step normalization values (vector of length 4) corr.spec <- bkg_corr(raw.spec = corr.spec.samples[[1]], print(corr.spec) fit_athena Porting of ATHENA linear combination fitting The function can be used to check which combinations of standards produce a good fit and if output from ATHENA is similar. fit_athena(all.samples, all.standards, LC.vals, amostd, ex.smaller = NULL, file.output = NULL, best.fits = NULL)

fit_float 3 all.samples all.standards LC.vals amostd ex.smaller file.output List of all samples List of all standards The fitting range values for the linear combination fitting Use at most X standards Exclude portions smaller than a given value (decimal form), default to NULL Possibility to have a file output, default to NULL best.fits Possibility to output more than the best fit (e.g. the first 10 best fits), default to 1 athena.fit <- fit_athena(all.samples = corr.spec.samples, all.standards = corr.spec.standards, LC.vals = c(-14, 46), amostd = 4) ## exclude portions smaller 5% = 0.05 athena.fit.exlcude <- fit_athena(all.samples = corr.spec.samples, all.standards = corr.spec.standards, LC.vals = c(-14, 46), amostd = 4, ex.smaller = 0.05) fit_float Central fitting function with float environment This function allows to process all samples, especially written for the float environment. fit_float(all.samples, all.standards, LC.vals, float, ex.smaller = NULL, file.output = NULL, best.fits = NULL) all.samples all.standards LC.vals float ex.smaller file.output List of all samples List of all standards The fitting range values for the linear combination fitting Let vary the energy range paramerters Exclude portions smaller than a given value (decimal form), default to NULL Possibility to have a file output, default to NULL best.fits Possibility to output more than the best fit (e.g. the first 10 best fits), default to 1

4 initial_load ## Select parameters for baseline correction and edge-step normalization param.float <- expand.grid(pre.adj.1 = seq(-42,-30,6), pre.adj.2 = seq(-19,-9,5), post.adj.1 = seq(35,40,5), post.adj.2 = seq(50,65,5)) length(param.float[,1]) float.fit <- fit_float(all.samples = corr.spec.samples, all.standards = corr.spec.standards, LC.vals = c(-14, 46), float = param.float, best.fits = 20) print(float.fit) ###### Using next configuration can be very time consuming param.float.2 <- expand.grid(pre.adj.1 = seq(-43,-30,1), pre.adj.2 = seq(-19,-9,.5), post.adj.1 = seq(34,40,.5), post.adj.2 = seq(50,65,1)) initial_load Initial loading of spectra This function loads and initially normalizes the raw spectra. Output is a list with the raw and initially corrected spectra. initial_load(raw.spec = NULL, file = NULL, corr.norm, use.eshift = NULL) raw.spec file corr.norm use.eshift List of files already loaded with read_raw_spec() Vector with file names Initial correction and normalization parameters Set TRUE, if using energy shift value, defaults to NULL

LCF_solve_QP 5 LCF_solve_QP Linear combination fitting solve function Quadratic programming solution function for linear combination fitting (LCF) LCF_solve_QP(LCF.stds, LCF.samp) LCF.stds LCF.samp Standards for LCF Sample for LCF fit.standards <- std_df(sample = corr.spec.samples[[1]], all.standards = corr.spec.standards) corr.spec <- bkg_corr(raw.spec = corr.spec.samples[[1]], ## set fitting range parameters relative to E zero E.zero <- corr.spec.samples[[1]]$data$e0 LC.pre <- -14 LC.post <- 46 ## find ranges that have to be fitted abs.pre <- abs(corr.spec[["energy"]]-(e.zero+lc.pre)) abs.post <- abs(corr.spec[["energy"]]-(e.zero+lc.post)) range.pre <- which(abs.pre == min(abs.pre)) range.post <- which(abs.post == min(abs.post)) ## extract standards and sample in given range LC.sample <- corr.spec["cor.absorption"][range.pre:range.post,] LC.standards <- fit.standards[range.pre:range.post,] ## actual fitting fit.result <- LCF_solve_QP(LCF.stds = LC.standards, LCF.samp = LC.sample) print(fit.result)

6 plot_lcf LC_fit Linear combination fitting function This function performs the LC fitting of the input sample/samples. It outputs the fitting results with the R-Factors as fitting statistics. LC_fit(sample, standards, LC.vals, float = NULL, E.zero = NULL, ex.smaller = NULL) sample standards LC.vals float E.zero ex.smaller The sample spectrum The standards spectra Values for ranges of linear combination fitting, with respect to the edge-step Set float parameters, defaults to NULL Set E0, defaults to NULL Set value to exclude small portions (as portion of 1), defaults to NULL fit.standards <- std_df(sample = corr.spec.samples[[1]], all.standards = corr.spec.standards) fit.result <- LC_fit(sample = corr.spec.samples[[1]], standards = fit.standards, LC.vals = c(-14, 46)) print(fit.result) plot_lcf Plot sample data, linear combination fit and residual spectrum This function allows plotting (png or tiff image files) of the corrected sample spectrum, the linear combination fit and the residual.

plot_lcf 7 plot_lcf(all.samples, all.standards, LCF.res, LC.vals, corr.norm, float = NULL, exclude = NULL, use.tiff = NULL, E.zero = NULL, set.plot.ymax = NULL, file.output = NULL) all.samples all.standards LCF.res LC.vals corr.norm float exclude use.tiff E.zero set.plot.ymax file.output List of all samples List of all standards Results from function fit_float() The fitting range values for the linear combination fitting Vector of the base-line correction and edge-step normalization values (vector of length 4) Logical, default to FALSE Logical, default to FALSE Logical, default to FALSE Set E0, defaults to NULL Set maximum of plot y axis, defaults to NULL Logical, default to FALSE param.float <- expand.grid(pre.adj.1 = seq(-45,-30,5), pre.adj.2 = seq(-19,-9,5), post.adj.1 = seq(34,40,2), post.adj.2 = seq(50,65,5)) float.fit <- fit_float(all.samples = corr.spec.samples[1], all.standards = corr.spec.standards, LC.vals = c(-14, 46), float = param.float, ex.smaller = 0.05) par(pty="s") plot_lcf(all.samples = corr.spec.samples[1], all.standards = corr.spec.standards, LCF.res = float.fit[1,], LC.vals = c(-14,46),

8 specdat read_raw_spec Read raw spectra This function reads the raw.xmu file, extracts E0 and energy shift and returns a list with name, E0, energy shift, and the raw spectrum read_raw_spec(file, use.eshift = NULL) file use.eshift The raw.xmu file Set TRUE, if using energy shift value, defaults to NULL ## any.xmu file as output from ATHENA (>=0.9.25) specdat Phosphorus K-edge XANES spectral data for LCF Format Data from an experiment on the quality of XANES spectrscopy for phosphorus speciation List of four standard spectra comounds and four spectra of mixtures of these standard compounds, output objects of function read_raw_spec(). References Werner & Prietzel 2015, Environ. Sci. Technol. (49), 10521-10528 (DOI) specdat[[1]] specdat[[5]]

std_df 9 std_df Create a data frame of all standards The function creates a data frame with all standards in one data frame. The data frame has the same energy values as the sample that is loaded. std_df(sample, all.standards) sample all.standards A raw sample List of all standards fit.standards <- std_df(sample = corr.spec.samples[[1]], all.standards = corr.spec.standards) print(fit.standards)

Index Topic LCF plot_lcf, 6 Topic approximation, std_df, 9 Topic correction, bkg_corr, 2 std_df, 9 Topic correction fit_athena, 2 initial_load, 4 LC_fit, 6 LCF_solve_QP, 5 read_raw_spec, 8 Topic datasets specdat, 8 Topic flattening bkg_corr, 2 Topic float fit_float, 3 Topic normalization, bkg_corr, 2 initial_load, 4 LC_fit, 6 LCF_solve_QP, 5 read_raw_spec, 8 Topic normalization fit_athena, 2 Topic parameters fit_float, 3 Topic plot, plot_lcf, 6 Topic standards std_df, 9 LC_fit, 6 LCF_solve_QP, 5 plot_lcf, 6 read_raw_spec, 8 specdat, 8 std_df, 9 bkg_corr, 2 fit_athena, 2 fit_float, 3 initial_load, 4 10