How to round PICRUSt2 output tables to nearest integer

I'm trying to run my PICRUSt2 output (which produces non-integer results) through q2-aldex2 (which requires integer values). Is there an easy way to round my .qza tables to be compatible with ALDEx2?

I encountered the same issue a week ago and solved it using python. I can give you an example for Ubuntu (never tried with Windows or Mac).
So, first of all you will need Jupyter lab or notebook installed in your Qiime2 environment.

1 Activate your qiime2 environment
2 Install Jupyter lab:

conda install -c conda-forge jupyterlab

3 Launch Jupyter lab:

jupyter lab

4 Press Python3 sign in the opened window, copy the text below to the cell, add the path to your table to the code and run the cell:

### Modify here
tabin  = 'path to your table'          # add path to your table
round  = 'path to your rounded table'  # add desired path to your rounded table
outdir = 'export'                      # change the path for intermediate files or leave it like this

### Nothing to change from here

import pandas as pd 

### Export tables, round up and import back

!qiime tools export \
    --input-path $tabin \
    --output-path $outdir

!biom convert -i $outdir/feature-table.biom -o $outdir/float-table.tsv --to-tsv

df = pd.read_csv(outdir+'/float-table.tsv',sep='\t',index_col=0,skiprows=1)

!biom convert -i $outdir/round-table.tsv -o $outdir/round-table.biom --table-type="OTU table" --to-hdf5

!qiime tools import \
    --input-path $outdir/round-table.biom \
    --type 'FeatureTable[Frequency]' \
    --input-format BIOMV210Format \
    --output-path $round  

Code above will round your table. Or use R or any other tool for rounding the table, it is just an example.

1 Like

Thank you so much!

For some reason I couldn't get jupyter notebook to open, but I ran the cell as a python script through the terminal, and it seems to have created the round table that can successfully create effect plots using aldex2!

1 Like

Great, constantly using Jupyter I forgot that one can run Python scripts via the terminal :man_facepalming: =). Glad it worked!

1 Like