1D NMR Processing in Linux and Windows Example Script
From Powers Wiki
Load MVAPACK
addpath('/opt/mvapack/');
Load Data
F.dirs = glob('???'); [F.data, F.parms, F.t] = loadnmr(F.dirs);
Add Classes and Labels
cls.Y = classes([7,8,6,8,8,8,7,8,7,8,8,8,8,8,8]); cls.labels = {'1','2','3','4','5','6','7','8','9','10','11','12','13','14','15'};
Zerofills
F.data = zerofill(F.data, F.parms, 2); #number of zerofills can be adjusted
Build the Spectra/FT
[S.data, S.ppm] = nmrft(F.data, F.parms);
Note: Check out the Quality (spit out a couple plots)
#plot(S.ppm,S.data(1,:)) - Change 1 to a different number to inspect that spectrum.
Autophase the Spectra
- Note, some users run this ~2-3 times for convergence
[S.data, S.phc0, S.phc1] = autophase(S.data, F.parms); [S.data, S.phc0, S.phc1] = autophase(S.data, F.parms); [S.data, S.phc0, S.phc1] = autophase(S.data, F.parms);
Extract the Real Spectral Components
XF.data = realnmr(S.data, F.parms); XF.ppm = S.ppm;
Check Plot to Find Reference Standard
plot(XF.ppm, XF.data)
Reference Adjustment
XF.ppm = refadj(XF.ppm, -0.160, 0.0);
Icoshift
XF.data = icoshift(XF.data, XF.ppm);
Remove Undesired Regions
r0= findnearest(XF.ppm, min(XF.ppm)); r1=findnearest(XF.ppm, 0.4); r2=findnearest(XF.ppm, 0.97); r3=findnearest(XF.ppm, 1.33); r4=findnearest(XF.ppm, 4.5); r5=findnearest(XF.ppm, 5.2); r6=findnearest(XF.ppm, 8.5); r7=findnearest(XF.ppm, max(XF.ppm)); X.rm.var = [r7:r6,r5:r4,r3:r2,r1:r0]; [XF.data, XF.ppm] = rmvar(XF.data, XF.ppm, X.rm.var);
Normalize Data
X1.data= pqnorm(XF.data); X1.ppm=XF.ppm
Binning
[B.data, B.ppm, B.widths]=binadapt(XF.data,XF.ppm,F.parms);
Build Models
Principle Component Analysis
mdlpca= pca(X1.data); mdlpca = addclasses(mdlpca, cls.Z); scoresplot(mdlpca, 2, [], true); print -deps -color 'FB-2-mdlPCA.eps' print -dpdf -color 'Fb-2-mdlPCA.pdf' RQ Plot rqplot(mdlpca) print -deps -color 'FB-2-rqmdlPCA.eps' print -dpdf -color 'Fb-2-rqmdlPCA.pdf' Save Scores savescores (mdlpca,FB-2-scoresPCA,3,cls.Y,cls.labels)
Orthogonal Projection to Latent Squares (OPLS)
Note: no seperation with binned data
mdlopls = opls(X1.data, cls.Y); mdlopls = addlabels(mdlopls, cls.labels); print -deps -color 'FB-2-mdlOPLS.eps' print -dpdf -color 'Fb-2-mdlOPLS.pdf' Validation Stages for OPLS Models RQ Plot rqplot(mdlopls); Permutation Test mdl.cv.perm = permtest(mdlopls); permscatter(mdl.cv.perm) CV Anova mdl.cv.anova = cvanova(mdlopls); mdl.cv.anova