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

Description Usage Arguments Details Value See Also Examples

View source: R/retain.R

Description

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

Usage

1
2
3
4
5
6
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/μ L be good.

Status

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

CellspML

column name in meta_files containing cells/μ L measurements.

Details

It is typically not known in advance which dilution level would result in the desired cells/μ 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/μ 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.

Value

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

See Also

goodFcs

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 require("stringr")
 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[, seq_len(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[seq_len(3)] <- 
  cyanoFilter::retain(meta_files = metafile[seq_len(3),], 
 make_decision = "maxi",
 Status = "Status", CellspML = "CellspML")
 # last 3 rows contain BS5 measurements at 3 dilution levels as well
 metafile$Retained[seq(4, 6, by = 1)] <- 
   cyanoFilter::retain(meta_files = metafile[seq(4, 6, by = 1),], 
 make_decision = "maxi",
 Status = "Status", CellspML = "CellspML")

fomotis/cyanoFilter documentation built on Aug. 1, 2021, 10:58 p.m.