\name{classify} \alias{classify} \title{Cluster the different Phytoplankton Populations} \description{ Classify the different cell populations from an OPP or FCS dataframe according to a pre-defined parameters of population definition Because the characteristics of each phytoplankton populations varied according to environmental conditions and instrument settings, a customizable table of pre-defined parameters (pop.def) is used to help in gating the different phytoplankton populations. The rows of the pop.def table represent the names of the different populations. The columns of the pop.def table represent the parameters used for gating and clustering the different populations. The function uses these pre-defined parameters and inputs a single OPP or FCS file to cluster cell populations using either flowClust or flowMeans package } \usage{ classify(x, pop.def=POP.DEF, func=2, varnames = CHANNEL.CLMNS.SM, numc=0, noise=0, plot.cluster=FALSE, plot.assignment=FALSE, try.context='local',...) } \arguments{ \item{x}{an OPP or FCS dataframe.} \item{pop.def}{pop.def table that defines how to gate & cluster the events into populations.} \item{func}{Choose the clustering method, either flowClust (func = 1) or flowMeans (func = 2, by default) function} \item{varnames}{A character vector specifying the variables (columns) to be included in clustering when choosing flowMeans.} \item{numc}{Number of clusters when choosing flowMeans. If set to 0 (default) the value matches the number of populations defined in pop.def table . If set to NA, the optimal number of clusters will be estimated automatically.} \item{noise}{Set up the noise threshold for phytoplankton cells. Only cells with chlorophyll value higher than the noise will be clustered} \item{plot.cluster}{Plot the output of clustering when choosing flowMeans} \item{plot.assignment}{Plot the output of Matching cluster number with cell population defined in pop.def.tab when choosing flowMeans} \item{try.context}{Default value set up to 'local'} \item{...}{additional arguments to be passed to the plot function} } \value{ an OPP or FCS dataframe like the input x but with an additional column 'pop' indicating population assignment } \examples{ ## reading a standard SeaFlow file opp.path <- system.file("extdata","seaflow_cruise","2011_001", "1.evt.opp", package="flowPhyto") pop.def.path <- system.file("extdata","seaflow_cruise","pop.def.tab", package="flowPhyto") opp <- readSeaflow(opp.path) def <- readPopDef(pop.def.path) pop <- classify(x=opp, pop.def= def) table(pop$pop) ## reading from a fcs file format fcs.file.path <- system.file("extdata","fcs_cruise", "CD.20070615.A.0010.fcs", package="flowPhyto") pop.def.path2 <- system.file("extdata","fcs_cruise", "pop.def.tab", package="flowPhyto") require(flowClust) ff <- read.FCS(fcs.file.path, transformation=FALSE) df <- caroline::tab2df(exprs(ff)) names(df) <- EVT.HEADER[c(2,6,5,8,7,NA,9,NA,NA,10,1)] #if(!all(EVT.HEADER[5:length(EVT.HEADER)] %in% names(df))) # warning('Match your column names to the EVENT.COLUMN.NAMES') def2 <- readPopDef(pop.def.path2) pop2 <- classify(x=df, pop.def= def2, func=1) table(pop2$pop) #plotCytogram(pop2, 'fsc_small', 'chl_small', pop.def=def2) #optionally write this exported dataframe to disk as an opp file #writeSeaflow('converted.fcs.evt', df) }