Question about calculate_diversity.R

MetaPhlAn version 4.0.6 (1 Mar 2023):

–Describe the issue

I tried to use calcaulate_diversity.R for alpha and beta diversity. I have some issue with command line from tutorials.

When I ran metaphlan4, I had only two txt files: 1) bowtie2.txt and 2) profile.txt.

In the tutorial, however, tsv file is used. My question is how I can produce tsv file from metaphlan run.

Another question is when I used profile.txt file for calculate_diversity.R, I got the following errors.

Warning: unable to access index for repository http://cran.us.r-project.org/src/contrib:
Line starting ' install.packages → available.packages → readRDS
In addition: Warning message:
package âoptparseâ is not available (for R version 3.5.1)
Execution halted

Would someone please let me know how to calculate alpha and beta diversity from output of metaphlan?

Thanks.

Hi and sorry for the late reply!

Regarding the first point, the metaphlan run produces a profile.txt file for each sample, you can then merge the single profiles with the script merge_metaphlan_tables.py (here the tutorial: MetaPhlAn 4 · biobakery/MetaPhlAn Wiki · GitHub) to obtain a .tsv table on which you can then calculate alpha and beta diveristy.
Regarding the error message from R, are you running the script calculate_diversity.R inside a conda environment with metaphlan4? (here the installation tutorial MetaPhlAn 4 · biobakery/MetaPhlAn Wiki · GitHub), like that you should already have the requirements installed.