Metadata Index Error

Great question!

You have a few options:

  1. You could make the ID change at the import step — you could either rename the fastq.gz file (or files, if PE), or use one of the manifest formats to assign the new ID. This would probably be a bit of a pain, since it basically requires you to start over.
  2. You could export your feature table, which would give you the BIOM file — then you could do what you proposed above with the “classic otu,” then re-import the feature table. This might be the easiest option, especially if you are comfortable with biom, but it does “interrupt” your provenance tracking, which may or may not be of concern to you (any time you export/import, QIIME 2 isn’t able to keep track of these data).
  3. Use some existing QIIME 2 functionality to reindex!

a. First, create a new metadata column in your metadata file with the new sample IDs (I am just prefixing your existing IDs, for illustrative purposes):

#SampleID    ...   country    group   ...   SampleID-new
...
HS                                          sHS
NA                                          sNA
NI                                          sNI
PX                                          sPX
...

b. Next, we can use feature-table group to “hack” new sample IDs into place — basically we will “regoup” the feature table using our new SampleID-new column - because we aren’t creating new metadata groups (because the values here are still unique identifiers), we effectively just reindex our existing table. This means that the mode we specify can be anything, because we aren’t combing samples in any way, just remapping their IDs, so I will use sum for this example. Neat! :tada:

$ qiime feature-table group \
  --i-table table.qza \
  --p-axis sample \
  --m-metadata-file sample-metadata.tsv \
  --m-metadata-category SampleID-new \
  --p-mode sum \
  --o-grouped-table reindexed-table.qza

c. Now that the table has been reindexed, update your metadata to match the new IDs, and drop the unnecessary column:

#SampleID    ...   country    group   ...
...
sHS
sNA 
sNI
sPX
...

d. As a final check to make sure things worked out, you can summarize your feature table:

$ qiime feature-table summarize \
  --i-table reindexed-table.qza \
  --m-sample-metadata-file sample-metadata.tsv \
  --o-visualization reindexed-table.qzv

When you view that, you should see your new sample IDs in the sample summary!

Option 3 looks like a lot, but I just ran through the exercise with the Moving Pictures tutorial dataset and it took about 2 minutes (the longest part was creating a new metadata column). Hope that helps, and let us know if you get stuck or have any questions! :balloon: