#' Select only a subset of cells
#'
#' Given a parsed flowjo result,
#' return only those cells which fall into a specific gate
#'
#' @param flowjo_res The parsed flowjo result, as generated by parse_flowjo
#' @param gate The name of the gate that should be used for selection
#'
#' @return Returns a list with two elements: flowFrame/flowSet and gates. Both are
#' subsetted to contain only the cells of interest.
#'
#' @export
gating_subset <- function(flowjo_res, gate){
if(!is.null(flowjo_res$flowSet)){
res <- lapply(seq_len(length(flowjo_res$flowSet)),
function(i){
flowjo_res$flowSet[[i]][flowjo_res$gates[[i]][,gate],]
})
names(res) <- sampleNames(flowjo_res$flowSet)
return(list(
flowSet = flowCore::flowSet(res),
gates = lapply(flowjo_res$gates, function(x)x[x[,gate], ])
))
} else {
return(list(flowFrame = flowjo_res$flowFrame[flowjo_res$gates[,gate], ],
gates = flowjo_res$gates[flowjo_res$gates[,gate], ]))
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.