Skip to content
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

Legends and histogram fill behavior with altered limits #84

Open
rwbaer opened this issue Feb 20, 2022 · 0 comments
Open

Legends and histogram fill behavior with altered limits #84

rwbaer opened this issue Feb 20, 2022 · 0 comments

Comments

@rwbaer
Copy link

rwbaer commented Feb 20, 2022

I am looking at marker expression level after phenotypic alteration of macrophages. In using ggcyto() to try and display my (arcsinh transformed) data, I've come across two issues related to fill: 1) at certain limit values on both the high and low end, the fill of one of my faceted panels disappears; and 2) I've been unable to find a method to display a legend for the filled histograms. Normal ggplot() work-arounds for manual legends seem to be failing me with ggcyto().

  • The first seems to be a bug? The logic of where the cutoff breaks the fill behavior is so far escaping me.
  • The second may just be me needing help. Is there a workaround for adding legend for visit number? The legend aspect of this issue has overlap with issue geom_overlay - legend labels + stacked overlays #71

Here is a repex with the GvHD data:

library(CytoExploreR)
library(ggcyto)
data("GvHD")
fs <- GvHD[subset(pData(GvHD), Patient %in% 5:7 & Visit %in% c(1:5))[["name"]]]
gs = GatingSet(fs)

### arcsinh transform
transList <- cyto_transformer_arcsinh(gs)
gsTrans = cyto_transform(gs, trans = transList)

p = ggcyto(gsTrans, subset = "root", 
             aes(x = `FL2-A`,  color = Patient, fill = Visit),
             limit = "instrument") +
  geom_density(alpha = 0.2) +
  labs(title = "Different Visits", x = "FL2-Height (arcsinh)") +
  facet_wrap( ~ Patient) 


p
p + axis_x_inverse_trans() 
p + axis_x_inverse_trans() + ggcyto_par_set(limits = "instrument")
p + axis_x_inverse_trans() + ggcyto_par_set(limits = "data")
p + axis_x_inverse_trans() + ggcyto_par_set(limits = list(x = c(-.5, 1.0), y = c(0, 15)))       #  filled as expected
p + axis_x_inverse_trans() + ggcyto_par_set(limits = list(x = c(-.5, 0.1), y = c(0, 15)))       # issue with right panel
p + axis_x_inverse_trans() + ggcyto_par_set(limits = list(x = c(0.2, 1.0), y = c(0.2, 15)))    # issue with left panel

EDIT: With my own gating set, I have seen this same "lack of fill" issue with limits = "instrument" as well. It is not solely a function of using the list() version of ggcyto_par_set(limits =). In that case (which prompted this report), all histogram modes are fairly well centered in the view. This is not as easy to share as reproducible, but I'll add the figure to the bottom.

right
left
instrument_fill_issue

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

No branches or pull requests

1 participant