Closed DeniRibicic closed 2 years ago
If you look at the documentation for plotLoadings()
(via ?plotLoadings
), you will see the contrib
and method
parameters. When this are non-NULL, the returned object is a dataframe. Observe the GroupContrib
column to find what you're looking for
data(srbct)
X <- srbct$gene[,1:10]
Y <- srbct$class
model <- splsda(X, Y)
obj <- plotLoadings(model, contrib = "max", method="mean")
obj
#> EWS BL NB RMS Contrib.EWS Contrib.BL
#> g1 0.45191775 -1.41860883 -0.53145775 0.36661277 TRUE FALSE
#> g2 -0.42043056 -0.56012905 -0.41195530 0.95471994 FALSE FALSE
#> g3 0.08367123 0.23803114 0.78169159 -0.66044932 FALSE FALSE
#> g9 -0.45584880 0.91373648 0.59266341 -0.19686652 FALSE TRUE
#> g4 -0.31926138 0.19024186 0.78559795 -0.18030493 FALSE FALSE
#> g8 0.16173375 0.20372641 -0.76198922 0.18970915 FALSE TRUE
#> g6 0.14843647 -0.38690277 -0.34439310 0.19069503 FALSE FALSE
#> g7 -0.14465770 -0.51111911 -0.07106862 0.41344517 FALSE FALSE
#> g5 0.18874901 0.07687763 -0.59904443 0.11161424 TRUE FALSE
#> g10 -0.26216968 0.87078260 -0.22078014 0.08565018 FALSE TRUE
#> Contrib.NB Contrib.RMS Contrib GroupContrib color importance
#> g1 FALSE FALSE FALSE EWS #388ECC -0.4946755
#> g2 FALSE TRUE FALSE RMS #009E73 -0.4246271
#> g3 TRUE FALSE FALSE NB #C2C2C2 0.4079229
#> g9 FALSE FALSE FALSE BL #F68B33 0.3819278
#> g4 TRUE FALSE FALSE NB #C2C2C2 0.2984552
#> g8 FALSE FALSE FALSE BL #F68B33 -0.2200930
#> g6 FALSE TRUE FALSE RMS #009E73 -0.2111764
#> g7 FALSE TRUE FALSE RMS #009E73 -0.2033517
#> g5 FALSE FALSE FALSE EWS #388ECC -0.1806413
#> g10 FALSE FALSE FALSE BL #F68B33 0.0813818
Created on 2022-08-29 by the reprex package (v2.0.1)
Hi,
I have conducted
splsda
test and subsequent predictions, where I can see after plotting the loadingsplotLoadings
there are certain features driving discrimination between multiple outcomes.I am wondering how I can extract this into a table, where every feature will be connected to outcome it contributes to.
ps. if it was only two outcomes, then it is easier to get this info, as it is usually discriminated along x axis as positive or negative. However, I have here multiple outcomes, and few features are positive for several outcomes, while few negative along x-axis, therefore making in more difficult to discriminate exactly which feature belongs to which outcome. Hope this makes sense.
Thanks