### ### R Lab 2 5/14/10 - Flow Cytometry ### ## Load the appropriate libraries library(flowCore) library(flowViz) library(flowStats) ## Load in and summarize the data file.name <- system.file("extdata", "0877408774.B08", package = "flowCore") x <- read.FCS(file.name, transformation = FALSE) summary(x) ## Linearize and scale the data when loading file.name <- system.file("extdata", "0877408774.B08", package = "flowCore") x <- read.FCS(file.name, transformation = "scale") summary(x) # Make some plots plot(x) plot(x, c("FL1-H", "FL2-H")) plot(x, "FL1-H", breaks = 256) # Read in a flowSet object with 5 experiments measuring the same parameters fs <- read.flowSet(path = system.file("extdata", "compdata", "data", package = "flowCore"), name.keyword = "SAMPLE ID", phenoData = list(name = "SAMPLE ID", Filename = "$FIL")) fs # Do some gatting rectGate <- rectangleGate(filterId = "Fluorescence Region", "FL1-H" = c(50,100), "FL2-H" = c(50, 100)) rectGate # Apply to the first experiment result = filter(fs[[1]], rectGate) result summary(result) # Number of events(cells) summary(result)$n # Number of events in the gate summary(result)$true # Percent of events in the gate summary(result)$p # Other types of gates are rectangleGate, polygonGate,polytopeGate # Apply to all experiments: filter(fs, rectGate) # Set a gate that picks out the big ellipse in the # FSC/SSC channels. morphGate <- norm2Filter(filterId = "MorphologyGate", "FSC-H", "SSC-H", scale = 2) # Subset the data, in other words, select only the # cells in the morphGate, and create a new # object that only has the data for the cells in the gate smaller <- Subset(fs, morphGate) # Check that smaller has fewer events than fs fs[[1]] smaller[[1]] # You can combine filters rectGate & morphGate rectGate | morphGate !morphGate # Make a contour plot with 20 levels # on the data from the 1st experiment # only the 1st 2 channels. contour(fs[[1]],1:2,nlevels=20) # Make a flow plot flowPlot(fs[[1]])