Skip to content

Plotting examples - #1632

Merged
fidelram merged 10 commits into
scverse:masterfrom
ivirshup:plotting-examples
Feb 18, 2021
Merged

fidelram merged 10 commits into
scverse:masterfrom
ivirshup:plotting-examples

Conversation

@ivirshup

@ivirshup ivirshup commented Feb 9, 2021 •

Copy link
Copy Markdown
Member

Re #1604, @fidelram, I've got the sphinx extension working for examples (at least locally) here. You can check out a simple example for sc.pl.embedding.

Does this solve the problem you were running into?

Functions which need examples

Functions in sc.pl

  • Embedding plots
    • sc.pl.embedding
    • sc.pl.draw_graph
    • sc.pl.diffmap
    • sc.pl.pca
    • sc.pl.tsne
    • sc.pl.umap
    • sc.pl.spatial
    • sc.pl.embedding_density
  • PCA specific
    • sc.pl.pca_loadings
    • sc.pl.pca_overview
    • sc.pl.pca_scatter
    • sc.pl.pca_variance_ratio
  • PAGA
    • sc.pl.paga
    • sc.pl.paga_adjacency
    • sc.pl.paga_compare
    • sc.pl.paga_path
  • DPT pseudotime
    • sc.pl.dpt_groups_pseudotime
    • sc.pl.dpt_timeseries
  • Groupby
    • sc.pl.dotplot
    • sc.pl.matrixplot
    • sc.pl.clustermap
    • sc.pl.heatmap
    • sc.pl.dendrogram
    • sc.pl.stacked_violin
    • sc.pl.tracksplot
    • sc.pl.violin
  • Preprocessing
    • sc.pl.filter_genes_dispersion
    • sc.pl.highest_expr_genes
    • sc.pl.highly_variable_genes
  • DE
    • sc.pl.rank_genes_groups
    • sc.pl.rank_genes_groups_dotplot
    • sc.pl.rank_genes_groups_heatmap
    • sc.pl.rank_genes_groups_matrixplot
    • sc.pl.rank_genes_groups_stacked_violin
    • sc.pl.rank_genes_groups_tracksplot
    • sc.pl.rank_genes_groups_violin
  • Misc/ to be classified
    • sc.pl.ranking
    • sc.pl.scatter
    • sc.pl.sim
    • sc.pl.correlation_matrix
    • sc.pl.matrix
  • Time series (???)
    • sc.pl.timeseries
    • sc.pl.timeseries_as_heatmap
    • sc.pl.timeseries_subplot

Other functions

  • sc.pp.calculate_qc_metrics
  • sc.tl.embedding_density
  • sc.get.obs_df
  • sc.get.rank_genes_groups_df

@ivirshup

ivirshup commented Feb 9, 2021

Copy link
Copy Markdown
Member Author

Example of what the dotplot docs look like (locally) once this is working:

image

Does make that bbox_inches="tight" option seem important.

@ivirshup
ivirshup force-pushed the plotting-examples branch 2 times, most recently from 88dc259 to b83d444 Compare February 9, 2021 08:04
@fidelram

fidelram commented Feb 9, 2021 •

Copy link
Copy Markdown
Collaborator

@ivirshup This looks great! Thanks. The issue with the cropping of the labels is quite annoying and indeed bbox_inches="tight" should help. However, I don't think is nice to add that line for each example, but, on the other hand, if we add this to the scanpy code, many figures will be affected and would need to be updated.

The same issue also affects the test images which most are cropped.

@ivirshup

ivirshup commented Feb 9, 2021 •

Copy link
Copy Markdown
Member Author

Update: Nvm, I figured this out. Tt had to do with qualname_overrides, which I've updated.

Old problem

@flying-sheep, weird sphinx bug I'm running into:

  • The readthedocs builds are failing after commit fc83ec3
  • The error is:
scanpy/scanpy/external/pp/_bbknn.py:docstring of scanpy.external.pp.bbknn:24: WARNING: py:class reference target not found: sklearn.neighbors._dist_metrics.DistanceMetric
  • The error will still occur as long as this has been added:
    .. plot::
        :context: close-figs

        >>> import scanpy as sc
        >>> adata = sc.datasets.pbmc68k_reduced()
        >>> sc.tl.umap(adata)
  • If I remove the sc.tl.umap line, the builds work fine, as sklearn.neighbors.DistanceMetric resolves and no warning is thrown.

For now, I'm going to remove the type annotation from sc.external.pp.bbknn, since it's causing the error. Any ideas why calling sc.tl.umap means sklearn.neighbors._dist_metrics.DistanceMetric can no longer resolve? I assume it has something to do with packages being imported in an unexpected order, but also this is real weird.

@ivirshup

ivirshup commented Feb 9, 2021

Copy link
Copy Markdown
Member Author

@fidelram

I don't think making a broader change would be so bad right now, especially if it deals with this issue. However, if there was a way to just fix the issue here specifically that would also be good.

Separate issue these examples raise:

It looks like the colormap is changing at some point when it shouldn't:

image

Any idea what's up with this?

@ivirshup

ivirshup commented Feb 9, 2021

Copy link
Copy Markdown
Member Author

For this PR, I'm thinking I'm going to wait on a response from @flying-sheep to figure out what to do about the sklearn intersphinx problem, then clean it up for a merge. A new issue will be opened up with all the functions that need examples, and those can be added through separate PRs as the release progresses.

@fidelram

fidelram commented Feb 9, 2021 •

Copy link
Copy Markdown
Collaborator

@ivirshup the color change is caused because of the way the defaults are used. This is an issue that has to do with the visualisation of defaults in the documentation.

When you add .style(....) as in the second case you report, the colormap changes to winter although it should stay as Reds. This happens because the method default value of cmap is winter. Ideally, it should be None in which case it can be decided if the colormap was already set or if a default is needed.

However, setting the default of the colormap to None removes the default information from the sphinx documentation.

We had some discussions with @flying-sheep on how to address this that are still pending but ideas on how to address this are welcome.

@ivirshup

ivirshup commented Feb 9, 2021

Copy link
Copy Markdown
Member Author

Is there an open issue for this colormap problem? If so, could you link it? I'd like to track it for at least 1.8.

@ivirshup
ivirshup marked this pull request as ready for review February 11, 2021 06:21
Comment thread docs/dev/documentation.rst Resolved
Comment thread scanpy/plotting/_tools/scatterplots.py Resolved
@fidelram

Copy link
Copy Markdown
Collaborator

So far looking good. Maybe we can add to the TO-DO list, to fix issue with the 'cropped' labels.

@ivirshup

Copy link
Copy Markdown
Member Author

I think this is ready to merge. After that, I'll open the meta-issue about adding examples to all the listed functions.

@fidelram
fidelram merged commit 0c4ca5b into scverse:master Feb 18, 2021
@ivirshup
ivirshup deleted the plotting-examples branch February 19, 2021 03:14
@ivirshup ivirshup mentioned this pull request Feb 19, 2021
38 of 56 tasks
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

Successfully merging this pull request may close these issues.

2 participants