RGLab / openCyto

A package that provides data analysis pipeline for flow cytometry.
GNU Affero General Public License v3.0
77 stars 29 forks source link

Working with Character String gating_args in GatingTemplate #173

Closed DillonHammill closed 6 years ago

DillonHammill commented 6 years ago

Hi guys,

This is probably a simple question, but what is the best way to work with character string gating arguments in the GatingTemplate? See example below:

# Function for finding gate coordinates - take argument type with options "beads" and "cells"
coords <- function(type){

if(type == "beads"){
"Do something"
 }else if(type == "cells"){
"Do something else"
 }

}

# Gating function
gate_coords <- function(fr, pp_res, channels, filterId = "", type = NULL, ...){

type <- type # error object 'beads' not found

# Calls coords() with type argument
coords(type = type)
}

# GatingTemplate
template <- add_pop(
gs, alias = "name", parent = "root", pop = "+", dims = "FSC-A,SSC-A", gating_method = "",
gating_args = "type=beads"
)

I would like to pass the argument to gating function by not sure of the conversions required - the argument is being treated as an unknown R object.

How can I convert this argument to character string that I can use?

Thanks for your help!

Dillon

SamGG commented 6 years ago

Tried single quotes within the string? gating_args = "type='beads'"

DillonHammill commented 6 years ago

Perfect! Thanks @SamGG, I did not know that you could do that!