-
Notifications
You must be signed in to change notification settings - Fork 2
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
Update UMAP faceting code #644
Conversation
…he default level of wrapping plays well with the legend position
…ich does not load dplyr
…nly never going to happen though
Can we add back |
Related to this: I think you want a bit of code to determine the height of these figures based on the # of cell types. (I think maybe that is why you got out of square?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these changes look good to me. I'm fine without the aspect ratio, because when I had it I was seeing some really small UMAPs that didn't look good. I think the scenarios where we have long cell type names > 35 characters is minimal too. But feel free to test it out.
Thanks for reminder about aspect ratio @jashapiro! Let me play around with this and height...
(edit) Both* of the attached reports had this scenario - some of the singler cell type names are reaaallly long. |
All the UMAP chunks have height/width of 9, and cellassign + singler both had the same number of cell types (n=8). So, I think it's a product of the strip taking up 2 lines? |
I would agree that I don't think it's worth it and I think you could leave it the way it is. The only other thing I would suggest if you really want to change it is just setting the figure height and width based on the number of cell types. |
This is because you kept the bottom right positioning though, right? If the legend were positioned by the top left corner, it would fix this, wouldn't it? |
I actually think keeping the aspect ratio fixed is pretty important, otherwise you get skewing between different plots. |
I was specifically thinking of submitter plot where you only have 6. It becomes too long, so those aren't square. |
Ok, I think I've gotten there -
All of them look - |
Next up, going to modify figure size params. |
I think setting size conditionally is a bit of a pain because we have to both contend with whether the legend is inset or on the bottom, as well as the number of cell types. So before I launch into that, what if we just move to 8x8 all around instead of 9x9...? Just make things a little less domineering. For example - |
You can do it in one case statement, something like:
But maybe still not worth it. |
Getting closer (arrived?). Found a bug too for n=2 while exploring - legend has to be on the bottom here, since even though ncol = 3, there won't be a 3rd panel! I also killed the legend for n=1. Reports for each N<=6 (see submitter UMAPs): 1-submitter.html.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My biggest comment is that the 8x8 doesn't look square to me. I would go back to 9x9 as the default so we have square UMAPs, at least in the case of cell type labels that are not on the longer end.
legend.text = element_text(size = rel(0.85)), | ||
aspect.ratio = 1 | ||
) | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you just add a comment here that this is specifically for when n = 2 that because we have < 3 columns, we need the legend on the bottom?
Maybe another comment for each of the if
conditions would be helpful to say why each decision was made here.
templates/qc_report/celltypes_qc.rmd
Outdated
n_celltypes <= 3 ~ 4, | ||
n_celltypes <= 5 ~ 6, | ||
n_celltypes <= 6 ~ 7, | ||
.default = 8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are you setting width? I think we want it to be square and they are not square right now, even if they don't have long cell type names.
I think I would go back to the default being the 9x9.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are you setting width?
I just kept it fixed at 8; because of the aspect ratio, the whole space should only be taken up if needed, is what I saw while exploring. But will bump to 9 and explore a bit more!
…rmine both width and height together
I have explored much more!
Here's a set of reports across number of cell types: reports-across-ncelltypes.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused as to why you don't like sticking with making each plot 3x3 so the default is 9x9? Is something not looking right? Because the plots used to look much more square then they do now.
I think the problem is me 😬 ! I'm sure I've been focusing more on overall size than overall squareness... I'll do another round shortly! |
Noting that I downloaded a ruler app which actually works really well, and I measured all the panels for different N's. Each panel is indeed square; |
Co-authored-by: Ally Hawkins <54039191+allyhawkins@users.noreply.github.com>
Co-authored-by: Ally Hawkins <54039191+allyhawkins@users.noreply.github.com>
Some images for your perusal @allyhawkins, let me know how you feel about these dimensions: 9"x9" for 3x3 grids, with and without wrapped labels.Three versions of a 5-facet plot:8"x7" (WxH)9"x7" (WxH)9"x6" (WxH) |
Yup, that's the culprit! It's the labels.
It seems like we do for overall consistency across all report UMAPs. I'll set those width/heights! edit see next comment! |
Oh wait actually, the positioning is actually fixable - I was wrong about the wrapping being the culprit, it's the fact that there aren't three rows. I think it's ok to add another |
Ok, how does it look?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the 🎢, but looks good to me!
never apologize for making me stay in |
…p-legend Update UMAP faceting code
Closes #637
This PR cleans up legend placement and makes associated changes for the faceted UMAPs where we highlight 1 cell type in each facet. Here's an overview of the changes:
mutate()
altogether since I think that's a bit more legible.fct_lump()
, we lost our original factor order and levels became alphabetical. Now, we are back to ordering by frequency, with "Unknown cell type" and "All remaining cell types" as the last two levels%%3
anyways for determining legend placement, but there is still only 1if
statement so I think it's fine that I did that thing! I also covered the case of 1 cell type, which really should realistically never happen (the only circumstance I can think of is a method totally fails and assigns everything as unknown), but again, there's only 1if
:)facet_wrap()
which seemed a little safer to code explicitly given the legend placement choicesdplyr::
had to be added into the umap function as described in this commit - 3fa66d0Here are two rendered celltype reports:
Without submitter: celltypes_supplemental_report-no_submitter.html.zip
With (fake) submitter (where there are N=6 submitter cell types): celltypes_supplemental_report-with_submitter.html.zip