RGLab / ggcyto

Visualize Cytometry data with ggplot2
MIT License
55 stars 13 forks source link

plot one channel against all other channels #24

Closed mikejiang closed 6 years ago

mikejiang commented 6 years ago

On 10/12/2017 12:48 AM, Dillon Hammill wrote:

Hi Mike,

I was just wondering whether we were able to plot one channel on the x axis against all other channels on the y axis using ggcyto?

For example if I have a single stain control for APC-A, I want to plot APC-A against all other fluorescent channels (on separate plots) to check fluorescent spillover and confirm that the compensation is correct.

I know that this possible with base graphics using transformed data (and for loops) but I would like to use ggcyto to visualise data without physical transformation (using scale_x_logicle etc.).

Thanks again for your help,

Dillon Hammill

Ph.D. Scholar

The Parish Group – Cancer & Vascular Biology

ACRF Department of Cancer Biology and Therapeutics

The John Curtin School of Medical Research

ANU College of Medicine, Biology and the Environment

The Australian National University

Acton ACT 2601

+61 (02) 61254716

Dillon.Hammill@anu.edu.au

mikejiang commented 6 years ago

You can simply create plots through loop and arrange them by grid.arrange (make sure convert the ggcyto object to ggplot through coerce function as.ggplot), Here is the example

dataDir <- system.file("extdata",package="flowWorkspaceData")
gs <- load_gs(list.files(dataDir, pattern = "gs_manual",full = TRUE))
fr <- getData(gs[[1]], "CD3+")

markers <- markernames(fr)
x <- markers[1]
objs <- lapply(markers[-1], function(y){
  p <- autoplot(fr, x, y)
  p <- p + labs_cyto("marker")
  p <- p + theme(legend.position="none", strip.background = element_blank(),strip.text.x = element_blank())
  as.ggplot(p)
})
gridExtra::grid.arrange(grobs = objs)

image