In [1]:
%load http://pmb-bordeaux.fr/scripts/PyODAM.py
In [2]:
%load http://pmb-bordeaux.fr/scripts/PyODAM_pca.py
In [3]:
## API Call to retrieve data
dataset = 'frim1'
subset = 'qNMR_metabo'
d = getSubsetFromODAM(dataset, subset)
## Retrieve factors
d['factor']['Attribute']
Out[3]:
In [4]:
# Matrix X
X = d['data'][d['numvars']]
# Choose 'DevStage' as Factor (index=1)
facname = d['factor'].Attribute[1]
Y = d['data'][facname]
# Factor levels
factorlevels = []
for f in Y:
if f not in factorlevels:
factorlevels.append(f)
factorlevels
Out[4]:
In [5]:
# Compute PCA
res_pca = PCA_compute(X, Y, n=3, scale=True)
# Factor level selection
FacLevSel = ['FF.01', 'FF.02', 'FF.04', 'FR.02', 'FR.04']
# Plot PCA Scores
plotPCA(res_pca, 1, 3, FacLevSel)
In [6]:
# Explained Variance (%)
res_pca['EV']
Out[6]: