cyto_stats_compute: Compute, export and save statistics

View source: R/cyto_stats_compute.R

cyto_stats_computeR Documentation

Compute, export and save statistics

Description

Compute, export and save statistics

Usage

## S3 method for class '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 class '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 class 'flowSet'
cyto_stats_compute(
  x,
  channels = NULL,
  trans = NA,
  stat = "median",
  gate = NA,
  format = "long",
  select = NULL,
  density_smooth = 0.6,
  ...
)

## S3 method for class '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(s)

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)

# Compute statistics - median
cyto_stats_compute(gs,
  alias = "T Cells",
  channels = c("Alexa Fluor 488-A", "PE-A"),
  stat = "median",
  save = FALSE
)

# 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")
)

# 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"
)


DillonHammill/CytoExploreR documentation built on March 2, 2023, 7:34 a.m.