This one made me scratch my head a lot but we found the solution so I thought I would post it here in case it helps anyone else.
The phenotype was that Maaslin2 would crash at the LM step:
2023-08-11 09:44:01.647892 INFO::Running selected analysis method: LM
Error in seq_len(ncol(features)) :
argument must be coercible to non-negative integer
In addition: Warning messages:
1: In min(x[x > 0]) : no non-missing arguments to min; returning Inf
2: In seq_len(ncol(features)) :
first element used of ‘length.out’ argument
I found that I could solve it by removing exactly 16 lines in my metadata file but did not understand why. Tom pointed out that the actual problem was that the bug input file had quite a lot of NA in it, so those 16 samples were causing errors due to being all NA and not getting filtered out elsewhere. Replacing all NA with 0 in the bug abundance file fixed this problem.
Posting here in case this is useful for anyone else who encounters this error. It had me scratching my head for quite a while.