biocore / gemelli

Gemelli is a tool box for running Robust Aitchison PCA (RPCA), Joint Robust Aitchison PCA (Joint-RPCA), TEMPoral TEnsor Decomposition (TEMPTED), and Compositional Tensor Factorization (CTF) on sparse compositional omics datasets.
BSD 3-Clause "New" or "Revised" License
76 stars 18 forks source link

DEICODE toy tutorial not working in qiime2-amplicon-2024.5 version #100

Closed magibc closed 1 month ago

magibc commented 1 month ago

Dear @cameronmartino and other developers of DEICODE and Gemelli,

Due to the DEICODE Github is being replaced by Gemelli, I also post here although my original comment can be seen in: https://github.com/biocore/DEICODE/issues/68#issue-2562363609

Thanks in advance for your insights, and comments.

Regards,

Maggie

cameronmartino commented 1 month ago

Hi @magibc,

The RPCA function as described here and originally released in DEICODE is only maintained in Gemelli and is no longer supported/maintained in the DEICODE repository. Please use Gemelli's RPCA, which should work in the current QIIME2 environments.

Thanks,

Cameron

magibc commented 1 month ago

Thank you very much @cameronmartino ,

I have installed gemelli as standalone. And I have done the toy example with rpca (https://github.com/biocore/gemelli/blob/master/ipynb/tutorials/RPCA-moving-pictures-standalone-cli-and-api.ipynb) .

I obtained two files: ordination.txt and distance_matrix.tsv.

However in the abovementioned tutorial, only ordination.txt is used in the qurro software.

Both files are in scikit-bio format but the two hyperlinks for tutorial does not work (Page not found error). Do you have available this tutorials in a pdf format or html?

In additionm could I use this two files to plot the PCA in R?

Or you recommends me to follow Python CLI as in tutorial for my data?

Thank you if you have some hints that I can use to interpret the data obtained, plot the PCA and perform after a Procrust analysis.

Furthermore if I try the Python CLI, in the next part I obtain the following error:

from assets.plotting_helper import biplot
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'assets'

Only exists Python asset module but not assets... How can I fix it? Thanks again

Have a nice day,

Maggie.

cameronmartino commented 1 month ago

Hi @magibc,

For the QIIME2 implementation, you can import the output of RPCA directly into R to plot/explore, see here and here for how to do that.

The links to the skbio types can be found here for the OrdinationResults and here for the DistanceMatrix. The distance matrix is already in tab-delimited format, so that could already be imported into R how you would normally import a .tsv file. If you want to export the components of the OrdinationResults into separate .csv files for import into R, you could do the following:

import pandas as pd
from skbio import OrdinationResults

# export sample/feature loadings as csv
ord_res = OrdinationResults.read('qiime2-moving-pictures-tutorial/standalone-cli/ordination.txt')
ord_res.samples.to_csv('qiime2-moving-pictures-tutorial/standalone-cli/ordination-sample-loadings.csv')
ord_res.features.to_csv('qiime2-moving-pictures-tutorial/standalone-cli/ordination-feature-loadings.csv')
ord_res.eigvals.to_csv('qiime2-moving-pictures-tutorial/standalone-cli/ordination-eigvals.csv')
ord_res.proportion_explained.to_csv('qiime2-moving-pictures-tutorial/standalone-cli/ordination-proportion-explained.csv')

I am un-awaare of an easier way to import skbio OrdinationResults into R (but that does not mean it does not exist).

I will open an issue for that plotting function being absent and to update the links in the tutorials, thank you for letting me know.

I hope that helps. Best,

Cameron

magibc commented 1 month ago

Hi @cameronmartino ,

Apologise for my bit delay.

Thank you for your message!!! In theory obtaining the ordination_sample_loadings.csv will be enough to plot the corresponding PCA using the rpca algorithm in Gemelli. Thank you very much!

Moreover, I would like to plot using your plugin, but in the standalone rpca tutorial when indicates:

from assets.plotting_helper import biplot

My system says that no assets module exists. But I think that maybe I have to download some python file from your Github?

Maggie

cameronmartino commented 1 month ago

Hi @magibc,

I put in an issue for this problem, but you can find the plotting function for the tutorial here. However, this is not a tested function and should not be used to make figures for publications; it is just a helper function for the tutorial. I suggest using Emperor in Python or a similar tested function in R for publications.

Thanks!

Cameron

magibc commented 1 month ago

Ok Cameron @cameronmartino

Many thanks

cameronmartino commented 1 month ago

Glad it worked. Thanks for using RPCA! Closing this issue but please feel free to re-open if the problem persists.