Biplot customisation

Hi there,

I have been generating some biplots to show the contribution of some variables to the cluster I see in the PCA plots, however, I can’t find a way to get rid of those variables with less weight. The image is so busy (hundreds of vectors) that it is not worth it to use it. Is there a way to set a cutoff to show those with more weight.

I have had a look at the ‘help’ tool to see if there is an argument that allows me to customise the code, but I have not found any.

Any help more than appreciated.

Cheers,

Yali

Capture Here an example, how it looks like.

Hi @Yali,
You can either keep the top features with highest loadings, or simply use the sparse pca (spca) function from mixOmics to select for variables. See example below.

data(multidrug)

## all variables
pca.res <- pca(multidrug$ABC.trans, ncomp = 2, scale = TRUE)
biplot(pca.res, xlabs = multidrug$cell.line$Class, cex = 0.7)

## select variables using spca
spca.res <- spca(multidrug$ABC.trans, ncomp = 2, scale = TRUE, keepX = c(15, 15))
selected_vars <- selectVar(spca.res)$name
## only plot the selected variables in biplot
biplot(x = spca.res$variates$X[,1:2],  y = spca.res$rotation[selected_vars,1:2] , xlabs = multidrug$cell.line$Class, cex = 0.7)

We’re adding the tune feature to spca to help find the optimal number of variables to keep but that is not quite out yet. Let us know if that’s something you’re interested in.

Best,

Al