You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Gene expression color legends and gene names #1913
I have two suggestions/questions about dot/matrix plots:
1- If standard_scale='var' is given, we can write Mean expression\nin group\n(min-max scaled) on the color legend to be more accurate about what is being displayed.
Hmm ok, I mean that'd work too, I guess this is more like the difference between programmer's view and practitioner's view 😄
This is definitely more flexible and cleaner in terms of API design, but if we imagine a notebook with e.g. five sc.pl.dotplot calls, wouldn't it be painful to write this for each call (and memorize)? There are two reasons I suggested set_figure_params
It already has all the tricks to make figures more publication-ready e.g. rasterization, Arial font etc.
Italicized gene names is likely going to be a session-wide (or project-wide) decision, where one would use it in all figures not just in one, which brings us to the importance of conciseness.
Last suggestion is like theme(axis_text_x=element_text(angle=90, hjust=1)) kind of argument but rotation=90 also works 😃 Anyway, my two cents, happy with any option that achieves this, the community will appreciate it I think.
if we imagine a notebook with e.g. five sc.pl.dotplot calls
To me, italicizing the genes is more of a "customizing plots for publication" than "looking at data", so I think it's okay for it to have some extra steps as it happens less often. I personally have used illustrator for this kind of step. Alternatively, I tend to have functions like:
defcustomized_dotplot(adata, ..., dotplot_kwargs={}):
... # Preprocess data, maybe add some fieldsret=sc.pl.dotplot(adata, show=False, ..., **dotplot_kwargs)
... # do additional things
That said, I'm not against also having a global config for it, I would just want to see the structure for handling this global config for extra setting options sketched out in more detail. Also a PR implementing it 😉.
Last suggestion is like theme(axis_text_x=element_text(angle=90, hjust=1))
I do think it would make sense to have this outside of set_figure_params. set_figure_params does some global setting through the matplotlib config. Were you thinking of this as DotPlot(...).theme(...) or sc.settings.theme(...)? Maybe both, with the method overriding the config?
I don't really like that set_figure_params modifies plots not generated by scanpy
matplotlib doesn't have a concept of the "variable axis", so we'd have to handle this ourselves.
To me, italicizing the genes is more of a "customizing plots for publication" than "looking at data", so I think it's okay for it to have some extra steps as it happens less often. I personally have used illustrator for this kind of step.
I disagree very much :) First of all I didn't say that these 10 dotplots are for "looking at data," most of them are indeed for a paper (we can count the number of dotplots in sc papers, if we want to have a more accurate estimate of the time cost) and all of them need to be edited in a pdf editing software. Once the preprint is out, I can write in this post which dotplots I am talking about, how many there are in reality and how much time it took us to manually edit such minor things that can be easily addressed in the plotting code 😄
What we are discussing is maybe a minor thing here, but if we can minimize the dependency on Illustrator (which is a pricey proprietary software with a highly unintuitive interface in my very subjective opinion) to make publication-ready figures, I think it's a HUGE plus for the community. I think this is related to the philosophy of scanpy. To sum it up in a broader context, I think enabling people to have high-quality, publication-ready figures without mastering matplotlib and/or Illustrator must be one of the top items of the scanpy constitution :)
I know many colleagues who already nicely memorized the entire scanpy API but asking them also to know bits and pieces of a beast like mpl might be too much IMO. Based on your final suggestion, I can imagine myself trying to remember "Was it var_ticklabels_kwargs={"fontstyle": "italic"} or var_ticklabels_kwargs={"font_style": "italic"} or var_ticklabels_kwds={"fontstyle": "italic"} or ticklabels_var_kwargs={"fontstyle": "italic"} etc. I even spend 45 seconds everyday to remember this damn thing here plt.rcParams["figure.figsize"] :)
I don't really like that set_figure_params modifies plots not generated by scanpy
I totally understand this from the coding and engineering perspective, very ugly and violates several principles of good design. But on the other hand, it makes the life of many practitioners easier by setting the plotting config early on in a "Scanpy notebook session", which is clearly created to do research on single-cell genomics with scanpy, without rerunning things several times. For example, I use plotnine sometimes for publications too, but I hate writing theme(text=element_text(family='Arial')) every time I make a figure. plotnine is a general-purpose plotting library so it's not their problem, but people use Scanpy for both data exploration AND publications. So I think we can do better than that.
Activity
ivirshup commentedon Jul 1, 2021
Relevant discussion for 1.: #1757
For 2., I believe this is currently possible like this:
But this is a pain.
Should we just be splatting a passed dict into
dot_ax.set_xticklabels?gokceneraslan commentedon Jul 1, 2021
Cool, totally forgot about it.
That would be much more convenient, absolutely. How would the API look like e.g.
sc.pl.dotplot(pbmc, ..., gene_font_style='italic')?gokceneraslan commentedon Jul 1, 2021
or
set_figure_params(gene_font_style='italic'), which changes it in all/most plots where gene names are written?ivirshup commentedon Jul 2, 2021
I was thinking more like:
With an internal:
gokceneraslan commentedon Jul 2, 2021
Hmm ok, I mean that'd work too, I guess this is more like the difference between programmer's view and practitioner's view 😄
This is definitely more flexible and cleaner in terms of API design, but if we imagine a notebook with e.g. five sc.pl.dotplot calls, wouldn't it be painful to write this for each call (and memorize)? There are two reasons I suggested
set_figure_paramsLast suggestion is like
theme(axis_text_x=element_text(angle=90, hjust=1))kind of argument butrotation=90also works 😃 Anyway, my two cents, happy with any option that achieves this, the community will appreciate it I think.ivirshup commentedon Jul 5, 2021
To me, italicizing the genes is more of a "customizing plots for publication" than "looking at data", so I think it's okay for it to have some extra steps as it happens less often. I personally have used illustrator for this kind of step. Alternatively, I tend to have functions like:
That said, I'm not against also having a global config for it, I would just want to see the structure for handling this global config for extra setting options sketched out in more detail. Also a PR implementing it 😉.
I do think it would make sense to have this outside of
set_figure_params.set_figure_paramsdoes some global setting through the matplotlib config. Were you thinking of this asDotPlot(...).theme(...)orsc.settings.theme(...)? Maybe both, with the method overriding the config?set_figure_paramsmodifies plots not generated by scanpygokceneraslan commentedon Jul 7, 2021
I disagree very much :) First of all I didn't say that these 10 dotplots are for "looking at data," most of them are indeed for a paper (we can count the number of dotplots in sc papers, if we want to have a more accurate estimate of the time cost) and all of them need to be edited in a pdf editing software. Once the preprint is out, I can write in this post which dotplots I am talking about, how many there are in reality and how much time it took us to manually edit such minor things that can be easily addressed in the plotting code 😄
What we are discussing is maybe a minor thing here, but if we can minimize the dependency on Illustrator (which is a pricey proprietary software with a highly unintuitive interface in my very subjective opinion) to make publication-ready figures, I think it's a HUGE plus for the community. I think this is related to the philosophy of scanpy. To sum it up in a broader context, I think enabling people to have high-quality, publication-ready figures without mastering matplotlib and/or Illustrator must be one of the top items of the
scanpy constitution:)I know many colleagues who already nicely memorized the entire scanpy API but asking them also to know bits and pieces of a beast like mpl might be too much IMO. Based on your final suggestion, I can imagine myself trying to remember "Was it
var_ticklabels_kwargs={"fontstyle": "italic"}orvar_ticklabels_kwargs={"font_style": "italic"}orvar_ticklabels_kwds={"fontstyle": "italic"}orticklabels_var_kwargs={"fontstyle": "italic"}etc. I even spend 45 seconds everyday to remember this damn thing hereplt.rcParams["figure.figsize"]:)I totally understand this from the coding and engineering perspective, very ugly and violates several principles of good design. But on the other hand, it makes the life of many practitioners easier by setting the plotting config early on in a "Scanpy notebook session", which is clearly created to do research on single-cell genomics with scanpy, without rerunning things several times. For example, I use plotnine sometimes for publications too, but I hate writing
theme(text=element_text(family='Arial'))every time I make a figure. plotnine is a general-purpose plotting library so it's not their problem, but people use Scanpy for both data exploration AND publications. So I think we can do better than that.