calculate_diversity.R script is not working properly

Hello,

I am facing problem running the calculate_diversity.R for alpha and beta diversity analysis with the script provided in the metaphlan utilities folder.

So, I ran metaphlan/4.2.2 at species level (–tax_lev ‘s’) and then merged the multiple samples with merge_metaphlan_tables.py command available in the metaphlan package.

Next, I wanted to run alpha and beta diversities using this merged metaphlan table.

I ran the alpah diversity with the following command:

Rscript /home/User10/metaphlan/4.2.2/lib/python3.13/site-packages/metaphlan/utils/calculate_diversity.R -f merged_metaphlan_S.txt -d alpha -m shannon

It runs without error but with the warning below:

WARNING: 25 samples with 100% unknown species were removed from the input table.

and my output file diversity_analysis/merged_metaphlan_S_shannon.tsv is emtpy.

Next, I tried to run beta diversity with the following command:

Rscript /home/User10/metaphlan/4.2.2/lib/python3.13/site-packages/metaphlan/utils/calculate_diversity.R -f merged_metaphlan_S.txt -d beta -m bray-curtis

Then I get this error

Error in rb_counts():
! Matrix is all zeroes.
Backtrace:

  1. ├─rbiom::beta.div(…)
  2. │ └─rbiom::bdiv_distmat(…)
  3. │ ├─stats::as.dist(…)
  4. │ └─rbiom::bdiv_matrix(…)
  5. │ ├─rbiom::as_rbiom(biom)
  6. │ └─rbiom:::as_rbiom.default(biom)
  7. │ └─rbiom$new(counts = biom, …)
  8. │ └─rbiom (local) initialize(…)
  9. │ └─rbiom:::rb_init(…)
  10. └─rbiom (local) <fn>(base::quote(<lgl[,0]>))
  11. └─rbiom:::rb_counts(self, private, value)
  12. └─cli::cli_abort("Matrix is all zeroes.")
    
  13.   └─rlang::abort(...)
    

Warning message:
beta.div() was deprecated in rbiom 2.0.0.
:information_source: Please use bdiv_distmat() instead for generating a distance matrix.
Execution halted

I have checkec that my input species abundance is NOT zero.

Could you please help me to fix this error and successfully run alpha and beta diversities for my metagenomic samples?

Many thanks in advance!

a similar issue! bray curtis fine! but then aitchison give an error : Error in rb_counts():
! Matrix can’t have negative values. were you able to solve your problem?