Learn R Programming

cyanoFilter (version 0.1.3)

retain: Decides if a file should be retiained or removed based on its status.

Description

Function to determine what files to retain and finally read from the flow cytometer FCS file.

Usage

retain(meta_files, make_decision = c("maxi", "mini", "unique"),
  Status = "Status", CellspML = "CellspML")

Arguments

meta_files

dataframe from meta file that has been preprocessed by the goodfcs function.

make_decision

decision to be made should more than one \(cells/\mu L\) be good.

Status

column name in meta_files containing status obtained from the goodfcs function.

CellspML

column name in meta_files containing \(cells/\mu L\) measurements.

Value

a character vector with entries "Retain" for a file to be retained or "No!" for a file to be discarded.

Details

It is typically not known in advance which dilution level would result in the desired \(cells/\mu L\), therefore the samples are ran through the flow cytometer at two or more dilution levels. Out of these, one has to decide which to retain and finally use for further analysis. This function and goodfcs are to help you decide that. If more than one of the dilution levels are judged good, the option make_decision = "maxi" will give "Retain" to the row with the maximum \(cells/\mu L\) while the opposite occurs for make_decision = "mini". make_decision = "unique" i there is only one measurement for that particular sample, while make_decision = "maxi" and make_decision = "mini" should be used for files with more than one measurement for the sample in question.

See Also

goodfcs

Examples

Run this code
# NOT RUN {
 metadata <- system.file("extdata", "2019-03-25_Rstarted.csv", package = "cyanoFilter",
              mustWork = TRUE)
 metafile <- read.csv(metadata, skip = 7, stringsAsFactors = FALSE,
                      check.names = TRUE, encoding = "UTF-8")
 metafile <- metafile[, 1:65] #first 65 columns contain useful information
 #extract the part of the Sample.ID that corresponds to BS4 or BS5
 metafile$Sample.ID2 <- stringr::str_extract(metafile$Sample.ID, "BS*[4-5]")
 #clean up the Cells.muL column
 names(metafile)[which(stringr::str_detect(names(metafile), "Cells."))] <- "CellspML"
 metafile$Status <- cyanoFilter::goodfcs(metafile = metafile, col_cpml = "CellspML",
                            mxd_cellpML = 1000, mnd_cellpML = 50)
 metafile$Retained <- NULL
 # first 3 rows contain BS4 measurements at 3 dilution levels
 metafile$Retained[1:3] <- cyanoFilter::retain(meta_files = metafile[1:3,], make_decision = "maxi",
                   Status = "Status", CellspML = "CellspML")
 # last 3 rows contain BS5 measurements at 3 dilution levels as well
 metafile$Retained[4:6] <- cyanoFilter::retain(meta_files = metafile[4:6,], make_decision = "maxi",
                   Status = "Status", CellspML = "CellspML")


# }

Run the code above in your browser using DataLab