Closed Biomiha closed 4 years ago
@Biomiha, this is what the select
argument is for. Either pass a vector of indices of samples to use or supply experimental parameters in a list. This will pull out and merge only the selected samples for plotting and apply the gate(s) to all samples.
# Use the first sample only
cyto_gate_draw(gs,
parent = "root",
alias = "Cells",
channels = c("FSC-A", "SSC-A"),
select = 1)
# Use a few samples only
cyto_gate_draw(gs,
parent = "root",
alias = "Cells",
channels = c("FSC-A", "SSC-A"),
select = c(1, 4, 6))
# Use Stim-A samples only
cyto_gate_draw(gs,
parent = "root",
alias = "Cells",
channels = c("FSC-A", "SSC-A"),
select = list(Treatment = "Stim-A"))
# Use Stim-A samples with highest antigen concentration only
cyto_gate_draw(gs,
parent = "root",
alias = "Cells",
channels = c("FSC-A", "SSC-A"),
select = list(Treatment = "Stim-A",
OVAConc = 500))
There are some major updates coming that should improve the plotting speed. I will try and finish this off today.
@DillonHammill yes, of course. Thanks for the explanation. Sorry for the silly question.
Happy to help. The select
argument works with group_by
as well so you can use a subset of samples for each group too.
# Gate each Treatment group separately
cyto_gate_draw(gs,
parent = "root",
alias = "Cells",
channels - c("FSC-A", "SSC-A"),
group_by = "Treatment",
select = list(OVAConc = c(0,500))
@Biomiha see issue #40 for ways to improve plotting speed without changing display
.
Thanks @DillonHammill I'll pull the latest version and give it a whirl.
Happy to help. The
select
argument works withgroup_by
as well so you can use a subset of samples for each group too.# Gate each Treatment group separately cyto_gate_draw(gs, parent = "root", alias = "Cells", channels - c("FSC-A", "SSC-A"), group_by = "Treatment", select = list(OVAConc = c(0,500))
Hey @DillonHammill ,
In this case, only the selected gatingHeirarchy have those gates. What if the purpose is to apply those gates to all gatingHeirarchies within the gatingSet?
For example, if one wants to gate on the unstained sample (boundaries become difficult to discern once samples are pooled) and apply that to the rest?
Best, NN
Sorry @northNomad only saw this now. Not exactly sure what it is that you are asking, but if you wanted to use the unstained control to set the gate and then apply the gate to all samples:
# Activation_33.fcs is the unstained control
cyto_gate_draw(gs,
parent = "root",
alias = "Cells",
channels = c("FSC-A", "SSC-A"),
select = list(name = "Activation_33.fcs"))
This will pull out the unstained control for plotting and the constructed gate(s) will be applied to all samples. In this case I am selecting the control by file name, but you could also add another variable (e.g. stain) and select the control based on that variable.
Sorry @northNomad only saw this now. Not exactly sure what it is that you are asking, but if you wanted to use the unstained control to set the gate and then apply the gate to all samples:
# Activation_33.fcs is the unstained control cyto_gate_draw(gs, parent = "root", alias = "Cells", channels = c("FSC-A", "SSC-A"), select = list(name = "Activation_33.fcs"))
This will pull out the unstained control for plotting and the constructed gate(s) will be applied to all samples. In this case I am selecting the control by file name, but you could also add another variable (e.g. stain) and select the control based on that variable.
Wow thank you @DillonHammill I'm embarrassed -
Cannot believe I've never realized there's a select argument for cyto_gate_draw
, I've been doing it wrong...
Appreciate the help as always!
Hi Dillon,
I'm trying to select one sample to gate and apply that gate to all, but I keep having the error message
Error in if (channels[1] == channels[2] | (!.empty(channels[1]) & .empty(channels[2]))) { :
missing value where TRUE/FALSE needed
For instance in this script all the gating are written in the gatin_template.csv file:
cyto_gate_draw(control_gates,
parent = "root",
alias = "Cells Platelets",
display = n_event,
channels = c("FSC-A", "SSC-A" )
)
# Gate Single Cells
cyto_gate_draw(control_gates,
parent = "Cells Platelets",
alias = "Single cells",
display = n_event,
channels = c("FSC-A", "FSC-H")
)
# Gate platelets CD42 +
cyto_gate_draw(control_gates,
parent = "Single cells",
alias = "Platelets CD42 +",
display = n_event,
channels = c("670/14 640nm-A", "SSC-A")
)
# Gate platelets CD42 + - Histogram
cyto_gate_draw(control_gates,
parent = "Platelets CD42 +",
alias = "Just Platelets",
display = n_event,
channels = "670/14 640nm-A"
)
# Gate platelets Fibronectin + (FITC) - Histogram
cyto_gate_draw(control_gates,
parent = "Platelets CD42 +",
alias = "Fibronectin + (FITC)",
channels = "530/30 488nm-A",
display = n_event,
select = list(name = "beads_and_sample_fitc Edta.fcs")
)
# Gate platelets P_Selectin + (PE) - Histogram
cyto_gate_draw(control_gates,
parent = "Platelets CD42 +",
alias = "P_Selectin + (PE)",
channels = "585/15 561nm-A",
display = n_event,
select = list(name = "beads_and_sample_pe neg isotype.fcs")
)
However when I run the command:
# Plot the gating stratiegy
# Gating scheme
cyto_plot_gating_scheme(control_gates,
back_gate = TRUE,
gate_track = TRUE)
I get the error mentioned above.
Any help?
@stefanucci-luca, this looks like a bug in plotting 1D gates. I am busy re-writing cyto_plot_gating_scheme()
from scratch and I will make sure that I fix this as well. The new update should be available early next week.
Hi @DillonHammill, did you have time to fix this?
@stefanucci-luca, I am still working on this - it is a lot more complex than I thought. I will have the new cyto_plot_gating_scheme()
ready soon.
Hi @DillonHammill,
Is there a way of using cyto_gate_draw on one sample in the GatingSet and then applying the gate to the rest of the samples. I've got a very, very big gs that takes a long time to merge before plotting and essentially I'd like to replicate what FlowJo does, in that you pick a "representative example" for gating and then copy analysis to group.
Currently, I've devised a somewhat hacky workaround:
Thanks.