## ----setup, include=FALSE----------------------------------------------------- knitr::opts_chunk$set(echo = TRUE, results = "markup", message = FALSE) ## ----findxml------------------------------------------------------------------ library(flowWorkspace) path <- system.file("extdata",package="flowWorkspaceData"); wsfile <- list.files(path, pattern="A2004Analysis.xml", full = TRUE) ## ----openws,results='markup'-------------------------------------------------- library(CytoML) ws <- open_flowjo_xml(wsfile) ws ## ----getsamples-ws------------------------------------------------------------ fj_ws_get_samples(ws) ## ----getgroups---------------------------------------------------------------- fj_ws_get_sample_groups(ws) ## ----------------------------------------------------------------------------- sn <- "a2004_O1T2pb05i_A1_A01.fcs" fj_ws_get_keywords(ws, sn)[1:5] ## ----parsews,message=FALSE, warning=FALSE------------------------------------- gs <- flowjo_to_gatingset(ws,name = 1); #import the first group #Lots of output here suppressed for the vignette. gs ## ----sampleNames-------------------------------------------------------------- sampleNames(gs) ## ----parseGatingML, eval=FALSE------------------------------------------------ # xmlfile <- system.file("extdata/cytotrol_tcell_cytobank.xml", package = "CytoML") # fcsFiles <- list.files(pattern = "CytoTrol", system.file("extdata", package = "flowWorkspaceData"), full = T) # gs1 <- parse.gatingML(xmlfile, fcsFiles) ## ----subset------------------------------------------------------------------- gs[1] ## ----plotTree----------------------------------------------------------------- plot(gs) ## ----gs_get_pop_paths-path-1-------------------------------------------------- gs_get_pop_paths(gs, path = 1) ## ----gs_get_pop_paths-path-full----------------------------------------------- gs_get_pop_paths(gs, path = "full") ## ----gs_get_pop_paths-path-auto----------------------------------------------- nodelist <- gs_get_pop_paths(gs, path = "auto") nodelist ## ----gh_pop_get_gate---------------------------------------------------------- node <- nodelist[3] g <- gs_pop_get_gate(gs, node) g ## ----getStats----------------------------------------------------------------- gs_pop_get_count_fast(gs)[1:10,] ## ----plotGate-nodeName-------------------------------------------------------- plotGate(gs, "pDC") ## ----annotate----------------------------------------------------------------- d <- data.frame(sample=factor(c("sample 1", "sample 2")),treatment=factor(c("sample","control")) ) pd <- pData(gs) pd <- cbind(pd,d) pData(gs) <- pd pData(gs) ## ----------------------------------------------------------------------------- subset(gs, treatment == "control") ## ----------------------------------------------------------------------------- fs <- gs_pop_get_data(gs) class(fs) nrow(fs[[1]]) ## ----gh_pop_get_data-gs------------------------------------------------------- fs <- gs_pop_get_data(gs, node) nrow(fs[[1]]) ## ----gh----------------------------------------------------------------------- gh <- gs[[1]] gh ## ----------------------------------------------------------------------------- head(gh_pop_compare_stats(gh)) ## ----gh_plot_pop_count_cv----------------------------------------------------- gh_plot_pop_count_cv(gh) ## ----------------------------------------------------------------------------- plotGate(gh) ## ----getInd------------------------------------------------------------------- table(gh_pop_get_indices(gh,node)) ## ----getCMAT------------------------------------------------------------------ C <- gh_get_compensations(gh); C ## ----getTrans,results='markup'------------------------------------------------ T <- gh_get_transformations(gh) names(T) T[[1]] ## ----create gs---------------------------------------------------------------- library(flowCore) data(GvHD) #select raw flow data fs <- GvHD[1:2] ## ----GatingSet constructor---------------------------------------------------- gs <- GatingSet(fs) ## ----compensate--------------------------------------------------------------- cfile <- system.file("extdata","compdata","compmatrix", package="flowCore") comp.mat <- read.table(cfile, header=TRUE, skip=2, check.names = FALSE) ## create a compensation object comp <- compensation(comp.mat) #compensate GatingSet gs <- compensate(gs, comp) ## ----eval=FALSE--------------------------------------------------------------- # gs <- compensate(gs, comp.list) ## ----user-transformation------------------------------------------------------ require(scales) trans.func <- asinh inv.func <- sinh trans.obj <- trans_new("myAsinh", trans.func, inv.func) ## ----transform-build-in------------------------------------------------------- trans.obj <- asinhtGml2_trans() trans.obj ## ----transformerList---------------------------------------------------------- chnls <- colnames(fs)[3:6] transList <- transformerList(chnls, trans.obj) ## ----estimateLogicle---------------------------------------------------------- estimateLogicle(gs[[1]], chnls) ## ----transform-gs------------------------------------------------------------- gs <- transform(gs, transList) gs_get_pop_paths(gs) ## ----add-rectGate------------------------------------------------------------- rg <- rectangleGate("FSC-H"=c(200,400), "SSC-H"=c(250, 400), filterId="rectangle") nodeID <- gs_pop_add(gs, rg) nodeID gs_get_pop_paths(gs) ## ----add-quadGate------------------------------------------------------------- qg <- quadGate("FL1-H"= 0.2, "FL2-H"= 0.4) nodeIDs <- gs_pop_add(gs,qg,parent="rectangle") nodeIDs gs_get_pop_paths(gs) ## ----add-boolGate------------------------------------------------------------- bg <- booleanFilter(`CD15 FITC-CD45 PE+|CD15 FITC+CD45 PE-`) bg nodeID2 <- gs_pop_add(gs,bg,parent="rectangle") nodeID2 gs_get_pop_paths(gs) ## ----plot-gh,eval=FALSE------------------------------------------------------- # plot(gs, bool=TRUE) ## ----recompute---------------------------------------------------------------- recompute(gs) ## ----plotGate-rect------------------------------------------------------------ plotGate(gs,"rectangle") #plot one Gate ## ----plotGate-multiple-------------------------------------------------------- plotGate(gs,gs_pop_get_children(gs[[1]], "rectangle")) ## ----plotGate-gh-bool,eval=FALSE---------------------------------------------- # plotGate(gs[[1]], bool=TRUE) ## ----rm----------------------------------------------------------------------- Rm('rectangle', gs) gs_get_pop_paths(gs) ## ----archive,eval=FALSE------------------------------------------------------- # tmp <- tempdir() # save_gs(gs,path = file.path(tmp,"my_gs")) # gs <- load_gs(file.path(tmp,"my_gs")) ## ----clone,eval=FALSE--------------------------------------------------------- # gs_gs_cloned <- clone(gs)