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

Saving Misty model as .pkl #127

Open
Zach-Sten opened this issue Jul 22, 2024 · 3 comments
Open

Saving Misty model as .pkl #127

Zach-Sten opened this issue Jul 22, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@Zach-Sten
Copy link

Hello,

Not sure if this has been proposed yet but is there a way to save the model as a .pkl so that one could test data outside the training data set for performance? I was looking through the code but didn't see a way to save the full model directly.

@Zach-Sten Zach-Sten added the enhancement New feature or request label Jul 22, 2024
@dbdimitrov
Copy link
Collaborator

Hi @Zach-Sten, you're right this is currently not possible. But I see your point how it can be useful.

Are you more interested in the multi-view or the single-view models? Also, there would be many models (essentially an individual model is fit per target), so I might need to think about how to export them to be somewhat manageable.

Just out of interest, why do you want to check the performance of an inference method outside of training data? I mean besides the obvious whether it's not overfit etc, what is your specific application in mind? :)

@Zach-Sten
Copy link
Author

Hello,

We're mostly interested in the multi-view model because it pulls together information from different data views. However, the single-view models could also be helpful, so we’d like to keep them too. We are also not sure how to do this efficiently and not save so many individual files for every target haha.

Our main goal was to see how much the model is overfitting. but on top of that, we want to see how well it can act as a classifier. We're currently trying to use MISTy to pinpoint unique spatial features within sample groups (individual tissue cores which we set as our intra view) from Xenium data. Specifically, we're looking at which spatially co-localized receptor-ligand interactions set apart disease progressors from non-progressors.

What are your thoughts? Do you think this is appropriate use of the tool? If you have any recommendations on how to better reach our analysis goals that would be awesome.

@dbdimitrov
Copy link
Collaborator

dbdimitrov commented Jul 24, 2024

Hi @Zach-Sten, thanks for the info.

If you are interested in multi-views then Misty fits well.

If you want to see specific tissue cores (regions), perhaps the recent extension of misty - Kasumi - is a better fit. In Kasumi, @jtanevski essentially uses misty modeling but over a series of sliding windows (similar to convolution). This might also be a bit more powerful as a technique to set apart sample groups.
This is currently only in the R version of MISTy and @jtanevski can point you to a vignette. :)

If you are specifically interested in ligand-receptor interactions, how MISTy would work for those is a bit unorthodox, since it considers all possible interactions between features marked as ligands and receptors - i.e. it would consider ligand-receptors which are not necessarily known to interact.

An alternative would be the bivariate metrics of LIANA+, which are a bit simpler and essentially calculate ligand-receptor interactions for each spot/cell in a slide. When combined with dimensionality reduction these can also be used to classify sample groups, and in the LIANA+ paper (Fig3A-G), we have used them to identify fibrosis-related patterns with NMF. It's very much the same application as in the tutorial, except I concatenated all samples after calculating the bivariate scores, and used the concatenated anndata object for NMF.
I've also tried a very similar approach but instead of NMF, using archetypal analysis after batch integration.

Hope this helps :)

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

No branches or pull requests

2 participants