Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inverse normalizations #65

Open
quentinblampey opened this issue May 7, 2024 · 6 comments
Open

Inverse normalizations #65

quentinblampey opened this issue May 7, 2024 · 6 comments

Comments

@quentinblampey
Copy link
Contributor

It could be great to be able to inverse each of the normalization transformations.

When running normalization, we can store some attributes in adata.uns and then we can re-use them for the inverse transformation.

I have already implemented this for a few normalization functions in scyan, so I can do a PR if you find it interesting.

@mbuttner
Copy link
Collaborator

mbuttner commented May 7, 2024

I think that's a good idea. I think that keeping the parameters for normalization would also help to increase the interoperability of pytometry with FlowJo. Both tools have fairly different approaches when it comes to data transformation or normalization, but I think that keeping the parameters and implementing inverse normalizations is a step forward.

@quentinblampey
Copy link
Contributor Author

Great, I'll work on this!
I'll try to do a PR next week with inverse_asinh, inverse_logicle, and maybe inverse_biexp

@grst
Copy link
Collaborator

grst commented May 7, 2024

Certainly agree on storing the parameters in adata.uns for posteriority.

About the inverse transfromations, could you clarify when you need them instead of just keeping the untransformed data in an adata.layer?

@mbuttner
Copy link
Collaborator

mbuttner commented May 7, 2024

That's a great point.
By default, pytometry does not keep an untransformed version of the data right now, which is why it would make sense to me to implement inverse transformations. @grst has a point, though, and an alternative solution is to create a copy of the untransformed data in adata.layers for all normalizations and keep the normalization parameters for interoperability.
Given those two solutions, I would prefer @grst's suggestion.

@quentinblampey
Copy link
Contributor Author

I completely agree that keeping the untransformed data is better. Still, the inverse transformation can be used on batch corrected data, for which we don't have the untransformed values (for instance, after batch effect correction with Scyan). This way, we can visualize the corrected data in FlowJO.

But I agree that it's a very specific use case, and maybe a bad practice to do that anyway. So I'll only work on storing the parameters in adata.uns!

@grst
Copy link
Collaborator

grst commented May 8, 2024

Ok, then let's do it like that for now. If it turns out there are more broadly applicable use-cases we can still add inverse transformations later.

Related: in that case working with layers should become more convenient, e.g. all preprocessing functions should support storing the result in a separate layer. There are some ideas how the API for this could look like in scverse/anndata#706:

sc.pp.compensate(adata, in_layer="raw", out_layer="raw_compensated")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants