Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: export loadings from plotLoadings without plotting #294

Open
tyronechen opened this issue May 18, 2023 · 1 comment
Open
Assignees
Labels
feature-request Can be implemented if there's enough interest

Comments

@tyronechen
Copy link

Is your feature request related to a problem? Please describe.

Aim is to export a table of all loading values from plotLoadings without plotting the associated bar graph. This was possible in an earlier version of mixOmics 6.17.3. Version tested is 6.23.4.

Describe the solution you'd like

I would like to skip the plot generation when exporting all loadings. This is computationally expensive with a lot of features.

Describe alternatives you've considered

A workaround exists, it is possible to generate the plot as normal, with plot=TRUE (see below) and then catch the output in a variable. However in the case of many features (>10000) it slows down and generates very big plots.

Additional context

Code below best shows the event. Minimum reproducible example based on the Koren case study. mixOmics 6.23.4.

> sessionInfo()
R version 4.2.3 (2023-03-15)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: libopenblasp-r0.3.21.so

locale:
 [1] LC_CTYPE=en_AU.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_AU.UTF-8        LC_COLLATE=en_AU.UTF-8
 [5] LC_MONETARY=en_AU.UTF-8    LC_MESSAGES=en_AU.UTF-8
 [7] LC_PAPER=en_AU.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] mixOmics_6.23.4 ggplot2_3.4.1   lattice_0.20-45 MASS_7.3-58.3

data("Koren.16S") # extract the microbial data
X <- Koren.16S$data.raw # set the raw OTU data as the predictor dataframe
Y <- Koren.16S$bodysite # set the bodysite class as the response vector
basic.koren.plsda = plsda(X, Y, logratio = 'CLR', ncomp = nlevels(Y))

Plot everything correctly:

x <- plotLoadings(basic.koren.plsda, contrib="max", plot=TRUE)
# pull out the values
dim(x$X)
[1] 980  10
...

This errors out. I traced this back to a line in plotLoadings. Here is one sample for plotLoadings.mixo_plsda (others have this too):

x <- plotLoadings(basic.koren.plsda, contrib="max", plot=FALSE)
Error in names(contrib.df) <- block :
  'names' attribute [1] must be the same length as the vector [0]

I note that this worked in mixOmics 6.17.3:

> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: libopenblasp-r0.3.15.so

locale:
 [1] LC_CTYPE=en_AU.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_AU.UTF-8        LC_COLLATE=en_AU.UTF-8
 [5] LC_MONETARY=en_AU.UTF-8    LC_MESSAGES=en_AU.UTF-8
 [7] LC_PAPER=en_AU.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] mixOmics_6.17.3 ggplot2_3.3.6   lattice_0.20-45 MASS_7.3-58.1
@tyronechen tyronechen added the feature-request Can be implemented if there's enough interest label May 18, 2023
@tyronechen tyronechen changed the title feature request: feature request: export loadings from plotLoadings without plotting May 18, 2023
@LafontRapnouilTristan
Copy link

LafontRapnouilTristan commented Jun 26, 2024

Hi,

thanks for the amazing work!
This would be great with any plot function of Mixomics.

For instance if I want to ggplotify the network I can store its data in a variable but can cause some issues with graphic state if working in Rmarkdown with graphical display in line.
A direct access to the data used for your plot methods would be great!
Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Can be implemented if there's enough interest
Projects
None yet
Development

No branches or pull requests

3 participants