I am using qiime2’s python API (version 2019.1) now and it’s pretty good. I am wondering if there is any way to convert pd.DataFrame back to metadata? Or I have to export the dataframe as .tsv file and reload the metadata again?
I just pass my metadata into the
from qiime2 import Metadata
meta_df = pd.read_csv('my_metadata.tsv', sep='\t').set_index('sample_id')
meta_q2 = Metdata(meta)
There are a couple of caveats. If you’ve been using the nifty pandas Categorical types to handle your data for ordinal stuff, QIIME will not be happy. I’m also not sure if it automagically casts your numbers, either, so I’d watch that.
Thank you Justine!! It works!!