Compute, export and save statistics

# S3 method for GatingSet
cyto_stats_compute(
  x,
  alias = NULL,
  parent = NULL,
  channels = NULL,
  trans = NA,
  stat = "median",
  format = "long",
  save_as = NULL,
  select = NULL,
  density_smooth = 0.6,
  ...
)

# S3 method for GatingHierarchy
cyto_stats_compute(
  x,
  alias = NULL,
  parent = NULL,
  channels = NULL,
  trans = NA,
  stat = "median",
  format = "long",
  save_as = NULL,
  density_smooth = 0.6,
  ...
)

# S3 method for flowSet
cyto_stats_compute(
  x,
  channels = NULL,
  trans = NA,
  stat = "median",
  gate = NA,
  format = "long",
  select = NULL,
  density_smooth = 0.6,
  ...
)

# S3 method for flowFrame
cyto_stats_compute(
  x,
  channels = NULL,
  trans = NA,
  stat = "median",
  gate = NA,
  format = "long",
  density_smooth = 0.6,
  ...
)

Arguments

x

object of class flowFrame, flowSet, GatingHierarchy or GatingSet.

alias

name(s) of the population(s) for which the statistic should be calculated when a GatingHierarchy or GatingSet is supplied.

parent

name(s) of the parent population(s) used calculate population frequencies when a GatingHierarchy or GatingSet object is supplied. The frequency of alias in each parent will be returned as a percentage.

channels

names of of channels for which statistic should be calculated, set to all channels by default.

trans

object of class transformerList used to transfom the channels of the supplied data. The transformerList is required to return the data to the original linear scale when calculating statistics.

stat

name of the statistic to calculate, options include "count", "freq", "median", "mode", "mean", "geo mean", "CV", or "freq".

format

indicates whether the data should be returned in the "wide" or "long" format, set to the "long" format by default.

save_as

name of a csv file to which the statistical results should be saved.

select

named list containing experimental variables to be used to select samples using cyto_select when a flowSet or GatingSet is supplied. Refer to cyto_select for more details.

density_smooth

smoothing parameter passed to density when calculating mode, set to 1.5 by default.

...

not in use.

gate

object of class rectangleGate, polygonGate or ellipsoidGate to apply to flowFrame or flowSet objects prior to computing statistics.

Value

a tibble containing the computed statistics in the wide or long format.

Author

Dillon Hammill, Dillon.Hammill@anu.edu.au

Examples

library(CytoExploreRData) # Load in samples fs <- Activation gs <- GatingSet(fs) # Apply compensation gs <- compensate(gs, fs[[1]]@description$SPILL) # Transform fluorescent channels trans <- estimateLogicle(gs[[32]], cyto_fluor_channels(gs)) gs <- transform(gs, trans) # Gate using cyto_gate_draw gt <- Activation_gatingTemplate gt_gating(gt, gs)
#> Preprocessing for 'Cells'
#> Gating for 'Cells'
#> done!
#> done.
#> Preprocessing for 'Single Cells'
#> Gating for 'Single Cells'
#> done!
#> done.
#> Preprocessing for 'Dead Cells'
#> Gating for 'Dead Cells'
#> done!
#> done.
#> Live Cells gating...
#> done!
#> done.
#> Preprocessing for 'T Cells'
#> Gating for 'T Cells'
#> done!
#> done.
#> Preprocessing for 'CD8 T Cells'
#> Gating for 'CD8 T Cells'
#> done!
#> done.
#> Preprocessing for 'CD69+ CD8 T Cells'
#> Gating for 'CD69+ CD8 T Cells'
#> done!
#> done.
#> Preprocessing for 'CD4 T Cells'
#> Gating for 'CD4 T Cells'
#> done!
#> done.
#> Preprocessing for 'CD69+ CD4 T Cells'
#> Gating for 'CD69+ CD4 T Cells'
#> done!
#> done.
#> Preprocessing for 'Dendritic Cells'
#> Gating for 'Dendritic Cells'
#> done!
#> done.
#> finished.
# Compute statistics - median cyto_stats_compute(gs, alias = "T Cells", channels = c("Alexa Fluor 488-A", "PE-A"), stat = "median", save = FALSE )
#> # A tibble: 66 x 6 #> name OVAConc Treatment Population Marker MedFI #> <fct> <chr> <chr> <chr> <chr> <dbl> #> 1 Activation_1.fcs 0 Stim-A T Cells CD8 1501. #> 2 Activation_1.fcs 0 Stim-A T Cells Va2 17651. #> 3 Activation_2.fcs 0 Stim-A T Cells CD8 2238. #> 4 Activation_2.fcs 0 Stim-A T Cells Va2 18608. #> 5 Activation_3.fcs 5 Stim-A T Cells CD8 1541. #> 6 Activation_3.fcs 5 Stim-A T Cells Va2 18946. #> 7 Activation_4.fcs 5 Stim-A T Cells CD8 567. #> 8 Activation_4.fcs 5 Stim-A T Cells Va2 19885. #> 9 Activation_5.fcs 50 Stim-A T Cells CD8 1074. #> 10 Activation_5.fcs 50 Stim-A T Cells Va2 20104. #> # ... with 56 more rows
# Compute statistics for experimental group cyto_stats_compute(gs, alias = "T Cells", channels = c("Alexa Fluor 488-A", "PE-A"), stat = "median", save = FALSE, select = list(Treatment = "Stim-A") )
#> # A tibble: 16 x 6 #> name OVAConc Treatment Population Marker MedFI #> <fct> <chr> <chr> <chr> <chr> <dbl> #> 1 Activation_1.fcs 0 Stim-A T Cells CD8 1501. #> 2 Activation_1.fcs 0 Stim-A T Cells Va2 17651. #> 3 Activation_2.fcs 0 Stim-A T Cells CD8 2238. #> 4 Activation_2.fcs 0 Stim-A T Cells Va2 18608. #> 5 Activation_3.fcs 5 Stim-A T Cells CD8 1541. #> 6 Activation_3.fcs 5 Stim-A T Cells Va2 18946. #> 7 Activation_4.fcs 5 Stim-A T Cells CD8 567. #> 8 Activation_4.fcs 5 Stim-A T Cells Va2 19885. #> 9 Activation_5.fcs 50 Stim-A T Cells CD8 1074. #> 10 Activation_5.fcs 50 Stim-A T Cells Va2 20104. #> 11 Activation_6.fcs 50 Stim-A T Cells CD8 2222. #> 12 Activation_6.fcs 50 Stim-A T Cells Va2 20075. #> 13 Activation_7.fcs 500 Stim-A T Cells CD8 4823. #> 14 Activation_7.fcs 500 Stim-A T Cells Va2 20493. #> 15 Activation_8.fcs 500 Stim-A T Cells CD8 4369. #> 16 Activation_8.fcs 500 Stim-A T Cells Va2 20926.
# Compute population frequencies and save to csv file cyto_stats_compute(gs, alias = c("CD4 T Cells", "CD8 T Cells"), parent = c("Live Cells", "T Cells"), stat = "freq", save_as = "Population-Frequencies" )
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> New names: #> * count -> count...1 #> * count -> count...2
#> # A tibble: 132 x 6 #> name OVAConc Treatment Population Parent Frequency #> <fct> <chr> <chr> <chr> <chr> <dbl> #> 1 Activation_1.fcs 0 Stim-A CD4 T Cells Live Cells 13.3 #> 2 Activation_1.fcs 0 Stim-A CD8 T Cells Live Cells 16.1 #> 3 Activation_1.fcs 0 Stim-A CD4 T Cells T Cells 41.2 #> 4 Activation_1.fcs 0 Stim-A CD8 T Cells T Cells 49.8 #> 5 Activation_2.fcs 0 Stim-A CD4 T Cells Live Cells 15.0 #> 6 Activation_2.fcs 0 Stim-A CD8 T Cells Live Cells 18.3 #> 7 Activation_2.fcs 0 Stim-A CD4 T Cells T Cells 41.2 #> 8 Activation_2.fcs 0 Stim-A CD8 T Cells T Cells 50.2 #> 9 Activation_3.fcs 5 Stim-A CD4 T Cells Live Cells 14.9 #> 10 Activation_3.fcs 5 Stim-A CD8 T Cells Live Cells 18.1 #> # ... with 122 more rows