CV: Calculating coefficient of variance (CV) of fingerprints from...

Description Usage Arguments Examples

View source: R/CV.R

Description

This function calculates the coefficient of variance from the fingerprint generated by flowBasis().

Usage

1
CV(x, d = 3, n = 1, plot = FALSE)

Arguments

x

flowbasis object generated by flowBasis()according to Koch et al. 2014.

d

Rounding factor for density values. Defaults to 4.

n

Number of replicates. Defaults to 1.

plot

Make plot of diversity values? Defaults to FALSE.

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
## Short example

# Load precomputed fingerprint object
data(CoolingTower)

# Calculate diversity values
CV(CoolingTower, plot=TRUE)

## Full data processing example

# Load raw data (imported using flowCore)
data(flowData)
# Asinh transform and select parameters of interest (cells were stained with Sybr Green I).
flowData_transformed <- flowCore::transform(flowData,`FL1-H`=asinh(`FL1-H`),
       `SSC-H`=asinh(`SSC-H`), 
       `FL3-H`=asinh(`FL3-H`), 
       `FSC-H`=asinh(`FSC-H`))
param=c('FL1-H', 'FL3-H','SSC-H','FSC-H')
flowData_transformed = flowData_transformed[,param]

# Create a PolygonGate for denoising the dataset
# Define coordinates for gate in sqrcut1 in format: c(x,x,x,x,y,y,y,y)
sqrcut1 <- matrix(c(8.75,8.75,14,14,3,7.5,14,3),ncol=2, nrow=4)
colnames(sqrcut1) <- c('FL1-H','FL3-H')
polyGate1 <- flowCore::polygonGate(.gate=sqrcut1, filterId = 'Total Cells')

# Gating quality check
flowViz::xyplot(`FL3-H` ~ `FL1-H`, data=flowData_transformed[1], filter=polyGate1,
         scales=list(y=list(limits=c(0,14)),
         x=list(limits=c(6,16))),
         axis = lattice::axis.default, nbin=125, 
         par.strip.text=list(col='white', font=2, cex=2), smooth=FALSE)
 
 # Isolate only the cellular information based on the polyGate1
 flowData_transformed <- flowCore::Subset(flowData_transformed, polyGate1)
 
 # Normalize parameter values to [0,1] interval based on max. value across parameters
 summary <- flowCore::fsApply(x=flowData_transformed,FUN=function(x) apply(x,2,max),use.exprs=TRUE)
 max = max(summary[,1])
 mytrans <- function(x) x/max
 flowData_transformed <- flowCore::transform(flowData_transformed,`FL1-H`=mytrans(`FL1-H`),
         `FL3-H`=mytrans(`FL3-H`), 
         `SSC-H`=mytrans(`SSC-H`),
         `FSC-H`=mytrans(`FSC-H`))
 
 # Calculate fingerprint
 fbasis <- flowFDA::flowBasis(flowData_transformed, param, nbin=128, 
         bw=0.01, normalize=function(x) x)
 
 # Calculate diversity
 CV(fbasis, plot=TRUE)

rprops/Phenoflow_package documentation built on Sept. 22, 2020, 5:43 p.m.