Adding "equipment" to AnnData objects for neat addition of functionality

Hi all,

I am adding this topic because my colleague and I had this idea and I was wondering what the community’s suggestion would be for this.

In the creation of my ecosystem package I have added quite a few functions which would be really handy for the purposes of preprocessing/analysis if they were class methods rather than internal functions in the package. At first I was thinking of subclassing the AnnData object, but that would probably be at a heavy compatibility loss. Then I wondered if you could just temporarily add the functionality by adding class methods to already initialized AnnData objects (ie, ‘equip’ the methods to the object temporarily for the purposes needed at the time). Once the process that needed the extra functionality is done the AnnData objects can shed the extra functionality (equipment) and continue on as regular AnnData objects.

What are your thoughts on this? Please be as constructively critical as possible! I am new to the software dev space so maybe this issue is already addressed by some other routine practice I am unaware of.

Hey @MartinAlvarezKuglen,

Sorry about the late response! Conference + vacation season.

This sounds interesting, though I’m not quite sure what it would look like. Are there any APIs you use which do something similar? Examples would be very useful in explaining your idea here.

An alternative here would be to have pandas style extension methods.

Like this?

https://pandas.pydata.org/docs/development/extending.html