Skip to content

allowing dotplot to use two variables in groupby as x and y axis - #2055

Open
zhangguy wants to merge 6 commits into
scverse:mainfrom
zhangguy:dotplot2d
Open

zhangguy wants to merge 6 commits into
scverse:mainfrom
zhangguy:dotplot2d

Conversation

@zhangguy

Copy link
Copy Markdown

Hi,

This is for #1876
I added a new variable groupby_expand to dotplot and baseplot to allow the function using two variables from groupby as x and y axis.
Thanks.

@codecov

codecov Bot commented Nov 20, 2021 •

Copy link
Copy Markdown

Codecov Report

Merging #2055 (2b9f519) into master (48cc7b3) will decrease coverage by 0.73%.
The diff coverage is 28.00%.

@@            Coverage Diff             @@
##           master    #2055      +/-   ##
==========================================
- Coverage   71.74%   71.01%   -0.74%     
==========================================
  Files          92       92              
  Lines       11255    11292      +37     
==========================================
- Hits         8075     8019      -56     
- Misses       3180     3273      +93     
Impacted Files Coverage Δ
scanpy/plotting/_matrixplot.py 91.17% <22.22%> (-6.70%) ⬇️
scanpy/plotting/_dotplot.py 82.97% <26.31%> (-4.20%) ⬇️
scanpy/plotting/_baseplot_class.py 81.94% <31.81%> (-2.53%) ⬇️
scanpy/tools/_louvain.py 20.21% <0.00%> (-40.66%) ⬇️
scanpy/plotting/_tools/paga.py 66.92% <0.00%> (-4.07%) ⬇️
scanpy/tools/_draw_graph.py 71.42% <0.00%> (-1.79%) ⬇️
scanpy/preprocessing/_highly_variable_genes.py 94.24% <0.00%> (-0.53%) ⬇️
scanpy/external/pp/_scrublet.py 91.35% <0.00%> (ø)
scanpy/_metadata.py 76.00% <0.00%> (+1.00%) ⬆️

- made groupby_expand and categories_order compatib
@ivirshup

ivirshup commented Dec 6, 2021

Copy link
Copy Markdown
Member

Thanks for the PR!

While I like the idea of being able to be more flexible around how the dot plots are made, I'm not sure I like the idea of adding more argument specific behavior. That is, I don't like that passing a boolean flag changes the meaning of the values for the var_names and groupby arguments. E.g. the group_by is the selection of obs corresponding to the plots rows, while var_names was the variable for the columns.

What could maybe be done instead is to have an argument for column grouping. Instead of

sc.pl.dotplot(adata, var_names='C1QA', groupby=['louvain', 'sampleid'], groupby_expand=True)

It could be more like

sc.pl.dotplot(adata, var_names='C1QA', group_by='louvain', group_cols='sampleid')

I would ideally like a solution here to work for all the other "grouped plots" as well.

I'll write a bit more about this in the parent issue.

zhangguy and others added 3 commits December 22, 2021 15:27
…baseplot.

- added 'col_groups' to _matrixplot.
- If given col_groups, dotplot and matrixplot will use this variables or combo of variables as the x axis.
@codecov

codecov Bot commented Apr 8, 2023 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 28.00000% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.69%. Comparing base (7fc56a5) to head (744580d).
⚠️ Report is 586 commits behind head on main.

Files with missing lines Patch % Lines
scanpy/plotting/_baseplot_class.py 31.81% 15 Missing ⚠️
scanpy/plotting/_dotplot.py 26.31% 14 Missing ⚠️
scanpy/plotting/_matrixplot.py 22.22% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2055      +/-   ##
==========================================
- Coverage   71.87%   71.69%   -0.19%     
==========================================
  Files          98       98              
  Lines       11496    11538      +42     
==========================================
+ Hits         8263     8272       +9     
- Misses       3233     3266      +33     
Files with missing lines Coverage Δ
scanpy/plotting/_matrixplot.py 91.08% <22.22%> (-6.77%) ⬇️
scanpy/plotting/_dotplot.py 82.91% <26.31%> (-4.21%) ⬇️
scanpy/plotting/_baseplot_class.py 81.98% <31.81%> (-2.52%) ⬇️

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants