RGLab / ggcyto

Visualize Cytometry data with ggplot2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Legends and histogram fill behavior with altered limits

rwbaer opened this issue · comments

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 #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