NMR Batch Correction Example Script: Difference between revisions
From Powers Wiki
(Added to Category) |
(LearningSorting) |
||
Line 21: | Line 21: | ||
Note: mean can be replaced with median in a median of median model. | Note: mean can be replaced with median in a median of median model. | ||
[[category: | [[category:Protocols]] | ||
[[category:Data_Processing_and_Analysis]] | [[category:Data_Processing_and_Analysis]] |
Revision as of 04:52, 11 September 2021
PLS Fit Model
X = whole dataset (first & second);clsD = class info (dummy matrix). result = pls(X, clsD, @suv, [7,1], 1); mn = result.mean.X;sd = result.scale.X; Xscaled = (X-(repmat(mn,[size(X,1),1])))./(repmat(sd,[size(X,1),1]));%size(Xscaled) XPLSfit = result.T*result.P'; XscaledNew = Xscaled - XPLSfit; XNew = (XscaledNew.*(repmat(sd,[size(XscaledNew,1),1]))) + (repmat(mn,[size(XscaledNew,1),1]));
Mean of Mean Model
Xall = [Xtrain;Xtest]; refX = median(median(Xall)); mnXtrain = mean(mean(Xtrain)); newXtrain = Xtrain/repmat(mnXtrain, [size(Xtrain, 1), size(Xtrain, 2)]); newXtrain = newXtrain*repmat(refX, [size(Xtrain, 1), size(Xtrain, 2)]); mnXtest = mean(mean(Xtest)); newXtest = Xtest/repmat(mnXtest, [size(Xtest, 1), size(Xtest, 2)]); newXtest = newXtest*repmat(refX, [size(Xtest, 1), size(Xtest, 2)]);
Note: mean can be replaced with median in a median of median model.