Produce clonotype abundance barplot based on ir.pl.group_abundance by order of normalised abundance

Dear scirpy community,
I am using the following script to produce a barplot showing the normalised abundance of 25 clonotypes, but I have realised these are not the top most abundant (normalised) ones. How can I ensure that the plot includes only the top most abundant? I appreciate any help in the right direction.
Thank you

fig= ir.pl.group_abundance(
    mdata,
    groupby="airr:clone_id",
    target_col="gex:Group",
    max_cols=25,
    normalize="gex:Sample",
)

Hi Diana,

I’m afraid this is currently not possible using the pl.group_abundance function. I’m working on an improved wrapper to make barplots in Refactor group_abundance by grst · Pull Request #463 · scverse/scirpy · GitHub.

For now, you can just use the corresponding tool function tl.group_abundance and retreive a pandas data frame with the values. Then you can filter and plot it as you like.

Thank you for your prompt response. I am seeking some direction on ensuring that the data accurately reflects the normalisation produced by ir.pl.group_abundance. I am using ‘Sample’ as the reference variable for normalisation.

To give you a clearer picture, here is the script I have been using:

ir.tl.group_abundance(mdata, groupby="airr:clone_id", target_col="gex:Group", fraction=True, sort='count')

Could you please advise on how to adjust the script to achieve correct normalisation so I can sort by normalised values?

I greatly appreciate any help you could provide.

Best,
Diana

ok, I can see that this is poorly documented. Instead of fraction=True, you can pass fraction="gex:Sample" to tl.group_abundance.