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

fix docstrings example stereoscope #959

Merged
merged 2 commits into from
Mar 1, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions scvi/external/stereoscope/_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class RNAStereoscope(UnsupervisedTrainingMixin, BaseModelClass):
Examples
--------
>>> sc_adata = anndata.read_h5ad(path_to_sc_anndata)
>>> scvi.data.setup_anndata(sc_adata, label_key="labels")
>>> stereo = scvi.external.RNAStereoscope(sc_adata)
>>> scvi.data.setup_anndata(sc_adata, labels_key="labels")
>>> stereo = scvi.external.stereoscope.RNAStereoscope(sc_adata)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be accessible from just scvi.external right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both scRNA and spatial

Copy link
Member Author

@giovp giovp Mar 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scvi.external
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-f706a22e0ee9> in <module>
----> 1 scvi.external

AttributeError: module 'scvi' has no attribute 'external'

my feeling (but might be wrong) is that you should import it explicitly here
https://github.com/YosefLab/scvi-tools/blob/9b9370aa502b308f84e3129a7c940a9bea06426b/scvi/__init__.py#L10

If I import external there, it works.

totally unrelated/unwanted request, and (very) minor pet peeve, but adding the '' to pip install -e .'[dev,tutorials]' would makes it easier for zsh users.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just committed the latter change you suggested.

I suppose that pattern we can use in the examples here is from scvi.external import RNAStereoscope

I think we just aren't 100% sure we want to import into the top-level yet, as we are still figuring out what external is to some extent. This is also consistent with what scanpy does.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whatever you think it's best, I actually like the idea of not having explicit imports, and just implicit import scvi in the examples. Let me know what to do.

btw also really cool that cellassign is already there! Is this the port of the original implementation in tensorflow or the more recent one in torch https://github.com/camlab-bioml/astir/ ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok we can leave it like you have it haha.

This is a port of the original implementation, except that we minibatch during inference where they do "full-batch" EM. We'll have a notebook soon showing consistency with their implementation. We'd be happy for you to try it out!

We also talked to the Astir team about using scvi-tools... stay tuned!

>>> stereo.train()
"""

Expand Down Expand Up @@ -130,14 +130,14 @@ class SpatialStereoscope(UnsupervisedTrainingMixin, BaseModelClass):
Examples
--------
>>> sc_adata = anndata.read_h5ad(path_to_sc_anndata)
>>> scvi.data.setup_anndata(sc_adata, label_key="labels")
>>> sc_model = scvi.external.RNAStereoscope(sc_adata)
>>> scvi.data.setup_anndata(sc_adata, labels_key="labels")
>>> sc_model = scvi.external.stereoscope.RNAStereoscope(sc_adata)
>>> sc_model.train()
>>> st_adata = anndata.read_h5ad(path_to_st_anndata)
>>> scvi.data.setup_anndata(st_adata)
>>> stereo = scvi.external.SpatialStereoscope.from_rna_model(st_adata, sc_model)
>>> stereo = scvi.external.stereoscope.SpatialStereoscope.from_rna_model(st_adata, sc_model)
>>> stereo.train()
>>> st_adata.obs["deconv"] = stereo.get_proportions()
>>> st_adata.obsm["deconv"] = stereo.get_proportions()

Notes
-----
Expand Down