DillonHammill / CytoExploreR

Interactive Cytometry Data Analysis
60 stars 13 forks source link

Is there a built in function similar to facet_grid? #145

Closed MaxSchwiening closed 2 years ago

MaxSchwiening commented 2 years ago

Hi, I am new to CytoExploreR and I was wondering if there is a built in function similar to facet_grid to easily arrange plots? To create something similar to the example below where I have a number of CRISPR clones and each one has a treated and untreated sample. CRISPR KO PERK CHO Screen XBP1 Hist Thanks for your help

DillonHammill commented 2 years ago

@MaxSchwiening, cyto_plot() will do this automatically for you. You will need to add a Treatment variable to the cyto_details() of your samples to make things easier for you:

# interactively add a Treatment column - fill with Y or N
cyto_details_edit(gs)

Then you can use the select argument to pull out specific samples that you want to plot in the bottom layer. If you supply a single channel it will create a histogram automatically.

cyto_plot(
  gs,
  select = list(Treatment = "N"),
  parent = "root",
  channels = "PE-A"
)

Now we just need to overlay the treated samples. To do this we need to extract the data for the relevant samples and pass this through the overlay argument:

# Treated samples - called cs
cs <- cyto_extract(
  gs,
  select = list(Treatment = "Y")
)
# overlay treated samples
cyto_plot(
  gs,
  select = list(Treatment = "N"),
  parent = "root",
  channels = "PE-A",
  overlay = cs
)
MaxSchwiening commented 2 years ago

Thank you very much for the response. Worked great!