Change Sample Order in Feature Table in R

Hi! I’ve run into what is sort of a minor issue, but is time consuming to fix in downstream analysis. When the feature table is output the samples are in alphabetical order instead of the order I input them in on my metadata file. My metadata file is in a specific order for dealing with downstream analysis in R. Is there any way to “force” the samples in the feature table into a matching order to the metadata file?

Thanks!
Alicia

Hi @reige012,
I am reclassifying this post as “other bioinformatics tools” and tweaking the title, because it sounds like your question pertains specifically to reordering a feature table in R, not in QIIME 2.

Q2 does not have any methods explicitly designed to reorder sample IDs in a feature table, though this should be pretty trivial in R (or in python if you use QIIME 2’s artifact API, export to a biom table, and use the biom-table API to reorder your table).

Good luck!

Thanks for your help. I knew there was likely a way in R, but I had hoped there was a simple QIIME2 command that I was missing so I wouldn’t have to code in R. I did get a code working and it wasn’t too difficult, but still more time consuming than I want it to bet since I’m not very literate in R. I still had to manually import a list of the sample names, exclude any that were rarefied out or didn’t make it through quality filtering, and then import the feature table as a data matrix and reorder. More steps than ideal and might be able to be condensed, but as mentioned I’m not great with R. Would be worth having something in Qiime2 that made sure the output matched the metadata file if that was possible.

Thanks!

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.