1

I have two data matrices (predictor matrix and response matrix) on which I am running PLS. My question is 'How does their relationship differ between clean and polluted sites?'

I can observe this on plot, but would like ellipses around each group - clean and polluted. PLS clean and polluted

my code is:

data[complete.cases(data),]-> trans
my_pls2=plsreg2(trans[,-c(1:11)], trans[,-c(1:4,12:35)], comps=3, crosval = TRUE)
blok<-as.numeric(trans[,3]) ####column 3 is STATUS (CLEAN and POLLUTED)
col.status<-c("blue", "red")
palette(col.status)
plot(my_pls2, what="observations", where=c("u","u"), show.names = FALSE, main="Map of observation_(u,u)_transplant", col.points = blok, pch=19)
ordiellipse(my_pls2,trans[,3],conf=0.99) # puts elipse on pca graph based on pca file created and according to the file 3rd column

But then I am getting an error:

Error in scores.default(ord, display = display, ...) : Can't find scores

The packages that I am using are plsdepot and vegan.

dput(data)

site    ind STATUS  BLOK    E1  E2  E3  E4  E5  E6  E7  Li  Rb  Mo  Ag  Cd  Sn  Sb  Pb  Bi  U   Al  Ti  V   Cr  Mn  Fe  Co  Ni  Cu  Zn  Sr  Ba  As  Se
A   A1  C   N   73.858  78.044  24.59   22.57   0.85    16.92   3.4 1.522   5.949   0.987   0.025   0.721   0.069   0.025   0.737   0.01    0.099   619.5   32.4    3.229   1.438   9.19    425.3   0.753   1.492   4.759   107.7   33.3    3.46    24  3.672
A   A2  C   N   66.848  68.608  40.984  20.52   0.58    17.1    1.62    1.522   5.949   0.987   0.025   0.721   0.069   0.025   0.737   0.01    0.099   619.5   32.4    3.229   1.438   9.19    425.3   0.753   1.492   4.759   107.7   33.3    3.46    24  3.672
A   A3  C   N   66.718  32.434  99.666  14.96   0.08    22.21   4   1.522   5.949   0.987   0.025   0.721   0.069   0.025   0.737   0.01    0.099   619.5   32.4    3.229   1.438   9.19    425.3   0.753   1.492   4.759   107.7   33.3    3.46    24  3.672
A   A4  C   N   103.134 74.44   34.946  27.61   1.48    16.39   2.42    1.522   5.949   0.987   0.025   0.721   0.069   0.025   0.737   0.01    0.099   619.5   32.4    3.229   1.438   9.19    425.3   0.753   1.492   4.759   107.7   33.3    3.46    24  3.672
A   A5  C   N   69.078  44.9    54.358  29.72   2.14    12.76   1.21    1.522   5.949   0.987   0.025   0.721   0.069   0.025   0.737   0.01    0.099   619.5   32.4    3.229   1.438   9.19    425.3   0.753   1.492   4.759   107.7   33.3    3.46    24  3.672
A   A6  C   N   53.236  51.874  40.706  22.67   1.85    15.92   7.76    1.522   5.949   0.987   0.025   0.721   0.069   0.025   0.737   0.01    0.099   619.5   32.4    3.229   1.438   9.19    425.3   0.753   1.492   4.759   107.7   33.3    3.46    24  3.672
A   A7  C   N   70.044  47.672  40.706  31.53   0.1 16.1    1.58    1.522   5.949   0.987   0.025   0.721   0.069   0.025   0.737   0.01    0.099   619.5   32.4    3.229   1.438   9.19    425.3   0.753   1.492   4.759   107.7   33.3    3.46    24  3.672
A   A8  C   N   68.328  44.174  36.238  27.98   0.91    23.21   9.02    1.522   5.949   0.987   0.025   0.721   0.069   0.025   0.737   0.01    0.099   619.5   32.4    3.229   1.438   9.19    425.3   0.753   1.492   4.759   107.7   33.3    3.46    24  3.672
A   A9  C   N   120.928 47.576  34.946  26.19   0.83    15.39   3.47    1.522   5.949   0.987   0.025   0.721   0.069   0.025   0.737   0.01    0.099   619.5   32.4    3.229   1.438   9.19    425.3   0.753   1.492   4.759   107.7   33.3    3.46    24  3.672
A   A10 C   N   79.588  56.958  66.444  20.64   0.49    11.76   3.83    1.522   5.949   0.987   0.025   0.721   0.069   0.025   0.737   0.01    0.099   619.5   32.4    3.229   1.438   9.19    425.3   0.753   1.492   4.759   107.7   33.3    3.46    24  3.672
B   B1  P   N   151.374 81.816  47.812  20.73   0.18    15.68   9.04    1.204   5.974   1.252   0.07    0.642   0.45    0.065   8.411   0.026   0.112   184.6   13.1    18.127  2.484   5.15    235 0.441   1.126   16.208  176.9   65.9    11.16   23.79   3.215
B   B2  P   N   146.716 155.784 67.864  67.25   2.73    15.8    2.51    1.204   5.974   1.252   0.07    0.642   0.45    0.065   8.411   0.026   0.112   184.6   13.1    18.127  2.484   5.15    235 0.441   1.126   16.208  176.9   65.9    11.16   23.79   3.215
B   B3  P   N   165.122 36.742  63.35   27.86   0.68    16.4    10.64   1.204   5.974   1.252   0.07    0.642   0.45    0.065   8.411   0.026   0.112   184.6   13.1    18.127  2.484   5.15    235 0.441   1.126   16.208  176.9   65.9    11.16   23.79   3.215
B   B4  P   N   115.256 55.78   93.304  52.85   1.63    15.98   2.61    1.204   5.974   1.252   0.07    0.642   0.45    0.065   8.411   0.026   0.112   184.6   13.1    18.127  2.484   5.15    235 0.441   1.126   16.208  176.9   65.9    11.16   23.79   3.215
B   B5  P   N   185.064 44.9    104.488 44.77   2.3 22.02   1.42    1.204   5.974   1.252   0.07    0.642   0.45    0.065   8.411   0.026   0.112   184.6   13.1    18.127  2.484   5.15    235 0.441   1.126   16.208  176.9   65.9    11.16   23.79   3.215
B   B6  P   N   83.362  72.99   156.73  29.58   0.67    14.68   1.42    1.204   5.974   1.252   0.07    0.642   0.45    0.065   8.411   0.026   0.112   184.6   13.1    18.127  2.484   5.15    235 0.441   1.126   16.208  176.9   65.9    11.16   23.79   3.215
B   B7  P   N   49.506  35.008  81.74   32.98   0.19    16.9    1.39    1.204   5.974   1.252   0.07    0.642   0.45    0.065   8.411   0.026   0.112   184.6   13.1    18.127  2.484   5.15    235 0.441   1.126   16.208  176.9   65.9    11.16   23.79   3.215
B   B8  P   N   99.64   100.57  54.494  32.19   2.25    17.3    2.89    1.204   5.974   1.252   0.07    0.642   0.45    0.065   8.411   0.026   0.112   184.6   13.1    18.127  2.484   5.15    235 0.441   1.126   16.208  176.9   65.9    11.16   23.79   3.215
B   B9  P   N   179.53  52.368  72.77   39.15   2   14.98   8.7 1.204   5.974   1.252   0.07    0.642   0.45    0.065   8.411   0.026   0.112   184.6   13.1    18.127  2.484   5.15    235 0.441   1.126   16.208  176.9   65.9    11.16   23.79   3.215
B   B10 P   N   152.89  37.102  66.632  32.73   2.39    22.9    3.94    1.204   5.974   1.252   0.07    0.642   0.45    0.065   8.411   0.026   0.112   184.6   13.1    18.127  2.484   5.15    235 0.441   1.126   16.208  176.9   65.9    11.16   23.79   3.215
C   C1  C   M   60.25   62.024  34.686  33.51   0.49    19.69   4.39    1.366   6.739   7.213   0.04    0.875   0.057   0.022   0.962   0.014   0.139   408.4   22.6    2.543   1.255   17.32   284.5   0.71    1.779   5.244   64.2    36.1    6.68    32.39   5.301
C   C2  C   M   22.088  124.372 70.17   49.88   0.68    18.65   3.48    1.366   6.739   7.213   0.04    0.875   0.057   0.022   0.962   0.014   0.139   408.4   22.6    2.543   1.255   17.32   284.5   0.71    1.779   5.244   64.2    36.1    6.68    32.39   5.301
C   C3  C   M   34.458  62.5    52.042  44.36   1.96    21.68   4.34    1.366   6.739   7.213   0.04    0.875   0.057   0.022   0.962   0.014   0.139   408.4   22.6    2.543   1.255   17.32   284.5   0.71    1.779   5.244   64.2    36.1    6.68    32.39   5.301
C   C4  C   M   33.456  70.816  61.326  49.87   2.57    18.98   2.59    1.366   6.739   7.213   0.04    0.875   0.057   0.022   0.962   0.014   0.139   408.4   22.6    2.543   1.255   17.32   284.5   0.71    1.779   5.244   64.2    36.1    6.68    32.39   5.301
C   C5  C   M   48.572  102.868 43.58   54.52   0.35    4.61    4.53    1.366   6.739   7.213   0.04    0.875   0.057   0.022   0.962   0.014   0.139   408.4   22.6    2.543   1.255   17.32   284.5   0.71    1.779   5.244   64.2    36.1    6.68    32.39   5.301
C   C6  C   M   62.214  55.654  34.686  38.58   0.71    19.1    2.59    1.366   6.739   7.213   0.04    0.875   0.057   0.022   0.962   0.014   0.139   408.4   22.6    2.543   1.255   17.32   284.5   0.71    1.779   5.244   64.2    36.1    6.68    32.39   5.301
C   C7  C   M   32.41   79.09   68.15   34.7    0.95    17.55   5.74    1.366   6.739   7.213   0.04    0.875   0.057   0.022   0.962   0.014   0.139   408.4   22.6    2.543   1.255   17.32   284.5   0.71    1.779   5.244   64.2    36.1    6.68    32.39   5.301
C   C8  C   M   33.574  90.35   52.042  56.13   3.96    22.68   8.24    1.366   6.739   7.213   0.04    0.875   0.057   0.022   0.962   0.014   0.139   408.4   22.6    2.543   1.255   17.32   284.5   0.71    1.779   5.244   64.2    36.1    6.68    32.39   5.301
C   C9  C   M   36.522  121.092 62.92   58.42   1.39    17.78   2.56    1.366   6.739   7.213   0.04    0.875   0.057   0.022   0.962   0.014   0.139   408.4   22.6    2.543   1.255   17.32   284.5   0.71    1.779   5.244   64.2    36.1    6.68    32.39   5.301
C   C10 C   M   31.608  70.058  43.58   32.02   0.89    5.52    2.66    1.366   6.739   7.213   0.04    0.875   0.057   0.022   0.962   0.014   0.139   408.4   22.6    2.543   1.255   17.32   284.5   0.71    1.779   5.244   64.2    36.1    6.68    32.39   5.301
D   D1  P   M   79.37   116.392 94.426  43.88   0.94    13.81   2.22    1.859   5.613   3.106   0.253   0.951   2.389   0.054   14.05   0.134   0.138   328.4   54.2    1.774   3.133   6.33    386.9   0.667   1.298   312.977 410.9   80.5    5.36    24.82   3.122
D   D2  P   M   132.234 88.232  71.56   49.76   0.36    9.51    2.68    1.859   5.613   3.106   0.253   0.951   2.389   0.054   14.05   0.134   0.138   328.4   54.2    1.774   3.133   6.33    386.9   0.667   1.298   312.977 410.9   80.5    5.36    24.82   3.122
D   D3  P   M   137.114 156.878 84.6    42.43   0.26    23.93   2.36    1.859   5.613   3.106   0.253   0.951   2.389   0.054   14.05   0.134   0.138   328.4   54.2    1.774   3.133   6.33    386.9   0.667   1.298   312.977 410.9   80.5    5.36    24.82   3.122
D   D4  P   M   161.826 132.916 59.922  41.64   0.34    6.96    2.68    1.859   5.613   3.106   0.253   0.951   2.389   0.054   14.05   0.134   0.138   328.4   54.2    1.774   3.133   6.33    386.9   0.667   1.298   312.977 410.9   80.5    5.36    24.82   3.122
D   D5  P   M   97.656  153.014 117.94  32.9    1.17    2.09    2.21    1.859   5.613   3.106   0.253   0.951   2.389   0.054   14.05   0.134   0.138   328.4   54.2    1.774   3.133   6.33    386.9   0.667   1.298   312.977 410.9   80.5    5.36    24.82   3.122
D   D6  P   M   100.3   155.406 65.88   35.97   0.42    14.81   1.85    1.859   5.613   3.106   0.253   0.951   2.389   0.054   14.05   0.134   0.138   328.4   54.2    1.774   3.133   6.33    386.9   0.667   1.298   312.977 410.9   80.5    5.36    24.82   3.122
D   D7  P   M   94.694  114.008 109.444 30.66   0.72    10.51   3.42    1.859   5.613   3.106   0.253   0.951   2.389   0.054   14.05   0.134   0.138   328.4   54.2    1.774   3.133   6.33    386.9   0.667   1.298   312.977 410.9   80.5    5.36    24.82   3.122
D   D8  P   M   175.182 153.594 49.322  30.97   0.72    22.93   2.9 1.859   5.613   3.106   0.253   0.951   2.389   0.054   14.05   0.134   0.138   328.4   54.2    1.774   3.133   6.33    386.9   0.667   1.298   312.977 410.9   80.5    5.36    24.82   3.122
D   D9  P   M   135.814 104.438 78.592  36.73   1.34    6.96    6.04    1.859   5.613   3.106   0.253   0.951   2.389   0.054   14.05   0.134   0.138   328.4   54.2    1.774   3.133   6.33    386.9   0.667   1.298   312.977 410.9   80.5    5.36    24.82   3.122
D   D10 P   M   70.534  141.234 106.052 36.33   0.97    1.09    2.93    1.859   5.613   3.106   0.253   0.951   2.389   0.054   14.05   0.134   0.138   328.4   54.2    1.774   3.133   6.33    386.9   0.667   1.298   312.977 410.9   80.5    5.36    24.82   3.122
E   E1  C   S   67.29   143.506 36.088  25.83   2.74    11.16   2.93    1.516   6.642   3.406   0.027   0.899   0.051   0.027   0.651   0.018   0.104   393.5   21.1    2.406   6.467   11.55   289.7   0.591   2.003   5.408   70.6    58.2    2.47    23.04   5.368
E   E2  C   S   NA  75.094  44.758  28.71   0.33    15.77   5.72    1.516   6.642   3.406   0.027   0.899   0.051   0.027   0.651   0.018   0.104   393.5   21.1    2.406   6.467   11.55   289.7   0.591   2.003   5.408   70.6    58.2    2.47    23.04   5.368
E   E3  C   S   28.66   53.16   48.526  34.77   0.69    1.6 1.73    1.516   6.642   3.406   0.027   0.899   0.051   0.027   0.651   0.018   0.104   393.5   21.1    2.406   6.467   11.55   289.7   0.591   2.003   5.408   70.6    58.2    2.47    23.04   5.368
E   E4  C   S   72.53   108.82  48.634  37.05   1.53    16.77   6.37    1.516   6.642   3.406   0.027   0.899   0.051   0.027   0.651   0.018   0.104   393.5   21.1    2.406   6.467   11.55   289.7   0.591   2.003   5.408   70.6    58.2    2.47    23.04   5.368
E   E5  C   S   56.122  53.16   42.11   48.81   0.24    11.05   2.29    1.516   6.642   3.406   0.027   0.899   0.051   0.027   0.651   0.018   0.104   393.5   21.1    2.406   6.467   11.55   289.7   0.591   2.003   5.408   70.6    58.2    2.47    23.04   5.368
E   E6  C   S   79.63   98.662  35.928  26.18   0.78    12.16   3.39    1.516   6.642   3.406   0.027   0.899   0.051   0.027   0.651   0.018   0.104   393.5   21.1    2.406   6.467   11.55   289.7   0.591   2.003   5.408   70.6    58.2    2.47    23.04   5.368
E   E7  C   S   87.75   70.358  44.758  33.62   1.02    14.77   1.8 1.516   6.642   3.406   0.027   0.899   0.051   0.027   0.651   0.018   0.104   393.5   21.1    2.406   6.467   11.55   289.7   0.591   2.003   5.408   70.6    58.2    2.47    23.04   5.368
E   E8  C   S   76.722  33.79   48.526  44.37   0.32    2.6 3.4 1.516   6.642   3.406   0.027   0.899   0.051   0.027   0.651   0.018   0.104   393.5   21.1    2.406   6.467   11.55   289.7   0.591   2.003   5.408   70.6    58.2    2.47    23.04   5.368
E   E9  C   S   22.59   37.468  48.634  35.89   0.25    15.77   3.96    1.516   6.642   3.406   0.027   0.899   0.051   0.027   0.651   0.018   0.104   393.5   21.1    2.406   6.467   11.55   289.7   0.591   2.003   5.408   70.6    58.2    2.47    23.04   5.368
E   E10 C   S   56.59   40.78   42.11   19.6    0.25    12.05   2.42    1.516   6.642   3.406   0.027   0.899   0.051   0.027   0.651   0.018   0.104   393.5   21.1    2.406   6.467   11.55   289.7   0.591   2.003   5.408   70.6    58.2    2.47    23.04   5.368
F   F1  P   S   113.338 99.742  53.584  27.15   0.05    9.75    4.9 1.527   6.122   1.255   0.043   0.651   0.396   0.134   6.039   0.041   0.19    507.7   36.5    2.651   2.897   8.96    388.8   0.747   1.968   43.988  172.1   55.2    18.69   27.24   3.964
F   F2  P   S   32.006  158.122 50.918  47.87   0.19    2.53    4.79    1.527   6.122   1.255   0.043   0.651   0.396   0.134   6.039   0.041   0.19    507.7   36.5    2.651   2.897   8.96    388.8   0.747   1.968   43.988  172.1   55.2    18.69   27.24   3.964
F   F3  P   S   31.84   157.776 90.49   34.43   0.02    22.59   2.25    1.527   6.122   1.255   0.043   0.651   0.396   0.134   6.039   0.041   0.19    507.7   36.5    2.651   2.897   8.96    388.8   0.747   1.968   43.988  172.1   55.2    18.69   27.24   3.964
F   F4  P   S   36.362  86.126  70.18   32.314  0.02    26.35   6.7 1.527   6.122   1.255   0.043   0.651   0.396   0.134   6.039   0.041   0.19    507.7   36.5    2.651   2.897   8.96    388.8   0.747   1.968   43.988  172.1   55.2    18.69   27.24   3.964
F   F5  P   S   89.888  77.3    61.708  49.89   0.14    4.58    6.45    1.527   6.122   1.255   0.043   0.651   0.396   0.134   6.039   0.041   0.19    507.7   36.5    2.651   2.897   8.96    388.8   0.747   1.968   43.988  172.1   55.2    18.69   27.24   3.964
F   F6  P   S   57.914  68.176  89.308  32.05   0.03    8.75    6.05    1.527   6.122   1.255   0.043   0.651   0.396   0.134   6.039   0.041   0.19    507.7   36.5    2.651   2.897   8.96    388.8   0.747   1.968   43.988  172.1   55.2    18.69   27.24   3.964
F   F7  P   S   63.488  81.408  50.918  24.84   0.02    1.53    13.61   1.527   6.122   1.255   0.043   0.651   0.396   0.134   6.039   0.041   0.19    507.7   36.5    2.651   2.897   8.96    388.8   0.747   1.968   43.988  172.1   55.2    18.69   27.24   3.964
F   F8  P   S   65.04   69.306  88.642  28.68   0.31    23.59   6.45    1.527   6.122   1.255   0.043   0.651   0.396   0.134   6.039   0.041   0.19    507.7   36.5    2.651   2.897   8.96    388.8   0.747   1.968   43.988  172.1   55.2    18.69   27.24   3.964
F   F9  P   S   42.456  50.728  70.18   26.28   0.02    25.45   3.79    1.527   6.122   1.255   0.043   0.651   0.396   0.134   6.039   0.041   0.19    507.7   36.5    2.651   2.897   8.96    388.8   0.747   1.968   43.988  172.1   55.2    18.69   27.24   3.964
F   F10 P   S   42.644  73.532  64.778  32.35   0.02    5.58    11.07   1.527   6.122   1.255   0.043   0.651   0.396   0.134   6.039   0.041   0.19    507.7   36.5    2.651   2.897   8.96    388.8   0.747   1.968   43.988  172.1   55.2    18.69   27.24   3.964
J.Con
  • 4,101
  • 4
  • 36
  • 64
Doro
  • 75
  • 5
  • Please can you include some data (use `dput`) to so that others can replicate your problem – Richard Telford Feb 13 '17 at 14:16
  • I am new here, so not sure how to do it. can I load the excel table somehow? – Doro Feb 13 '17 at 14:41
  • Run `dput(trans)` and edit the result into your question. If the data are very large, just include a subset of rows/columns – Richard Telford Feb 13 '17 at 16:40
  • You need `scores` function that extracts the two columns for which you want to draw the ellipse. Alternatively, you can produce a 2-column matrix that `vegan:::scores.default` knows. NB., `ordiellipse` assumes that your plot is isometric: units are equal on both axes. If not so, the ellipse will be biased. – Jari Oksanen Feb 14 '17 at 08:43
  • hmm..not quite sure how to write a command. – Doro Feb 14 '17 at 11:03
  • There is a canned `scores` function in vegan that will read the x and y coordinates from a 2-column matrix. Write a matrix, and give this as the first argument. The second argument must be a matching vector that gives the grouping of each row of the 2-column matrix. – Jari Oksanen Feb 14 '17 at 12:39
  • wow thanks a lot! that worked! – Doro Feb 14 '17 at 15:43
  • Do you think I could run ANOVA on PLS scores as well, and get significance for CLEAN and POLLUTED? if the ellipse fits good, statistical tests should as well. – Doro Feb 15 '17 at 12:35

0 Answers0