DillonHammill / CytoExploreR

Interactive Cytometry Data Analysis
61 stars 13 forks source link

Allow multiple parents in one cyto_plot call #76

Closed northNomad closed 4 years ago

northNomad commented 4 years ago

Currently cyto_plot argument parent only takes one input.

I have yet to find a way to compare markerB expression in marker_A-HIGH vs marker_A-LOW cells in one cyto_plot call. Ie) cyto_plot cannot take two parents argument A-HIGH vs A-LOW

What do you think about making it so that users can allow cyto_plot to take multiple parent

DillonHammill commented 4 years ago

@northNomad, this is quite complex to implement in cyto_plot() directly so it is unlikely that this will be supported any time soon.

You can however, accomplish this with a little bit of coding. For example, you could split your GatingSet into groups based on your experiment variables and then make a call to cyto_plot() for each group and each parent:

# Split gs into groups
gs_groups <- cyto_group_by(gs, "name") # list of GatingSets

# parents
parents <- c("CD4 T Cells", "CD8 T Cells")

# Prepare plotting space
cyto_plot_custom(c(length(parents), length(gs_groups))) # parents by groups - c(nrow, ncol)

# Loop through groups and parents
lapply(names(gs_groups), function(group) {
  lapply(parents, function(parent) {
   cyto_plot(gs_groups[[group]], # GatingSet
             parent = parent,
             alias = "CD69+",
             channels = c("CD44", "CD69"),
             group_by = "all", # merge samples in group
             title = paste0(group, "\n", parent))
 }
}

# Signal plot is complete
cyto_plot_complete(c(1,1)) # reset grid dimensions to 1 x 1

Hope this helps!