# NOT RUN {
# }
# NOT RUN {
## Process the raw data
data_dir <- system.file("extra", package = "Rnmr1D")
RAWDIR <- file.path(data_dir, "CD_BBI_16P02")
CMDFILE <- file.path(data_dir, "NP_macro_cmd.txt")
SAMPLEFILE <- file.path(data_dir, "Samples.txt")
out <- Rnmr1D::doProcessing(RAWDIR, cmdfile=CMDFILE, samplefile=SAMPLEFILE, ncpu=detectCores())
## Plot the spectra for the given ppm range
plotSpecMat(out$specMat, ppm_lim=c(0.5,9), K=0)
## Generate the output data matrix based on the computed buckets
## stored in out$specMat$bucket_zones.
outMat <- Rnmr1D::getBucketsDataset(out, norm_meth='CSN')
## Compute the bucket clustering based on a cut threshold applied on the buckets tree
## resulting of a hierarchical classification analysis. If \code{vcutusr} is equal to
## zero then cut threshold automatically estimated; otherwise the specified value
## is applied.
outclust <- Rnmr1D::getClusters(outMat, method='hca', vcutusr=0.15 )
## Plot the criterion curves and the cluster boxplot
dev.new()
plotCriterion(outclust)
dev.new()
plotClusters(outMat,outclust)
## ---- PCA ----
pca <- prcomp(outMat,retx=TRUE,scale=TRUE, rank=2)
# plot PCA Scores
dev.new()
plotScores(pca$x, 1, 2, out$samples, 'Treatment', level=0.95) # Choose 'Treatment' as factor
# plot PCA Loadings
dev.new()
plotLoadings(pca$rotation, 1, 2, associations=outclust$clustertab, cexlabel=0.6,
main=sprintf("Loadings - Crit=<!-- %s",outclust$vcrit) ) -->
# }
Run the code above in your browser using DataLab