Closed giovp closed 3 years ago
Re converting .ipynb
to .py
: I found that I need to specify that I want to use the sphinx
format to get correct results. Otherwise the cell blocks are marked by #+
and #-
which seems not to work in the docs. Using
jupytext --to py:sphinx mynotebook.ipynb
uses the valid cell block marker ###########################
.
Edit: updated to use sphinx instead of percent format.
Hey Guys. Just to clarify what's the final format for the py blocks?. Default or percent (using --to py:percent
)?. Just confirm and/or link to parsed example.py.
Hey Guys. Just to clarify what's the final format for the py blocks?. Default or percent (using
--to py:percent
)?. Just confirm and/or link to parsed example.py.
The py file needs to be in a format readable by sphinx gallery: https://sphinx-gallery.github.io/stable/syntax.html
This means using either #%%
or #########################
as marker for text cells.
After trying out several examples, I've come to the conclusion that using the percent
format is not enough, as sometimes code cells seem to be represented wrongly in the docs. Using the sphinx
format, however, works. This will use lines like this ###############################
to mark text cells. Sorry for the confusion, I'm also very new at this.
TL;DR: use:
jupytext --to py:sphinx mynotebook.ipynb
closed with #46
Hi All!
Here's a brief list of examples that we need to add to the repo. We'll really use your help to populate the example folder. Here's a description of the workflow to get you started.
Set up environemnt
git clone
most recent versions ofsquidpy
andsquidpy_notebooks
.squidpy
withpip install -e'.[dev,test]'
pre-commit install
in both reposPick one of the available dataset
Remember that only the visium datasets for the image functions. Also, don't use the 4i dataset for the
co_occurrence
example.sq.datasets.imc()
good for graphsq.datasets.seqfish()
good for graphsq.datasets.four_i()
good for graphsq.datasets.four_i()
good for graphsq.datasets.visium_fluo_adata()
good for graph and imagesq.datasets.visium_hne_adata()
good for graph and imagesq.datasets.visium_fluo_adata_crop()
good for graph and image (cropped)sq.datasets.visium_hne_adata_crop()
good for graph and image (cropped)sq.datasets.visium_fluo_image_crop()
good for image container (cropped)sq.datasets.visium_hne_image_crop()
good for image container (cropped)sq.datasets.visium_hne_image()
good for image container (cropped)Pick one of the available functions in the repo
graph
sq.gr.centrality_scores
andsq.pl.centrality_scores
sq.gr.nhood_enrichment
andsq.pl.nhood_enrichment
sq.gr.spatial_neighbors
sq.gr.ligrec
andsq.pl.ligrec
sq.gr.ripley_k
andsq.pl.ripley_k
image
(also have a look at #9 for existing image examples and let Hannah know if you start working on one of these.
sq.im.ImageContainer
data structure (loading, layers, etc)sq.im.ImageContainer.crop_corner
andsq.im.ImageContainer.crop_center
sq.pl.extract
sq.im.calculate_image_features
with segmentation features (I think this is already done - no, segmentation features are not yet covered)sq.im.process
with custom processing functionsq.im.segment
with custom segmentation function like pre-trained keras model?Create a new branch
ex_<module>_<fun>
for example
git checkout -b ex_gr_ligrec
Follow the existing examples as reference
An example consists of a short, two liners explanation of the function of interest. If the function also has a related plotting function, then that function need also to be used and briefly described. See examples for that, for instance in #13 or the beautiful ones in cellrank
Try to think like a user who has zero familiarity with python/coding, so try to be detailed regarding what the function does, and maybe some specific arguments (e.g. in
sq.gr.spatial_neighbors
what's the difference betweenradius
andrings
?). There is no need to "interpret biologically" the result, but the function usage needs to be clear.You can work on a jupyter notebook for that, but the files to be pushed needs as
.py
file. You can conveniently go back and forth withjupytext
(install it with pip).this makes it very easy to go back and forth!
Make sure that lines of text don't go over 120 characters (easy that this happens in text part). Also, pre-commit check will flag other potential problems for you. precommit can be painful, if you are struggling with understanding some flags, contact us directly (on MM or here or anywhere else) and we'll be happy to help.
Also, remember that the text part will be rendered with
rst
(notmd
) so checkout this cheatsheetYou can locally generate the docs to check that everything looks good:
tox -e docs
Open a new PR and ask us to review it !
Thank you!