library(mdatools)
# resolve mixture of carbonhydrates Raman spectra
data(carbs)
m = mcrpure(carbs$D, ncomp = 3)
# examples for purity spectra plot (you can select which components to show)
par(mfrow = c(2, 1))
plotPuritySpectra(m)
plotPuritySpectra(m, comp = 2:3)
# you can do it manually and combine e.g. with original spectra
par(mfrow = c(1, 1))
mdaplotg(
list(
"spectra" = prep.norm(carbs$D, "area"),
"purity" = prep.norm(mda.subset(mda.t(m$resspec), 1), "area")
), col = c("gray", "red"), type = "l"
)
# show the maximum purity for each component
par(mfrow = c(1, 1))
plotPurity(m)
# plot cumulative and individual explained variance
par(mfrow = c(1, 2))
plotVariance(m)
plotCumVariance(m)
# plot resolved spectra (all of them or individually)
par(mfrow = c(2, 1))
plotSpectra(m)
plotSpectra(m, comp = 2:3)
# plot resolved contributions (all of them or individually)
par(mfrow = c(2, 1))
plotContributions(m)
plotContributions(m, comp = 2:3)
# of course you can do this manually as well, e.g. show original
# and resolved spectra
par(mfrow = c(1, 1))
mdaplotg(
list(
"original" = prep.norm(carbs$D, "area"),
"resolved" = prep.norm(mda.subset(mda.t(m$resspec), 1), "area")
), col = c("gray", "red"), type = "l"
)
# in case if you have reference spectra of components you can compare them with
# the resolved ones:
par(mfrow = c(3, 1))
for (i in 1:3) {
mdaplotg(
list(
"pure" = prep.norm(mda.subset(mda.t(carbs$S), 1), "area"),
"resolved" = prep.norm(mda.subset(mda.t(m$resspec), 1), "area")
), col = c("gray", "red"), type = "l", lwd = c(3, 1)
)
}
# See bookdown tutorial for more details.
Run the code above in your browser using DataLab