pca_to_fcs: Add principle components (PCs) to FCS file

View source: R/pca_to_fcs.R

pca_to_fcsR Documentation

Add principle components (PCs) to FCS file

Description

A PCA is calculated on selected events and selected channels with stats::prcomp. Resulting PCs are added as channels to a newly generated FCS file.

Usage

pca_to_fcs(
  file,
  which_lines = NULL,
  channels = NULL,
  compensate = T,
  compMat,
  timeChannel = NULL,
  logicle_trans = T,
  processed_channels_to_FCS = T,
  n_pca_dims = NULL,
  output_folder = NULL,
  new_file_suffix = "pca"
)

Arguments

file

character, path to a fcs file or a flowFrame read with flowCore::read.FCS()

which_lines

numeric vector, which events to keep; every line in a fcs file is one acquired event. If you know your events (~lines) of interest (e.g. a subpopulation to select or outliers to exclude) these events may be selected.

channels

character vector, which channels to use for PC calculation. Either channels names (e.g. v-450/50-F-A) or descriptions (e.g. CD3, CD4-PECy7) may be provided. Also a mixture is possible. If not provided, all channels (scatter and fluorescence) except for the Time channel are used.

compensate

logical, should compensation be applied before PC calculation

compMat

matrix, optional; a compensation matrix to use for compensation. If not provided the SPILL argument of the fcs file will be used. If you have generated a compensation matrix in FlowJo see ?fcexpr::wsx_compMats_to_fcs in order to have it copied to fcs files.

timeChannel

character, optional; name of the time channel. If not provided flowCore:::findTimeChannel() is used to derive the time channel.

logicle_trans

logical, should the logical transformation (Parks, 2006, https://pubmed.ncbi.nlm.nih.gov/16604519/) be applied before PCA calculation. Recommendation: yes.

processed_channels_to_FCS

logical, should the processed fluorescence intensities (compensation and/or logicle transformation) be saved as extra channels to the newly generated fcs file? Respective channels are suffixed by _comp, _lgcl, or _comp_lgcl depend upon the selections above.

n_pca_dims

numeric, the number of PCs to add to the newly generated fcs file. Default: all.

output_folder

character, optional, path to a folder where to save the newly generated fcs file. Default is dirname(file).

new_file_suffix

character, the suffix to add to the the newly generated fcs file. Default is _pca.; Set this one to NULL as well as output_folder to overwrite the original file.

Value

list of pca-object and appended flowFrame which is also saved as fcs file

Examples

## Not run: 
pf <- pca_to_fcs(file = "mypath/file.fcs")

## End(Not run)

Close-your-eyes/fcexpr documentation built on Sept. 29, 2023, 12:27 a.m.