DillonHammill / CytoExploreR

Interactive Cytometry Data Analysis
60 stars 13 forks source link

Saving Gating template #162

Closed kim619 closed 1 year ago

kim619 commented 1 year ago

Hi, I am wondering if there is a way to save the gating template without re-gating after re-opening the R studio. It seems to me that the data is already saved in the gating template though when I tried to use the gating population in cyto_plot(), it appeared as not found.

For example:

`> #FSC vs. SSC
> cyto_gate_draw(gs1,
+                parent="R6 GFP+RFP Pi",
+                alias = "R6 GFP+RFP Pi cells",
+                select="05-Well-A1.fcs",
+                channels = c("FSC-H","SSC-H"),
+                type="rectangle",
+                gatingTemplate="GatingTemplate6.csv",
+                plot=TRUE,
+                axes_limits="data",
+                overlay=c(GFP_R6,RFP_R6),
+                popup=FALSE)
R6 GFP+RFP Pi cells already exists in GatingTemplate6.csv.
Error in FUN(X[[i]], ...) : 
  Supply another gatingTemplate or edit gate(s) using cyto_gate_edit.`
> #trying custom legend
> cyto_plot(gs1[1],
+           parent = "R6 GFP+RFP Pi cells",
+           channels = c("FITC-H", "PE-H"),
+           contour_lines = c(15,10),
+           overlay=c("R6 GFP+RFP Px cells"),
+           point_col="black",
+           point_cols=c("yellow"),
+           point_col_alpha = c(0.1,0.5),
+           legend = TRUE,
+           legend_text = c("R6 GFP+RFP Px","R6 GFP+RFP Px"),
+           legend_text_font = 1,
+           legend_text_size = 1,
+           legend_text_col = "blue",
+           title = "R6 GFP+RFP Px vs. Pi",
+           popup=FALSE,
+           margins=c(5,5,5,10))
Error in get_cytoset_from_node(obj@pointer, y) : 
  R6 GFP+RFP Pi cells not found!
northNomad commented 1 year ago

Did you apply the gating template after restarting your session? gs <- cyto_gatingTemplate_apply(gs, "gatingTemplate.csv")

DillonHammill commented 1 year ago

Yes, you should apply the gatingTemplate after compensating and transforming the data.

Otherwise use cyto_save() to export the entire GatingSet to a folder and simply reload it using cyto_setup().

cyto_save(
  gs,
  save_as = "GatingSet"
)

gs <- cyto_setup(
  "GatingSet",
  gatingTemplate = "gatingTemplate.csv"
)

Make sure you tell cyto_setup() the name of the original gatingTemplate so that any new gates are saved there.

kim619 commented 1 year ago

Sounds good! Thank you both!