# FR tests to compare two flow cytometry samples

### Description

Estimate FR statistics comparing cell populations across two flow cytometry samples. The estimates are
generated from `getFRmat`

and are dependent on the number of random draws as well as the size
of each random sample. For every cell population pair comparison, we take the median of the FR statistics
across all random samples as the estimated similarity. Parallel computing is used to minimize the runtime
of the algorithm (doParallel). Users can specify the number of cores to be used depending on the
available computing power. Default uses all available processing cores in the system.

Visualize minimum spanning tree (MST) of the pooled data combined from the two cell populations. MST is the basis of the FR statistics. Two populations are similar if their respective events congregate with events of the same population membership. Runs is calculated as the number of edges connecting nodes of different cell population membership plus 1 ( (or equivalently, the number of subtrees of homogeneous cell population membership).

### Usage

1 2 3 4 |

### Arguments

`XX1` |
a flow cytometry sample of cell populations, organized in a matrix or a data.frame of events (rows) by features (columns) where cell populaiton memberships are indexed in the last column by a variable named id. |

`XX2` |
a flow cytometry sample of cell populations, organized in a matrix or a data.frame of events (rows) by features (columns) where cell populaiton memberships are indexed in the last column by a variable named id. |

`ndraws` |
number of random samples. Runtime is linear in the number of random samples. (default: 200) |

`sampleMethod` |
downsampling method, options include |

`sampleSize` |
specifies |

`estStat` |
statistic that used to estimate FR statistic of each population pair comparison across random samples. (default: median) |

`mat` |
a matrix or data.frame of the pooled data of a cell population pair. The rows contain events in the pooled data. The columns are the expression markers. The population membership is indexed in the last column of the matrix or data.frame. The membership IDs are for plotting purposes, and hence need to uniquely identify the two cell populations in the pooled data. |

`node.colors` |
colors to label cell population membership of the events. (default: c("blue","red")) |

### Value

wmat a matrix of estimated FR statistics for each XX1 by XX2 population comparisons.

runsmat a matrix of estimated runs for each XX1 by XX2 population comparisons.

mumat a matrix of estimated expected number of runs for each XX1 by XX2 population comparisons.

sigma2mat a matrix of estimated variance of runs for each XX1 by XX2 population comparisons.

pNormat a matrix of one-sided p-values of the estimated FR statistic for each XX1 by XX2 population comparisons under the asymptotic normality assumption of the FR statistic.

g an *igraph* object that contains graph adjacency matrix of the minimum spanning tree calculated from
euclidean distance between nodes in the pooled data combined from the two cell populations.

gall an *igraph* object that contains graph adjacency matrix containing euclidean distance between
nodes in the pooled data from the two cell population. Complete graph is assumed here.

ww FR statistics for the cell population comparison (formula: (runs-mu)/sqrt(sigma2))

runs observed number of runs for the cell population comparison

mu expected number of runs for the cell population comparison

sigma2 variance of runs for the cell population comparison

pNorm p-value of the FR statistic for the cell population comparison

distmat a matrix defining Euclidean distance between events (nodes) across the two cell populations

mstree minimum spannin tree defined in an adjacency matrix. 1 indicates an edge between nodes and 0 indicates non-existent edge.

C number of edge pairs (pairs of edges that share a common node) in the minumum spanning tree

m number of events in the first cell population

n number of events in the second cell population

### Author(s)

Chiaowen Joyce Hsiao joyce.hsiao1@gmail.com

Chiaowen Joyce Hsiao joyce.hsiao1@gmail.com

### Examples

1 2 | ```
## see vignettes
## see vignettes
``` |