Humann_barplot sort

Hello everyone:

I am using humann_barplot to plot my result, when I use Group as metadata for sorting, it looks like graph and the X axis would be sort by alphabetical order.

for example, my input data table is like:


Then when i do this:
/opt/software/miniconda3/envs/humann3/bin/humann_barplot --input genefamilies.ko.rename.join.renorm.for_plot.no.BC.tsv --focal-metadata Group --last-metada
ta Group --output ./test.pdf --focal-feature K00010 --sort sum metadata --scaling logstack

The output graph is like:


The X axis and the legend are sorted by alphabetical order, but I want: SC, L, M, and H.

Anyone knows how to solve this problem?

I use humann_barplot --help to see --sort options, but still I can not solve this problem, the --sort option could be provided a file: Apply sorting order read in from a file. I wonder how to use it.

Hi, everyone, I solved this problem, by just adding a new metadata row, and group my sample as:
A to SC, B to L, C to M, and D to H.

Then I could plot it using this new metadata as sort metadata. Finally I could get the correct order in result graph. I could modified A, B, C, D to SC, L, M ,and H using Adobe Illustrator.

Thanks to everyone.

Wow, very clever you are

I can chime in that I usually do something similar by attaching numbers to the start of the category levels to force them to obey a certain order, e.g. 0_Control, 1_Fiber, 2_Apples, and so forth. This is also convenient for forcing the first group to act as the reference group in a lot of stats modeling software.

Thank you! This wonderful software helps me a lot!