Metaphlan4 Diversity Calculation Error

Using the provided script “calculate_diversity.R” I am unable to calculate Weighted and Unweighted Unifrac. I am using the following command:

Rscript calculate_diversity.R -f Metaphlan4/T2DM_Taxonomic_Profiles/merged_abundance_table.txt -t mpa_vJan21_CHOCOPhlAnSGB_202103.nwk -d beta -m weighted-unifrac

I get the following error:

Error in FUN(X[[i]], …) : attempt to set index 0/0 in SET_STRING_ELT
Calls: → lapply → FUN
In addition: Warning message:
In FUN(X[[i]], …) : NAs introduced by coercion
Execution halted

I was able to calculate bray curtis and jaccard no problem.

Any help is greatly appreciated. Many thanks

Hi @PeterCx
I need to understand better the problem, can you tell me which database version are you using to ran metaphlan4? (you can check that in the first lines of the metaphlan profiles).
Is the file mpa_vJan21_CHOCOPhlAnSGB_202103.nwk in the same folder you are running the script?

1 Like

Please forgive me. It was a rookie error. I was using the wrong tree. It should have been version Oct22 instead of Jan21. Thanks for response.