FlowHist: FlowHist

Description Usage Arguments Details Value Slots Author(s) Examples

View source: R/FlowHist.R


Creates a FlowHist object from an FCS file, setting up the histogram data for analysis.


FlowHist(file, channel, standards = 0, bins = 256, window = 20,
  smooth = 20, pick = FALSE, linearity = "variable", debris = "SC",
  opts = list(), samples = 2, gate = logical(), analyze = TRUE)

batchFlowHist(files, channel, verbose = TRUE, ...)



character, the name of the single file to load


character, the name of the data column to use


numeric; the size of the internal standard in pg. When loading a data set where different samples have different standards, a vector of all the standard sizes. If set to 0, calculation of pg for the unknown sample will not be done.


integer, the number of bins to use to aggregate events into a histogram


integer, the width of the moving window used to identify local maxima for peak detection via runmax. The default is 20. If you have really clean, narrow, peaks, lowering this value may help you get better initial values.


integer, the width of the moving window used to reduce noise in the histogram via runmean. The default is 20. As for window, lower values may be helpful for clean peaks.


boolean; if TRUE, the user will be prompted to select peaks to use for starting values. Otherwise (the default), starting values will be detected automatically.


character, either "variable", the default, or "fixed". If "fixed", linearity is fixed at 2; if "variable", linearity is fit as a model parameter.


character, either "SC", the default, "MC", or "none", to set the debris model component to the Single-Cut or Multi-Cut models, or to not include a debris component (such as for gated data).


list, currently not used, but maybe in future as a way to test additional model options


integer; the number of samples in the data. Default is 2 (unknown and standard), but can be set to 3 if two standards are used.


logical, a vector of events to exclude from analysis. In normal usage this will be set interactively, not as a function argument.


boolean, if TRUE the model will be analyzed immediately


character, a vector of file names to load


boolean; if TRUE, batchFlowHist will list files as it processes them.


Additional arguments passed to FlowHist


For most uses, simpling calling FlowHist with a file, channel, and standards argument will do what you need. The other arguments are provided for optional tuning of this process. In practice, it's easier to correct the model fit using browseFlowHist than to determine 'perfect' values to pass in as arguments to FlowHist.

Similarly, batchFlowHist is usually used with only the files, channel, and standards arguments.

In operation, FlowHist starts by reading an FCS file (using the function read.FCS internally). This produces a flowFrame object, which we extend to a FlowHist object as follows:

  1. Extract the fluorescence data from channel.

  2. Remove the top bin, which contains off-scale readings we ignore in the analysis.

  3. Remove negative fluorescence values, which are artifacts of instrument compensation

  4. Removes the first 5 bins, which often contain noisy values, probably further artifacts of compensation.

  5. aggregates the raw data into the desired number of bins, as specified with the bins argument. The default is 256, but you may also try 128 or 512. Any integer is technically acceptable, but I wouldn't stray from the default without a good reason. (I've never had a good reason!)

  6. identify model components to include. All FlowHist objects will have the single-cut debris model and the G1 peak for sample A, and the broadened rectangle for the S-phase of sample A. Depending on the data, additional components for the G2 peak and sample B (G1, G2, s-phase) may also be added. The debris argument can be used to select the Multi-Cut debris model instead, or this can be toggled in browseFlowHist

  7. Build the NLS model. All the components are combined into a single model.

  8. Identify starting values for Gaussian (G1 and G2 peaks) model components. For reasonably clean data, the built-in peak detection is ok. You can evaluate this by plotting the FlowHist object with the argument init = TRUE. The easiest way to fix bad peak detection is via the browseFlowHist interface. You can also play with the window and smooth arguments (which is tedious!), or pick the peaks visually yourself with pick = TRUE.

  9. Finally, we fit the model and calculate the fitted parameters. Model fitting is suppressed if the analyze argument is set as FALSE


FlowHist returns a FlowHist object.

batchFlowHist returns a list of FlowHist objects.



a flowFrame object containing the raw data from the FCS file


character, the name of the data column to use


integer, the number of bins to use to aggregate events into a histogram


character, either "fixed" or "variable" to indicate if linearity is fixed at 2 or fit as a model parameter


character, either "SC" or "MC" to indicate if the model should include the single-cut or multi-cut model


logical, a vector indicating events to exclude from the analysis. In normal use, the gate will be modified via interactive functions, not set directly by users.


data.frame, the columns are the histogram bin number (xx), florescence intensity (intensity), and the raw single-cut and multi-cut debris model values (SCvals and MCvals), and the raw doublet, triplet and quadruplet aggregate values (DBvals, TRvals, and QDvals). The debris and aggregate values are used in the NLS fitting procedures.


matrix, containing the coordinates used for peaks when calculcating initial parameter values.


list, currently unused. A convenient place to store flags when trying out new options.


a list of ModelComponent objects included for these data.


the function (built from comps) to fit to these data.


list, a list of lower and upper bounds for model parameters


a list of initial parameter estimates to use in fitting the model.


the nls object produced by the model fitting


a list of cells counted in each peak of the fitted model


a list of the coefficients of variation for each peak in the fitted model.


numeric, the residual chi-square for the fitted model.


numeric, the number of samples included in the data. The default is 2 (i.e., unknown and standard), but if two standards are used it should be set to 3.


a FlowStandards object.


Tyler Smith


fh1 <- FlowHist(file = flowPloidyFiles[1], channel = "FL3.INT.LIN")
batch1 <- batchFlowHist(flowPloidyFiles, channel = "FL3.INT.LIN")

flowPloidy documentation built on May 20, 2017, 10:36 p.m.

Search within the flowPloidy package
Search all R packages, documentation and source code