NKInstinct / flowGate

Other
3 stars 1 forks source link

ggplot2-related error: legend.text.align not defined during Shiny opening + idea of feature #8

Open PaulRegnier opened 7 months ago

PaulRegnier commented 7 months ago

Hello Andrew,

I am the developer of the PICAFlow R package (https://github.com/PaulRegnier/PICAFlow) which basically serves as an all-in-one processing and analysis package for flow/mass cytometry data. Long story short, I discovered your flowGate package at the end of the past year and decided to implement your package in PICAFlow to interactively draw gates on samples.

It was working like a charm until I tried again today after a long period without analyzing cytometry data, and realized that your Shiny application was not showing the graph (through your gs_gate_interactive() function).

The R Shiny application actually opened but a red message showed up which complained that the legend.text.align parameter was not defined. This seems to be related to ggplot2. I remembered that ggplot2 got some huge updates in the past weeks/months, so that could be linked. I had to correct a bunch of other functions (unrelated to PICAFlow) which showed similar errors recently.

Nonetheless, I finally managed to fix this strange bug by adding the following code into your theme_flowGate variable (right after the line 75 of the preparePlot.R file, from the latest Bioconductor version): , legend.text = ggplot2::element_text(hjust = 0.5)

Would you mind to implement this line of code, quickly test it and eventually push it to the Bioconductor repository?

Thank you again for your kind help and again congratulations for flowGate, I really like it :)

NB: I also have a suggestion for you to implement in flowGate, but this is not urgent at all. Actually, it would be very useful if one could directly specify in the arguments of the gs_gate_interactive() function what manual X/Y limits we want to use. To illustrate, in PICAFlow, I allow users to draw a global gate using the first sample of the flowset, but afterwards I also allow users to draw specific gates for some samples if they are very different from the template sample. So I iterate over the samples to re-gate, but users must every time reset the manual X/Y limits even if they are the same for the samples to re-gate. What do you think of this?

Biomiha commented 7 months ago

@PaulRegnier does changing theme_flowGate work for you? I've tried sourcing your bug fix but still get the same error message.

PaulRegnier commented 7 months ago

Hello @Biomiha ,

Yes it works! In addition to what I wrote in my first message regarding the Bioconductor release of flowGate, I realized that the flowGate GitHub fork I made also works, so you need to make sure that the right version of the package is installed, at least until the maintainer of flowGate actually incorporates this fix.

image

If you don't know what version is used, then I suggest you to manually remove the package flowGate from your library, then force the installation from the flowGate fork I made:

library("devtools")
install_github("PaulRegnier/flowGate", force = TRUE)

Then load PICAFlow and it should work.

Biomiha commented 7 months ago

That works, thanks!