MEGAN UE command line: select rank within subtree only

Hi!

I have been trying to select all families in ‘Bacteria’ in command line. I tried few things below but none produced satisfactory results. Help please!

uncollapse nodes=all;
collapse rank=Family;
select name=Bacteria;
select nodes=leavesBelow;
export what=CSV format=taxonName_to_count separator=tab counts=summarized file=’/family_com.txt’;

This selects not only “Family”, but also other terminal leaves. For example, if I have Cyanobacteria, but no assignments to any Cyanobacteria family, it will export Cyanobacteria as well.

uncollapse nodes=all;
select name=Bacteria;
collapse rank=Family;
select rank=Family;
export what=CSV format=taxonName_to_count separator=tab counts=summarized file=’/family_com.txt’;

This on the other hand, will export all families, including those for non-Bacteria.

Any suggestions are welcome; many thanks!

Best,
Rafal

Can you try this:

set keepOthersCollapsed=prokaryotes;
collapse rank=Family;
select rank=Family;
export what=CSV format=taxonName_to_count separator=tab counts=summarized file=’/family_com.txt’;

The keepOthersCollapsed=prokaryotes; statement should prevent export of non-prokaryotes (I’m hoping that you don’t mind archaea appearing in the output…)

Thanks a lot! Apologies for late reply, my trial key ran out and I finally got the license now.

Your solution works pretty well for bacteria, but works poorly for my next target, which is dikarya (selecting eukaryotes would include host assignments as well). Would there be any other more generalised ways for doing joint rank and taxon uncollapsing/selecting? Or would that already breach the realm of feature requests :slight_smile: ?

Many thanks for your help!

Best,
Rafal