Title: | Identifying differential cell populations in flow cytometry data accounting for marker frequency |
---|---|
Description: | Identifies maximal differential cell populations in flow cytometry data taking into account dependencies between cell populations; flowGraph calculates and plots SpecEnr abundance scores given cell population cell counts. |
Authors: | Alice Yue [aut, cre] |
Maintainer: | Alice Yue <[email protected]> |
License: | Artistic-2.0 |
Version: | 1.15.0 |
Built: | 2024-10-30 07:51:13 UTC |
Source: | https://github.com/bioc/flowGraph |
Determines the layer on which the given phenotypes reside.
cell_type_layers(phen)
cell_type_layers(phen)
phen |
A string vector of phenotype or cell population name labels. |
Given a vector of phenotypes, returns an equal length vector of the number of markers in each phenotype.
A numeric vector with the same length as phen
indicating which
layer each phenotype resides on.
phen <- c('A+B+C-D++', 'A+B-', '', 'B++D-E+') cell_type_layers(phen)
phen <- c('A+B+C-D++', 'A+B-', '', 'B++D-E+') cell_type_layers(phen)
Extracts all unique markers from cell population phenotypes
extract_markers(phen)
extract_markers(phen)
phen |
A vector of cell population phenotypes. |
A vector of unique markers
Adds a feature created using feat_fun
from fg
OR
m
into a given flowGraph object. Only use this function if
you cannot generate the desired features using the existing flowGraph
functions starting with fg_feat_<feature name>
.
fg_add_feature( fg, type = "node", feature, m = NULL, feat_fun = NULL, overwrite = FALSE, ... )
fg_add_feature( fg, type = "node", feature, m = NULL, feat_fun = NULL, overwrite = FALSE, ... )
fg |
flowGraph object. |
type |
A string specifying the type of the feature being added i.e. 'node' or 'edge'. |
feature |
A string indicating the unique name of the feature added. |
m |
A numeric matrix with feature values; it should contain the
same sample id's on row names as in |
feat_fun |
A function that ouputs a feature matrix as in |
overwrite |
A logical variable indicating whether or not the function
should replace the existing feature with the same name if
one is already in |
... |
Other parameters that would be used as input into |
fg_add_feature
adds the given new feature matrix to the
given flowGraph object fg
updating slots
feat
and feat_desc
.
See flowGraph-class
slot feat
and feat_desc
for what should be in these slots.
We do not recommend users to directly use this method unless there is
a clear understanding on how the row and column names should be specified.
Instead, we recommend users to use the functions listed in the "See also"
sections prefixed with "fg_feat_".
flowGraph object.
flowGraph-class
fg_feat_node_prop
fg_feat_node_specenr
fg_get_feature
fg_rm_feature
fg_get_feature_desc
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg_get_feature_desc(fg) fg <- fg_add_feature(fg, type="node", feature="count_copy", m=fg_data_pos30$count) fg_get_feature_desc(fg)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg_get_feature_desc(fg) fg <- fg_add_feature(fg, type="node", feature="count_copy", m=fg_data_pos30$count) fg_get_feature_desc(fg)
Adds a feature summary into a given flowGraph object.
Only use this function if your summary statistic cannot be calcuated
using the fg_summary
function.
fg_add_summary( fg, type = "node", summary_meta = NULL, p = NULL, summ_fun = NULL, overwrite = FALSE, ... )
fg_add_summary( fg, type = "node", summary_meta = NULL, p = NULL, summ_fun = NULL, overwrite = FALSE, ... )
fg |
flowGraph object. |
type |
A string indicating feature type the summary was created for; 'node' or 'edge'. |
summary_meta |
The user must provide
|
p |
A list containing summary values; this list contains elements:
|
summ_fun |
A function that ouputs a feature summary matrix
as in |
overwrite |
A logical variable indicating whether or not the function
should replace the existing feature summary with the
same name if one is already in |
... |
Other parameters that would be used as input into |
fg_add_summary
adds the given feature summary list p
or the output of the given function summ_fun
to the
given flowGraph object fg
updating slots
summary
and summary_desc
.
See flowGraph-class
slot summary
and summary_desc
for what should be in these slots. We do not recommend users directly use
this function unless what is required is duly in the above slots is
well understood — note these slots are used in plotting functions
e.g. fg_plot
. We instead recommend users to use
the fg_summary
function.
flowGraph object.
flowGraph-class
fg_summary
fg_get_summary
fg_rm_summary
fg_get_summary_desc
fg_add_feature
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) # get samples that we are going to compare m <- fg_get_feature(fg, type="node", feature="prop") m1_ <- m[fg_data_pos30$meta$class=="control",,drop=FALSE] m2_ <- m[fg_data_pos30$meta$class=="exp",,drop=FALSE] # define test or summary function to conduct comparison test_custom <- function(x,y) tryCatch(stats::t.test(x,y)$p.value, error=function(e) 1) values_p <- sapply(seq_len(ncol(m)), function(j) test_custom(m1_[,j], m2_[,j]) ) values_p <- p.adjust(values_p , method="BY") # the user can choose to fill either parameter "p" or "summ_fun", # the latter of which must output a list with the same elements as "p". # see documentation for ?flowGraph-class, slot "summary" for # details on what should be in "p". p <- list(values=values_p, test_fun=test_custom, adjust_fun="BY") fg <- fg_add_summary(fg, type="node", summary_meta=list( feature="prop", test_name="wilcox_BY", class="class", label1="control", label2="exp"), p=p) fg_get_summary_desc(fg)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) # get samples that we are going to compare m <- fg_get_feature(fg, type="node", feature="prop") m1_ <- m[fg_data_pos30$meta$class=="control",,drop=FALSE] m2_ <- m[fg_data_pos30$meta$class=="exp",,drop=FALSE] # define test or summary function to conduct comparison test_custom <- function(x,y) tryCatch(stats::t.test(x,y)$p.value, error=function(e) 1) values_p <- sapply(seq_len(ncol(m)), function(j) test_custom(m1_[,j], m2_[,j]) ) values_p <- p.adjust(values_p , method="BY") # the user can choose to fill either parameter "p" or "summ_fun", # the latter of which must output a list with the same elements as "p". # see documentation for ?flowGraph-class, slot "summary" for # details on what should be in "p". p <- list(values=values_p, test_fun=test_custom, adjust_fun="BY") fg <- fg_add_summary(fg, type="node", summary_meta=list( feature="prop", test_name="wilcox_BY", class="class", label1="control", label2="exp"), p=p) fg_get_summary_desc(fg)
Reformats cell population phenotypes into flowGraph format
fg_clean_phen(phen, markers = NULL)
fg_clean_phen(phen, markers = NULL)
phen |
Vector of cell population phenotype names as character strings. |
markers |
markers extracted from |
Vector with the same length as phen
containing reformatted
and not necessarily changed cell population phenotype names.
# fg_clean_phen(c("A+_B+","B+_notC","A-_C"))
# fg_clean_phen(c("A+_B+","B+_notC","A-_C"))
Returns a flowGraph object with only the count
feature.
fg_clear_features(fg)
fg_clear_features(fg)
fg |
flowGraph object. |
flowGraph object with only the count
node
feature.
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) fg <- fg_clear_features(fg) fg_get_summary_desc(fg)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) fg <- fg_clear_features(fg) fg_get_summary_desc(fg)
Removes all summary statistics in a flowGraph object; we recommend doing this to save space.
fg_clear_summary(fg)
fg_clear_summary(fg)
fg |
flowGraph object. |
flowGraph object with an empty summary
slot.
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores, node_features="count") fg_get_summary_desc(fg) fg <- fg_clear_summary(fg) fg_get_summary_desc(fg)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores, node_features="count") fg_get_summary_desc(fg) fg <- fg_clear_summary(fg) fg_get_summary_desc(fg)
fg_data_fca
fg_data_fca
fg_data_fca
A list containing the following elements derived from the flowCAP-II AML data set for cell populations up to layer 3.
count
: A numeric sample x cell population node
matrix with cell count values.
meta
: A data frame containing meta information on
samples in count
; it contains columns:
class
: a string indicating whether a sample is
from a "control" or "aml" subject.
id
: a string containing sample id's.
train
: a logical variable indicating whether
a sample is from the train or test set.
subject
: a numeric variable containing the
id of the subject from whom the sample came from.
tube
: the tube or panel number;
all samples in this data set is
analyzed under the 6th panel.
Aghaeepour N, Finak G, Hoos H, Mosmann TR, Brinkman R, Gottardo R, Scheuermann RH, Consortium F, Consortium DREAM, others (2013). “Critical assessment of automated flow cytometry data analysis techniques.” Nature methods, 10(3), 228–238.
fg_data_pos2
fg_data_pos2
fg_data_pos2
A list containing the following elements for a positive control data set with markers A, B, C, D. This is a positive control data set where node A+B+C+ increased by 50
count
: A numeric sample x cell population node
matrix with cell count values
meta
: A data frame containing meta information on
samples in count
; it contains columns:
id
: a string containing sample id's.
class
: a string indicating whether a sample is
from a "control" or "exp" (experiment) subject.
fg_data_pos30
fg_data_pos30
fg_data_pos30
A list containing the following elements for a positive control data set with markers A, B, C, D; note it was made with two and three thresholds for markers A and B to test functions with multiple thresholds (this is a positive control data set where nodes A+..B+..C+ increased by 50
count
: A numeric sample x cell population node
matrix with cell count values
meta
: A data frame containing meta information on
samples in count
; it contains columns:
id
: a string containing sample id's.
class
: a string indicating whether a sample is
from a "control" or "exp" (experiment) subject.
Extracts or removes a specified set of phenotypes from a flowGraph object.
fg_extract_phenotypes(fg, phenotypes)
fg_extract_phenotypes(fg, phenotypes)
fg |
flowGraph object. |
phenotypes |
A string vector of phenotype or cell population name labels. |
The summary
in fg
will not be modified;
we recommend users recalculate them.
flowGraph object.
flowGraph-class
fg_get_feature_desc
fg_merge
fg_extract_samples
fg_merge_samples
no_cores <- 1 data(fg_data_pos30) fg0 <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg_get_feature_desc(fg0) fg <- fg_extract_phenotypes(fg0, fg_get_graph(fg0)$v$phenotype[1:10]) fg_get_feature_desc(fg)
no_cores <- 1 data(fg_data_pos30) fg0 <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg_get_feature_desc(fg0) fg <- fg_extract_phenotypes(fg0, fg_get_graph(fg0)$v$phenotype[1:10]) fg_get_feature_desc(fg)
Returns a flowGraph object with only the count
feature
and meta data. This function clears all other features and
feature summaries to save space.
fg_extract_raw(fg)
fg_extract_raw(fg)
fg |
flowGraph object. |
flowGraph object with all summary statistics and feature values removed except for the node count feature.
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) fg <- fg_extract_raw(fg) show(fg)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) fg <- fg_extract_raw(fg) show(fg)
Extracts or removes a specified set of samples from a flowGraph object.
fg_extract_samples(fg, sample_ids, rm_summary = TRUE)
fg_extract_samples(fg, sample_ids, rm_summary = TRUE)
fg |
flowGraph object. |
sample_ids |
A string vector of sample id's that the user wants to
keep in |
rm_summary |
A logical indicating whether or not to clear summary. |
The summaries in fg
will not be modified;
we recommend the user recalculates them.
flowGraph object.
flowGraph-class
fg_get_feature_desc
fg_merge
fg_extract_phenotypes
no_cores <- 1 data(fg_data_pos30) fg0 <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg_get_feature_desc(fg0) fg <- fg_extract_samples(fg0, fg_get_meta(fg0)$id[1:5]) fg_get_feature_desc(fg)
no_cores <- 1 data(fg_data_pos30) fg0 <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg_get_feature_desc(fg0) fg <- fg_extract_samples(fg0, fg_get_meta(fg0)$id[1:5]) fg_get_feature_desc(fg)
Converts the cell counts in a flowGraph object into cumulated cell counts; this is optional and can be done only for there is more than one threshold for one or more markers. This should also only be ran when initializing a flowGraph object as converting back and forth is computationally expensive. If the user is interested in seeing non- and cumulated counts, we recommend keeping two flowGraph objects, one for each version. This function simply converts e.g. the count of A+ or A++ into the sum of count of A+, A++, and A+++ or A++, and A+++.
fg_feat_cumsum(fg, no_cores)
fg_feat_cumsum(fg, no_cores)
fg |
flowGraph object. |
no_cores |
An integer indicating how many cores to parallelize on. |
fg_feat_cumsum
returns the given flowGraph object with an
adjusted count feature. As in our example,
flowGraph object with cumulated counts.
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg <- flowGraph:::fg_feat_cumsum(fg, no_cores=no_cores)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg <- flowGraph:::fg_feat_cumsum(fg, no_cores=no_cores)
Generates the proportion edge feature and returns it inside the flowGraph object.
fg_feat_edge_prop(fg, no_cores = 1, overwrite = FALSE)
fg_feat_edge_prop(fg, no_cores = 1, overwrite = FALSE)
fg |
flowGraph object. |
no_cores |
An integer indicating how many cores to parallelize on. |
overwrite |
A logical variable indicating whether to overwrite the existing proportion edge feature if it exists. |
Given a flowGraph object, fg_feat_edge_prop
returns the same
flowGraph object with an additional proportions prop
edge
feature and its meta data. The proportions feature is
made using the node count
feature and is the cell count of each cell population (e.g. A+B+)
over the cell count of its parent (e.g. A+);
each edge then corresponds with such a relationship.
The edge feature matrix has column names <from>_<to> e.g. A+_A+B+.
flowGraph object containing the proportion edge feature.
flowGraph-class
fg_feat_node_prop
fg_feat_node_specenr
fg_add_feature
fg_get_feature
fg_rm_feature
fg_get_feature_desc
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg <- fg_feat_edge_prop(fg)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg <- fg_feat_edge_prop(fg)
Generates the SpecEnr edge feature and returns it inside the flowGraph object.
fg_feat_edge_specenr(fg, no_cores = 1, overwrite = FALSE)
fg_feat_edge_specenr(fg, no_cores = 1, overwrite = FALSE)
fg |
flowGraph object. |
no_cores |
An integer indicating how many cores to parallelize on. |
overwrite |
A logical variable indicating whether to overwrite the existing proportion edge feature if it exists. |
Given a flowGraph object, fg_feat_edge_SpecEnr
returns the same
flowGraph object with an additional SpecEnr and expected proportions
expect_prop
edge
feature and its meta data. The expected proportions edge feature is
calculated by taking the ratio of the child nodes' (e.g. A+B+)
expected proportion value over
its parent nodes' (e.g. A+) actual proportion value.
The SpecEnr feature is the actual over expected proportion ratio, logged.
The edge feature matrix has column names <from>_<to> e.g. A+_A+B+.
flowGraph object containing the proportion edge feature.
flowGraph-class
fg_feat_node_prop
fg_feat_node_specenr
fg_add_feature
fg_get_feature
fg_rm_feature
fg_get_feature_desc
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg <- fg_feat_edge_specenr(fg)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg <- fg_feat_edge_specenr(fg)
For each class label in column class
of meta
,
fg_feat_mean_class
takes the column mean of the rows in the given feature matrices
(as specified in node_features
and edge_features
)
associated with that class;
it then takes the difference point by point between these means and
the original rows for that class.
FUNCTION_DESCRIPTION
fg_feat_mean_class( fg, class, no_cores = 1, node_features = NULL, edge_features = NULL )
fg_feat_mean_class( fg, class, no_cores = 1, node_features = NULL, edge_features = NULL )
fg |
PARAM_DESCRIPTION |
class |
a column name in |
no_cores |
An integer indicating how many cores to parallelize on. |
node_features |
A string vector indicating the node features to
perform normalization on; set as |
edge_features |
A string vector indicating the edge features to
perform normalization on; set as |
For all features in the given flowGraph
object and for
each class label in column class
of meta
,
fg_feat_mean_class
. It takes the column mean of the rows in the given
feature matrices
(as specified in node_features
and edge_features
)
associated with that class;
it then takes the difference point by point between these means and
the original rows for that class.
fg_feat_mean_class
A numeric matrix whose dimensions equate to that of the input and whose values are normalized per class.
flowGraph object with normalized features.
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg <- fg_feat_mean_class(fg, class="class", node_features="count", no_cores=no_cores)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg <- fg_feat_mean_class(fg, class="class", node_features="count", no_cores=no_cores)
Generates the proportion node feature and returns it inside the returned flowGraph object.
fg_feat_node_prop(fg, overwrite = FALSE)
fg_feat_node_prop(fg, overwrite = FALSE)
fg |
flowGraph object. |
overwrite |
A logical variable indicating whether to overwrite the existing proportion node feature if it exists. |
Given a flowGraph object, fg_feat_node_prop
returns the same
flowGraph object, inside of which is an additional proportions prop
node
feature
and its meta data. The proportions feature is made using the node count
feature and is the cell count of each cell population over the total
cell count.
flowGraph object containing the proportion node feature.
flowGraph-class
fg_feat_node_specenr
fg_add_feature
fg_get_feature
fg_rm_feature
fg_get_feature_desc
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg <- fg_feat_node_prop(fg)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg <- fg_feat_node_prop(fg)
Generates the SpecEnr node feature and returns it inside the returned flowGraph object.
fg_feat_node_specenr(fg, no_cores = 1, feature = "prop", overwrite = FALSE)
fg_feat_node_specenr(fg, no_cores = 1, feature = "prop", overwrite = FALSE)
fg |
flowGraph object |
no_cores |
An integer indicating how many cores to parallelize on. |
feature |
A string indicating feature name; this is the feature SpecEnr will be calculated on. |
overwrite |
A logical variable indicating whether to overwrite the existing SpecEnr node feature if it exists. |
Given a flowGraph object, fg_feat_node_specenr
returns the same
flowGraph object with an additional SpecEnr
and expect_prop
node
feature and its meta data.
The expected proportions feature is made using the prop
node
and edge
features; therefore, the returned flowGraph will also
contain these two features. For details on how these feature is calculated.
flowGraph object containing the SpecEnr node feature.
Yue A, Chauve C, Libbrecht M, Brinkman R (2019). “Identifying differential cell populations in flow cytometry data accounting for marker frequency.” BioRxiv, 837765.
flowGraph-class
fg_feat_node_prop
fg_add_feature
fg_get_feature
fg_rm_feature
fg_get_feature_desc
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) # SpecEnr is by default calculated based on proportions fg <- fg_feat_node_specenr(fg, no_cores=no_cores) # SpecEnr can be calculated for other feature values too fg <- fg_feat_node_specenr(fg, feature="count") show(fg)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) # SpecEnr is by default calculated based on proportions fg <- fg_feat_node_specenr(fg, no_cores=no_cores) # SpecEnr can be calculated for other feature values too fg <- fg_feat_node_specenr(fg, feature="count") show(fg)
Retrieves a feature matrix from a given flowGraph object, the feature type, and feature name.
fg_get_feature(fg, type = "node", feature = "count")
fg_get_feature(fg, type = "node", feature = "count")
fg |
flowGraph object. |
type |
A string indicating feature type 'node' or 'edge'. |
feature |
A string indicating feature name; |
Returns NULL
if the requested feature does not exist.
A numeric matrix of the specified feature values.
flowGraph-class
fg_get_feature_desc
fg_add_feature
fg_rm_feature
fg_get_summary
data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=1) feature_matrix <- fg_get_feature(fg, type='node', feature='count')
data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=1) feature_matrix <- fg_get_feature(fg, type='node', feature='count')
Retrieves and/or recalculates a feature description table for a given flowGraph object.
fg_get_feature_desc(fg, re_calc = FALSE)
fg_get_feature_desc(fg, re_calc = FALSE)
fg |
flowGraph object. |
re_calc |
A logical variable specifying whether or not a feature summary
should be re-calculated or directly retrieved from |
A data frame where each row contains information on a feature
from the given flowGraph object; its columns is as in the feat_desc
slot of flowGraph-class
.
flowGraph-class
fg_get_feature
fg_add_feature
fg_rm_feature
fg_get_summary_desc
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) fg_get_feature_desc(fg, re_calc=TRUE)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) fg_get_feature_desc(fg, re_calc=TRUE)
Retrieves a feature summary (e.g. colMeans
) for samples
specified by sample id's id
OR class label
label
for class class
given a feature specified
by type
and feat
.
fg_get_feature_means( fg, type = c("node", "edge"), feature = "count", class = NULL, label = NULL, id = NULL, summary_fun = colMeans )
fg_get_feature_means( fg, type = c("node", "edge"), feature = "count", class = NULL, label = NULL, id = NULL, summary_fun = colMeans )
fg |
flowGraph object. |
type |
A string indicating feature type the summary was created for 'node' or 'edge'. |
feature |
A string indicating feature name the summary was created for; |
class |
A string corresponding to a column name of the |
label |
A string indicating a class label. |
id |
A string vector containing the sample id's corresponding to the
|
summary_fun |
A function that takes in a matrix and outputs a vector the same length as the number of columns this matrix has. |
A list containing two numeric vectors calculated using the
summary_fun
function on the subset of samples specified by
sample id's id
OR class label
label
for class class
from a feature matrix
specified by type
and feat
.
flowGraph-class
fg_get_summary_desc
fg_add_summary
fg_rm_summary
fg_get_summary
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) fg <- fg_summary(fg, no_cores=no_cores, class="class", label1="control", overwrite=FALSE, test_name="t", diminish=FALSE) show(fg) feat_mean <- fg_get_feature_means(fg, type="node", feature="count", class="class", label="control")
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) fg <- fg_summary(fg, no_cores=no_cores, class="class", label1="control", overwrite=FALSE, test_name="t", diminish=FALSE) show(fg) feat_mean <- fg_get_feature_means(fg, type="node", feature="count", class="class", label="control")
Retrieves a graph list from a given flowGraph object.
fg_get_graph(fg)
fg_get_graph(fg)
fg |
flowGraph object. |
A list containing two data frames (v
and ]codee)
from the graph
slot of the given flowGraph
object containing
information on the cell populations phenotype nodes and edges representing
relation between cell populations.
flowGraph-class
fg_plot
ggdf
plot_gr
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) gr <- fg_get_graph(fg) head(gr$v) head(gr$e)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) gr <- fg_get_graph(fg) head(gr$v) head(gr$e)
Retrieves the markers from a given flowGraph object.
fg_get_markers(fg)
fg_get_markers(fg)
fg |
flowGraph object. |
A character vector containing the markers used in a flowGraph object.
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg_get_markers(fg)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg_get_markers(fg)
Retrieves sample meta from a given flowGraph object.
fg_get_meta(fg)
fg_get_meta(fg)
fg |
flowGraph object. |
A data frame containing sample meta data.
flowGraph-class
fg_replace_meta
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) head(fg_get_meta(fg))
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) head(fg_get_meta(fg))
Retrieves a summary statistic from a given flowGraph object;
while fg
is required, the user can choose to input parameters
summary_meta
, index
, or all of type
,
feat
, test_name
, class
, label1
, and label2
.
See fg_get_summary_desc
for details.
fg_get_summary( fg, type = "node", index = NULL, summary_meta = NULL, adjust_custom = "byLayer", SpecEnr_filt = TRUE, summary_fun = colMeans, adjust0_lim = c(-0.1, 0.1), filter_adjust0 = 1, filter_es = 0, filter_btwn_tpthres = 0.05, filter_btwn_es = 0.5, default_p_thres = 1 )
fg_get_summary( fg, type = "node", index = NULL, summary_meta = NULL, adjust_custom = "byLayer", SpecEnr_filt = TRUE, summary_fun = colMeans, adjust0_lim = c(-0.1, 0.1), filter_adjust0 = 1, filter_es = 0, filter_btwn_tpthres = 0.05, filter_btwn_es = 0.5, default_p_thres = 1 )
fg |
flowGraph object. |
type |
A string indicating feature type the summary was created for 'node' or 'edge'. |
index |
The user must provide
|
summary_meta |
The user must provide
|
adjust_custom |
A function or a string indicating the
test adjustment method to use.
If a string is provided, it should be one of
|
SpecEnr_filt |
A logicle indicating whether or not to filter p-values for SpecEnr. |
summary_fun |
A function that takes in a matrix and outputs a
vector the same length as the number of columns this matrix has.
Set to |
adjust0_lim |
A vector of two numeric values indicating a range around 0, default set to -0.1 and 0.1. |
filter_adjust0 |
A numeric variable indicating what percentage of
SpecEnr values compared (minimum) should be not close to 0.
Set to 1 to not conduct filtering. Original p-values stored in
|
filter_es |
A numeric variable between 0 and 1 indicating what the Cohen's D value of the nodes/edges in question must be greater or equal to, to be significant. |
filter_btwn_tpthres |
A numeric variable between 0 and 1 indicating the
unadjusted T-test p-value threshold used to test whether the actual
and expected feature values used to calculate the specified SpecEnr
feature are significantly different for each sample class. Note this only
needs to be specified for SpecEnr features. Combined
with |
filter_btwn_es |
A numeric variable between 0 and 1 indicating what the
Cohen's D value of the nodes/edges in question must be greater or
equal to, to be significant – see |
default_p_thres |
A numeric variable indicating the p-value threshold
user is using. Currently, all nodes/edges not passing the |
A list containing elements on feature summary retrieved by the user
as in the summary
slot of
flowGraph-class
.
If summary_fun
is not NULL
, this list also includes:
m1
: a numeric vector the same length as values
;
this is a summary of the samples compared e.g. mean.
m2
: a numeric vector the same length as values
;
this is a summary of the samples compared e.g. mean.
cohensd
: a numberic vector indicating cohen's d values
considering effect size.
cohensd_size
: a factor vector interpreting cohen's d values.
adjust0
: a numeric vector indicating the percentage of
samples that have a SpecEnr value in the range of adjust0_lim
around 0; if there are two classes of samples being compared, we output
the smaller percentage between the two classes.
btwn
: a data frame containing columns:
tpv1
: unadjusted p-value calculated
between the actual and expected raw feature values of class 1.
tpv2
: unadjusted p-value calculated
between the actual and expected raw feature values of class 2.
cd1
: Cohen's D between the actual and expected raw
feature values of class 1.
cd2
: Cohen's D between the actual and expected raw
feature values of class 2.
btp
: unadjusted p-value calculated between the
difference between actual and expected raw feature of the two classes.
bcd
: Cohen's D calculated between the
difference between actual and expected raw feature of the two classes.
btp_
: unadjusted p-value calculated between the
log ratio between actual and expected raw feature of the two classes.
bcd_
: Cohen's D calculated between the
log ratio between actual and expected raw feature of the two classes.
flowGraph-class
fg_get_feature_means
fg_get_summary_desc
fg_add_summary
fg_rm_summary
fg_get_feature
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) # set features to NULL to apply summary statistic to all features. fg <- fg_summary(fg, no_cores=no_cores, class="class", label1="control", overwrite=FALSE, test_name="t", diminish=FALSE, node_features=NULL, edge_features=NULL) show(fg) feat_summ <- fg_get_summary(fg, type="node", summary_meta=list( feature="SpecEnr", test_name="t", class="class", label1="control", label2="exp"))
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) # set features to NULL to apply summary statistic to all features. fg <- fg_summary(fg, no_cores=no_cores, class="class", label1="control", overwrite=FALSE, test_name="t", diminish=FALSE, node_features=NULL, edge_features=NULL) show(fg) feat_summ <- fg_get_summary(fg, type="node", summary_meta=list( feature="SpecEnr", test_name="t", class="class", label1="control", label2="exp"))
Retrieves a feature summary description table for a given flowGraph object.
fg_get_summary_desc(fg)
fg_get_summary_desc(fg)
fg |
flowGraph object. |
A data frame where each row contains information
on a feature summary from fg
:
type
: feature type (i.e. 'node' or 'edge').
feat
: feature name.
test_name
: summary name.
class
: class or the column name of fg_get_meta(fg)
whose values represent the class label of each sample on which
the summary was created for.
label1
: A string from the class
column of the
meta
slot indicating the label of samples compared.
label2
: A string from the class
column of the
meta
slot indicating the label of samples compared.
flowGraph-class
fg_get_summary
fg_add_summary
fg_rm_summary
fg_get_feature_desc
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) fg_get_summary_desc(fg)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) fg_get_summary_desc(fg)
Retrieves the index of the requested summary from a given flowGraph object.
fg_get_summary_index(fg, type = "node", index = NULL, summary_meta = NULL)
fg_get_summary_index(fg, type = "node", index = NULL, summary_meta = NULL)
fg |
flowGraph object. |
type |
A string indicating feature type the summary was created for 'node' or 'edge'. |
index |
The user must provide
|
summary_meta |
The user must provide
|
An integer analagous to index
.
If both index
and summary_meta
are NULL
, returns 1.
flowGraph-class
fg_get_summary_desc
fg_add_summary
fg_rm_summary
fg_plot
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) # set features to NULL to apply summary statistic to all features. fg <- fg_summary(fg, no_cores=no_cores, class="class", label1="control", overwrite=FALSE, test_name="t", diminish=FALSE, node_features=NULL, edge_features=NULL) show(fg) index <- flowGraph:::fg_get_summary_index( fg, type="node", summary_meta=list( feature="SpecEnr", test_name="t", class="class", label1="control", label2="exp"))
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) # set features to NULL to apply summary statistic to all features. fg <- fg_summary(fg, no_cores=no_cores, class="class", label1="control", overwrite=FALSE, test_name="t", diminish=FALSE, node_features=NULL, edge_features=NULL) show(fg) index <- flowGraph:::fg_get_summary_index( fg, type="node", summary_meta=list( feature="SpecEnr", test_name="t", class="class", label1="control", label2="exp"))
Retrieves a table containing all node or edge summary statistics given a flowGraph object.
fg_get_summary_tables(fg, type = "node")
fg_get_summary_tables(fg, type = "node")
fg |
flowGraph object. |
type |
A string indicating feature type the summaries the user wants to retrieve were created for, 'node' or 'edge'. |
A list; this output is the same as that of function
fg_get_graph
with additional columns.
These columns contain summary statistics from the summary
slot of the flowGraph object. These columns are named:
<feature type: node/edge>.<feature>.<summary name>.<class>.<class labels>.
flowGraph-class
fg_get_feature_means
fg_get_summary_desc
fg_add_summary
fg_rm_summary
fg_get_summary
fg_get_feature
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) fg <- fg_summary(fg, no_cores=no_cores, class="class", label1="control", overwrite=FALSE, test_name="t", diminish=FALSE) show(fg) feat_summ_table_node <- fg_get_summary_tables(fg, type="node") head(feat_summ_table_node)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) fg <- fg_summary(fg, no_cores=no_cores, class="class", label1="control", overwrite=FALSE, test_name="t", diminish=FALSE) show(fg) feat_summ_table_node <- fg_get_summary_tables(fg, type="node") head(feat_summ_table_node)
Replace sample id's in a flowGraph object.
fg_gsub_ids(fg, ids_new, ids_old = NULL)
fg_gsub_ids(fg, ids_new, ids_old = NULL)
fg |
flowGraph object. |
ids_new |
A string vector of new sample id's; if |
ids_old |
A string vector of old sample id's the user wants to replace;
these marker names corresponding to those
in |
flowGraph object with sample id's replaced.
flowGraph-class
fg_get_feature_desc
fg_gsub_markers
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg <- fg_gsub_ids(fg, ids_new=paste0(fg_get_meta(fg)$id, "_new"))
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg <- fg_gsub_ids(fg, ids_new=paste0(fg_get_meta(fg)$id, "_new"))
Replace marker names in a flowGraph object.
fg_gsub_markers(fg, markers_new, markers_old = NULL)
fg_gsub_markers(fg, markers_new, markers_old = NULL)
fg |
flowGraph object. |
markers_new |
A string vector of new marker names;
if |
markers_old |
A string vector of old marker names user wants to replace;
these marker names corresponding to those
in |
flowGraph object with marker names replaced.
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg <- fg_gsub_markers(fg, c("Anew", "Bnew", "Cnew", "Dnew")) fg_get_feature_desc(fg)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg <- fg_gsub_markers(fg, c("Anew", "Bnew", "Cnew", "Dnew")) fg_get_feature_desc(fg)
Load a flowGraph object from a specified folder path.
fg_load(folder_path)
fg_load(folder_path)
folder_path |
A string indicating the folder path to where a flowGraph
object was saved using the |
see function fg_save
flowGraph object
no_cores <- 1 data(fg_data_pos2) fg <- flowGraph(fg_data_pos2$count, class=fg_data_pos2$meta$class, no_cores=no_cores) fg_save(fg, "tmp") fg <- fg_load("tmp")
no_cores <- 1 data(fg_data_pos2) fg <- flowGraph(fg_data_pos2$count, class=fg_data_pos2$meta$class, no_cores=no_cores) fg_save(fg, "tmp") fg <- fg_load("tmp")
Merges two flowGraph objects together.
fg_merge( fg1, fg2, method_sample = c("union", "intersect", "setdiff", "none"), method_phenotype = c("intersect", "setdiff", "none") )
fg_merge( fg1, fg2, method_sample = c("union", "intersect", "setdiff", "none"), method_phenotype = c("intersect", "setdiff", "none") )
fg1 |
flowGraph object. |
fg2 |
flowGraph object. |
method_sample |
A string indicating how samples from flowGraph objects should be merged:
|
method_phenotype |
A string indicating how phenotypes from flowGraph objects should be merged:
|
fg_merge
is a generic function that merges the samples and
phenotypes of two flowGraph objects.
Note that if method_sample="union"
then method_phenotype
must be set to "intersect".
flowGraph object.
flowGraph-class
fg_extract_samples
fg_extract_phenotypes
fg_merge_samples
no_cores <- 1 data(fg_data_pos30) fg0 <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg1 <- fg_extract_samples(fg0, fg_get_meta(fg0)$id[1:5]) fg2 <- fg_extract_samples(fg0, fg_get_meta(fg0)$id[4:7]) fg <- fg_merge(fg1, fg2, method_sample="intersect", method_phenotype="intersect") fg_get_feature_desc(fg)
no_cores <- 1 data(fg_data_pos30) fg0 <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg1 <- fg_extract_samples(fg0, fg_get_meta(fg0)$id[1:5]) fg2 <- fg_extract_samples(fg0, fg_get_meta(fg0)$id[4:7]) fg <- fg_merge(fg1, fg2, method_sample="intersect", method_phenotype="intersect") fg_get_feature_desc(fg)
Merges the samples from two flowGraph objects together;
we recommend removing all summary statistics from the new flowGraph object
as those won't be adjusted: fg_clear_summary
.
fg_merge_samples(fg1, fg2)
fg_merge_samples(fg1, fg2)
fg1 |
flowGraph object. |
fg2 |
flowGraph object. |
Appends the samples from fg2
onto those in fg1
.
This function requires that the two flowGraph objects must have the
same phenotypes. Therefore, we recommend users to use,
instead, fg_merge
.
flowGraph object.
flowGraph-class
fg_get_feature_desc
fg_merge
fg_extract_samples
no_cores <- 1 data(fg_data_pos30) fg0 <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg1 <- fg_extract_samples(fg0, fg_get_meta(fg0)$id[1:5]) fg2 <- fg_extract_samples(fg0, fg_get_meta(fg0)$id[4:7]) fg <- fg_merge_samples(fg1, fg2) fg_get_feature_desc(fg)
no_cores <- 1 data(fg_data_pos30) fg0 <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg1 <- fg_extract_samples(fg0, fg_get_meta(fg0)$id[1:5]) fg2 <- fg_extract_samples(fg0, fg_get_meta(fg0)$id[4:7]) fg <- fg_merge_samples(fg1, fg2) fg_get_feature_desc(fg)
Creates a cell hierarchy plot given a flowGraph object. If a path is not provided for fg_plot
to save the plot, please use plot_gr
to view plot given the output of fg_plot
.
fg_plot( fg, type = "node", index = 1, summary_meta = NULL, adjust_custom = "byLayer", show_nodes_edges = NULL, label_max = 30, p_thres = 0.05, filter_adjust0 = 1, filter_es = 0, filter_btwn_tpthres = 1, filter_btwn_es = 0, node_labels = c("prop", "expect_prop"), summary_fun = colMeans, layout_fun = NULL, show_bgedges = TRUE, main = NULL, interactive = FALSE, visNet_plot = TRUE, path = NULL, width = 9, height = 9 )
fg_plot( fg, type = "node", index = 1, summary_meta = NULL, adjust_custom = "byLayer", show_nodes_edges = NULL, label_max = 30, p_thres = 0.05, filter_adjust0 = 1, filter_es = 0, filter_btwn_tpthres = 1, filter_btwn_es = 0, node_labels = c("prop", "expect_prop"), summary_fun = colMeans, layout_fun = NULL, show_bgedges = TRUE, main = NULL, interactive = FALSE, visNet_plot = TRUE, path = NULL, width = 9, height = 9 )
fg |
flowGraph object. |
type |
A string indicating feature type the summary was created for 'node' or 'edge'. |
index |
The user must provide
|
summary_meta |
The user must provide
|
adjust_custom |
A function or a string indicating the
test adjustment method to use.
If a string is provided, it should be one of
|
show_nodes_edges |
A logical vector indicating which nodes/edges (type) to show in the plot; if this is not specified, only nodes/edges with significant summary statistics will be shown. |
label_max |
An integer specifying the maximum number of nodes to label. |
p_thres |
A double indicating a summary statistic threshold e.g. if we are plotting a T test summary statistic, we can set the threshold to .05; nodes with a p-value greater than .05 will not be plotted. |
filter_adjust0 |
A numeric variable indicating what percentage of SpecEnr values compared (minimum) should be not close to 0. Set to 1 to not conduct filtering. |
filter_es |
A numeric variable between 0 and 1 indicating what the Cohen's D value of the nodes/edges in question must be greater or equal to, to be significant. |
filter_btwn_tpthres |
A numeric variable between 0 and 1 indicating the
unadjusted T-test p-value threshold used to test whether the actual
and expected feature values used to calculate the specified SpecEnr
feature are significantly different for each sample class. Note this only
needs to be specified for SpecEnr features. Combined
with |
filter_btwn_es |
A numeric variable between 0 and 1 indicating what the
Cohen's D value of the nodes/edges in question must be greater or
equal to, to be significant – see |
node_labels |
A string vector indicating which node feature(s) should be used to label a node. We recommend keeping the length of this vector to below 2. Set to "NONE" if no p-value labels are needed. |
summary_fun |
A function that takes in a matrix and outputs a
vector the same length as the number of columns this matrix has;
see |
layout_fun |
A string representing a function from the
|
show_bgedges |
A logical variable indicating whether or not edges not specified for plotting should be plotted as light grey in the background. |
main |
A string or the title of the plot; if left as |
interactive |
A logical variable indicating whether the plot should be
an interactive plot; see package |
visNet_plot |
A logical variable indicating if an interactive plot is
chosen, if function should output a visNetwork plot; if set to |
path |
A string indicating the path to where the function should save
the plot; leave as |
width |
A numeric variable specifying, in inches, what the plot width should be. |
height |
A numeric variable specifying, in inches, what the plot height should be. |
fg_plot
takes a flowGraph object as input and returns the
graph
slot of the given object with additional columns to serve as
input into plot_gr
for plotting using functions
in the ggplot2
package. Users can choose to save a PNG version of
the plot by filling out the path
parameter with a full path to the
PNG plot. In addition to specifying columns added from
ggdf
, fg_plot
also adds label column(s)
whose values serve as labels in the interactive version of the plot.
A list of nodes and edges for plotting with the plot_gr
function. Other elements in this list include show_bgedges
,
which has the same value as parameter show_bgedges
, and main
,
the title of the plot.
flowGraph-class
get_phen_meta
ggdf
plot_gr
fg_get_feature
fg_get_summary
no_cores <- 1 data(fg_data_pos2) fg <- flowGraph(fg_data_pos2$count, class=fg_data_pos2$meta$class, no_cores=no_cores) gr <- fg_plot(fg, type="node", index=1, label_max=30, show_nodes_edges=NULL, p_thres=.01, node_labels=c("prop", "expect_prop"), path=NULL) # set path to a full path to save plot as a PNG # plot_gr(gr)
no_cores <- 1 data(fg_data_pos2) fg <- flowGraph(fg_data_pos2$count, class=fg_data_pos2$meta$class, no_cores=no_cores) gr <- fg_plot(fg, type="node", index=1, label_max=30, show_nodes_edges=NULL, p_thres=.01, node_labels=c("prop", "expect_prop"), path=NULL) # set path to a full path to save plot as a PNG # plot_gr(gr)
Creates a boxplot comparing the features of samples belonging to different classes corresponding to an existing summary statistic using ggplot2.
fg_plot_box( fg, type = "node", index = 1, summary_meta = NULL, node_edge = 1, adjust_custom = "byLayer", p_thres = 0.05, filter_adjust0 = 0.5, filter_es = 0.5, filter_btwn_tpthres = 0.05, filter_btwn_es = 0.5, paired = FALSE, dotplot = TRUE, outlier = TRUE, all_labels = FALSE, show_mean = TRUE, main = NULL, path = NULL )
fg_plot_box( fg, type = "node", index = 1, summary_meta = NULL, node_edge = 1, adjust_custom = "byLayer", p_thres = 0.05, filter_adjust0 = 0.5, filter_es = 0.5, filter_btwn_tpthres = 0.05, filter_btwn_es = 0.5, paired = FALSE, dotplot = TRUE, outlier = TRUE, all_labels = FALSE, show_mean = TRUE, main = NULL, path = NULL )
fg |
flowGraph object. |
type |
A string indicating feature type the summary was created for 'node' or 'edge'. |
index |
The user must provide
|
summary_meta |
The user must provide
|
node_edge |
An integer/index of or a string of the cell population (node) / edge name (edge) the user wants to plot. |
adjust_custom |
A function or a string indicating the
test adjustment method to use.
If a string is provided, it should be one of
|
p_thres |
A numeric variable indicating a p-value threshold |
filter_adjust0 |
A numeric variable indicating what percentage of SpecEnr values compared (minimum) should be not close to 0. Set to 1 to not conduct filtering. |
filter_es |
A numeric variable between 0 and 1 indicating what the Cohen's D value of the nodes/edges in question must be greater or equal to, to be significant. |
filter_btwn_tpthres |
A numeric variable between 0 and 1 indicating the
unadjusted T-test p-value threshold used to test whether the actual
and expected feature values used to calculate the specified SpecEnr
feature are significantly different for each sample class. Note this only
needs to be specified for SpecEnr features. Combined
with |
filter_btwn_es |
A numeric variable between 0 and 1 indicating what the
Cohen's D value of the nodes/edges in question must be greater or
equal to, to be significant – see |
paired |
A logical indicating whether the summary is paired. |
dotplot |
A logical indicating whether or not to plot sample points. |
outlier |
A logical indicating whether or not outliers should be plotted. |
all_labels |
A logical indicating whether or not to plot samples of all classes outside of just those used in the summary statistic test. |
show_mean |
A logical indicating whether or not to label the mean. |
main |
A string or the title of the plot; if left as |
path |
A string indicating the path to where the function should save
the plot; leave as |
The plot is made using the ggplot2
package. The interactive
version is the same as the static version, it is only here to support the
shiny app.
A static boxplot.
flowGraph-class
fg_plot
plot_gr
fg_get_feature
fg_get_summary
fg_plot_qq
no_cores <- 1 data(fg_data_pos2) fg <- flowGraph(fg_data_pos2$count, class=fg_data_pos2$meta$class, no_cores=no_cores) fg_plot_box(fg, type="node", summary_meta=NULL, adjust_custom="byLayer", index=1, node_edge=10)
no_cores <- 1 data(fg_data_pos2) fg <- flowGraph(fg_data_pos2$count, class=fg_data_pos2$meta$class, no_cores=no_cores) fg_plot_box(fg, type="node", summary_meta=NULL, adjust_custom="byLayer", index=1, node_edge=10)
Creates a p value vs feature difference plot where the difference is that of the features of samples belonging to different classes corresponding to an existing summary statistic.
fg_plot_pVSdiff( fg, type = "node", index = 1, summary_meta = NULL, adjust_custom = "byLayer", logged = TRUE, label_max = 5, p_thres = 0.05, filter_adjust0 = 1, filter_es = 0, filter_btwn_tpthres = 1, filter_btwn_es = 0, shiny_plot = FALSE, nodes_max = 30, main = NULL, interactive = FALSE, path = NULL )
fg_plot_pVSdiff( fg, type = "node", index = 1, summary_meta = NULL, adjust_custom = "byLayer", logged = TRUE, label_max = 5, p_thres = 0.05, filter_adjust0 = 1, filter_es = 0, filter_btwn_tpthres = 1, filter_btwn_es = 0, shiny_plot = FALSE, nodes_max = 30, main = NULL, interactive = FALSE, path = NULL )
fg |
flowGraph object. |
type |
A string indicating feature type the summary was created for 'node' or 'edge'. |
index |
The user must provide
|
summary_meta |
The user must provide
|
adjust_custom |
A function or a string indicating the
test adjustment method to use.
If a string is provided, it should be one of
|
logged |
A logical indicating whether or not to log the summary statistic p value. |
label_max |
An integer indicating the maximum number of max difference and/or min p value nodes/edges that should be labelled. |
p_thres |
A numeric variable indicating a p-value threshold; a line will be plotted at this threshold. |
filter_adjust0 |
A numeric variable indicating what percentage of SpecEnr values compared (minimum) should be not close to 0. Set to 1 to not conduct filtering. |
filter_es |
A numeric variable between 0 and 1 indicating what the Cohen's D value of the nodes/edges in question must be greater or equal to, to be significant. |
filter_btwn_tpthres |
A numeric variable between 0 and 1 indicating the
unadjusted T-test p-value threshold used to test whether the actual
and expected feature values used to calculate the specified SpecEnr
feature are significantly different for each sample class. Note this only
needs to be specified for SpecEnr features. Combined
with |
filter_btwn_es |
A numeric variable between 0 and 1 indicating what the
Cohen's D value of the nodes/edges in question must be greater or
equal to, to be significant – see |
shiny_plot |
A logical indicating whether this plot is made for shiny; users don't need to change this. |
nodes_max |
An integer indicating maximum number of nodes to plot; this limit is set for interactive plots only. |
main |
A string or the title of the plot; if left as |
interactive |
A logical variable indicating whether the plot should be
an interactive plot; see package |
path |
A string indicating the path to where the function should save
the plot; leave as |
The interactive plot is made using the ggiraph
package.
A static or interactive p value vs difference plot.
flowGraph-class
fg_plot
plot_gr
fg_get_feature
fg_get_summary
fg_plot_qq
no_cores <- 1 data(fg_data_pos2) fg <- flowGraph(fg_data_pos2$count, class=fg_data_pos2$meta$class, no_cores=no_cores) gp <- fg_plot_pVSdiff(fg, type="node", summary_meta=NULL, adjust_custom="byLayer", index=1, label_max=10)
no_cores <- 1 data(fg_data_pos2) fg <- flowGraph(fg_data_pos2$count, class=fg_data_pos2$meta$class, no_cores=no_cores) gp <- fg_plot_pVSdiff(fg, type="node", summary_meta=NULL, adjust_custom="byLayer", index=1, label_max=10)
Creates a QQ plot of a summary statistic.
fg_plot_qq( fg, type = "node", index = 1, summary_meta = NULL, adjust_custom = "byLayer", logged = TRUE, p_thres = 0.05, filter_adjust0 = 1, filter_es = 0, filter_btwn_tpthres = 1, filter_btwn_es = 0, shiny_plot = FALSE, main = NULL, interactive = FALSE, path = NULL )
fg_plot_qq( fg, type = "node", index = 1, summary_meta = NULL, adjust_custom = "byLayer", logged = TRUE, p_thres = 0.05, filter_adjust0 = 1, filter_es = 0, filter_btwn_tpthres = 1, filter_btwn_es = 0, shiny_plot = FALSE, main = NULL, interactive = FALSE, path = NULL )
fg |
flowGraph object. |
type |
A string indicating feature type the summary was created for 'node' or 'edge'. |
index |
The user must provide
|
summary_meta |
The user must provide
|
adjust_custom |
A function or a string indicating the
test adjustment method to use.
If a string is provided, it should be one of
|
logged |
A logical indicating whether or not to log the summary statistic p value. |
p_thres |
A double indicating a summary statistic threshold e.g. if we are plotting a T-test summary statistic, we can set the threshold to .05; nodes with a p-value greater than .05 will not be plotted. |
filter_adjust0 |
A numeric variable indicating what percentage of SpecEnr values compared (minimum) should be not close to 0. Set to 1 to not conduct filtering. |
filter_es |
A numeric variable between 0 and 1 indicating what the Cohen's D value of the nodes/edges in question must be greater or equal to, to be significant. |
filter_btwn_tpthres |
A numeric variable between 0 and 1 indicating the
unadjusted T-test p-value threshold used to test whether the actual
and expected feature values used to calculate the specified SpecEnr
feature are significantly different for each sample class. Note this only
needs to be specified for SpecEnr features. Combined
with |
filter_btwn_es |
A numeric variable between 0 and 1 indicating what the
Cohen's D value of the nodes/edges in question must be greater or
equal to, to be significant – see |
shiny_plot |
A logical indicating whether this plot is made for shiny; users don't need to change this. |
main |
A string or the title of the plot; if left as |
interactive |
A logical indicating whether or not plot should be an interactive ggiraph plot as opposed to a static plot. |
path |
A string indicating the path to where the function should save
the plot; leave as |
The interactive plot is made using the ggiraph
package.
A static or interactive qq plot.
flowGraph-class
fg_plot
plot_gr
fg_get_feature
fg_get_summary
no_cores <- 1 data(fg_data_pos2) fg <- flowGraph(fg_data_pos2$count, class=fg_data_pos2$meta$class, no_cores=no_cores) fg_plot_qq(fg, type="node", summary_meta=NULL, adjust_custom="byLayer", index=1, interactive=TRUE, logged=FALSE) fg_plot_qq(fg, type="node", summary_meta=NULL, adjust_custom="byLayer", index=1, interactive=FALSE, logged=FALSE)
no_cores <- 1 data(fg_data_pos2) fg <- flowGraph(fg_data_pos2$count, class=fg_data_pos2$meta$class, no_cores=no_cores) fg_plot_qq(fg, type="node", summary_meta=NULL, adjust_custom="byLayer", index=1, interactive=TRUE, logged=FALSE) fg_plot_qq(fg, type="node", summary_meta=NULL, adjust_custom="byLayer", index=1, interactive=FALSE, logged=FALSE)
Replaces sample meta in a given flowGraph object.
fg_replace_meta(fg, meta)
fg_replace_meta(fg, meta)
fg |
flowGraph object. |
meta |
A data frame containing meta data; see details in
|
A flowGraph object with an updated sample meta.
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) head(fg_get_meta(fg)) new_df <- fg_data_pos30$meta new_df$id[1] <- "newID" fg <- fg_replace_meta(fg, new_df) head(fg_get_meta(fg))
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) head(fg_get_meta(fg)) new_df <- fg_data_pos30$meta new_df$id[1] <- "newID" fg <- fg_replace_meta(fg, new_df) head(fg_get_meta(fg))
Removes a feature from a given flowGraph object.
fg_rm_feature(fg, type = "node", feature = NULL)
fg_rm_feature(fg, type = "node", feature = NULL)
fg |
flowGraph object. |
type |
A string specifying the type of the feature being removed i.e. 'node' or 'edge'. |
feature |
A string indicating the unique name of the feature removed; note we cannot remove the 'node' 'count' feature type. |
fg_rm_feature
removes a specified feature matrix from the
given flowGraph object fg
updating slots
feat
and feat_desc
.
See flowGraph-class
slot feat
and feat_desc
for what should be in these slots.
flowGraph object with specified feature removed.
flowGraph-class
fg_add_feature
fg_get_feature
fg_get_feature_desc
fg_rm_summary
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) fg_get_feature_desc(fg) fg <- fg_rm_feature(fg, type="node", feature="prop") fg_get_feature_desc(fg)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) fg_get_feature_desc(fg) fg <- fg_rm_feature(fg, type="node", feature="prop") fg_get_feature_desc(fg)
Removes a feature summary from a given flowGraph object;
while fg
is required, the user can choose to input parameters
summary_meta
, index
, or all of type
,
feat
, test_name
, class
, label1
,
and label2
.
See fg_get_summary_desc
for details.
fg_rm_summary(fg, type = "node", index = NULL, summary_meta = NULL)
fg_rm_summary(fg, type = "node", index = NULL, summary_meta = NULL)
fg |
flowGraph object. |
type |
A string indicating feature type the summary was created for; 'node' or 'edge'. |
index |
The user must provide
|
summary_meta |
The user must provide
|
flowGraph object.
flowGraph-class
fg_get_summary
fg_add_summary
fg_get_summary_desc
fg_rm_feature
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg <- fg_summary(fg, no_cores=no_cores, class="class", label1="control", overwrite=FALSE, test_name="wilcox_byLayer", diminish=FALSE, node_features=NULL, edge_features=NULL) fg_get_summary_desc(fg) fg <- fg_rm_summary(fg, summary_meta=c( feature="count",test_name="wilcox_byLayer", class="class", label1="control", label2="exp")) fg_get_summary_desc(fg)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg <- fg_summary(fg, no_cores=no_cores, class="class", label1="control", overwrite=FALSE, test_name="wilcox_byLayer", diminish=FALSE, node_features=NULL, edge_features=NULL) fg_get_summary_desc(fg) fg <- fg_rm_summary(fg, summary_meta=c( feature="count",test_name="wilcox_byLayer", class="class", label1="control", label2="exp")) fg_get_summary_desc(fg)
Saves flowGraph object to a specified path.
fg_save(fg, folder_path = NULL, save_plots = TRUE, paired = FALSE, ...)
fg_save(fg, folder_path = NULL, save_plots = TRUE, paired = FALSE, ...)
fg |
flowGraph object to save. |
folder_path |
A string indicating the folder path to where the flowGraph
object should save its elements; if this is the first time the object is
being saved, this folder should be empty or if it is
not yet created, the function will create it. If the object has previously
been saved before and this parameter is set to |
save_plots |
A logical indicating whether or not to save plots. |
paired |
A logical indicating whether the summary is paired; used in
function |
... |
Other parameters for the |
See generated README.md file.
TRUE if flowGraph object successfully saved.
length
,c("nrow", "nrow")
,NULL
map
no_cores <- 1 data(fg_data_pos2) fg <- flowGraph(fg_data_pos2$count, class=fg_data_pos2$meta$class, no_cores=no_cores) fg_save(fg, "tmp")
no_cores <- 1 data(fg_data_pos2) fg <- flowGraph(fg_data_pos2$count, class=fg_data_pos2$meta$class, no_cores=no_cores) fg_save(fg, "tmp")
Saves numerous plots for all summary statistics in a given flowGraph object to a user specified folder.
fg_save_plots( fg, plot_path, plot_types = "node", interactive = FALSE, adjust_custom = "byLayer", label_max = 10, box_no = 20, paired = FALSE, logged = FALSE, filter_adjust0 = 1, filter_es = 0, filter_btwn_tpthres = 1, filter_btwn_es = 0, overwrite = TRUE, node_labels = "NONE", ... )
fg_save_plots( fg, plot_path, plot_types = "node", interactive = FALSE, adjust_custom = "byLayer", label_max = 10, box_no = 20, paired = FALSE, logged = FALSE, filter_adjust0 = 1, filter_es = 0, filter_btwn_tpthres = 1, filter_btwn_es = 0, overwrite = TRUE, node_labels = "NONE", ... )
fg |
flowGraph object. |
plot_path |
A string indicating the folder path to where the function should save the plots. |
plot_types |
A string or a vector of strings indicating what feature types and their summaries the function should plot for: 'node' or 'edge'. |
interactive |
A logical indicating whether the QQ plot, p-value vs
difference plot, and the
cell hierarchy plots should be interactive; see functions
|
adjust_custom |
A function or a string indicating the
test adjustment method to use.
If a string is provided, it should be one of
|
label_max |
An integer indicating how many labels should be shown
in the functions |
box_no |
An integer indicating the maximum number of boxplots to save;
used in function |
paired |
A logical indicating whether the summary is paired; used in
function |
logged |
A logical indicating whether or not to log the summary statistic p value in the qq plots. |
filter_adjust0 |
A numeric variable indicating what percentage of SpecEnr values compared (minimum) should be not close to 0. Set to 1 to not conduct filtering. This parameter is used for the QQ and the pVSdifference plots. |
filter_es |
A numeric variable between 0 and 1 indicating what the Cohen's D value of the nodes/edges in question must be greater or equal to, to be significant. |
filter_btwn_tpthres |
A numeric variable between 0 and 1 indicating the
unadjusted T-test p-value threshold used to test whether the actual
and expected feature values used to calculate the specified SpecEnr
feature are significantly different for each sample class. Note this only
needs to be specified for SpecEnr features. Combined
with |
filter_btwn_es |
A numeric variable between 0 and 1 indicating what the
Cohen's D value of the nodes/edges in question must be greater or
equal to, to be significant – see |
overwrite |
A logical variable indicating whether or not to replace old plots if they exist under the same folder name. |
node_labels |
Parameter for the |
... |
Other parameters for the |
The interactive plots are made using the ggiraph
package.
No return; plots are saved to file.
flowGraph-class
fg_plot
plot_gr
fg_get_feature
fg_get_summary
fg_plot_qq
fg_plot_pVSdiff
fg_plot_box
no_cores <- 1 data(fg_data_pos2) fg <- flowGraph(fg_data_pos2$count, class=fg_data_pos2$meta$class, no_cores=no_cores) fg_save_plots(fg, "temp")
no_cores <- 1 data(fg_data_pos2) fg <- flowGraph(fg_data_pos2$count, class=fg_data_pos2$meta$class, no_cores=no_cores) fg_save_plots(fg, "temp")
Determines cell hierarchy layout and returns the X, Y coordinate
of each cell population. This function is a wrapper for
set_layout_graph
.
fg_set_layout(fg, layout_fun = "layout.reingold.tilford")
fg_set_layout(fg, layout_fun = "layout.reingold.tilford")
fg |
flowGraph object. |
layout_fun |
A string version of a function name from
the |
Given a flowGraph object, modifies the graph
slot such that
it contains X, Y axes for each node in accordance to a user specified
layout.
flowGraph object with coordinate meta data on cell populations and edges for plotting use.
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg <- fg_set_layout(fg) head(fg_get_graph(fg)$v)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg <- fg_set_layout(fg) head(fg_get_graph(fg)$v)
Calculates feature summary statistics for flowGraph features;
users can choose from a list of statistical significance tests/adjustments
or define custom summary functions.
For special cases, see example in function
fg_add_summary
on
how to manually calculate summary statistics without using this function.
fg_summary( fg, no_cores = 1, class = "class", label1 = NULL, label2 = NULL, class_labels = NULL, node_features = "SpecEnr", edge_features = "NONE", test_name = "t_diminish", diminish = TRUE, p_thres = 0.05, p_rate = 2, test_custom = "t", effect_size = TRUE, adjust0 = TRUE, adjust0_lim = c(-0.1, 0.1), btwn = TRUE, btwn_test_custom = "t", save_functions = FALSE, overwrite = FALSE )
fg_summary( fg, no_cores = 1, class = "class", label1 = NULL, label2 = NULL, class_labels = NULL, node_features = "SpecEnr", edge_features = "NONE", test_name = "t_diminish", diminish = TRUE, p_thres = 0.05, p_rate = 2, test_custom = "t", effect_size = TRUE, adjust0 = TRUE, adjust0_lim = c(-0.1, 0.1), btwn = TRUE, btwn_test_custom = "t", save_functions = FALSE, overwrite = FALSE )
fg |
flowGraph object. |
no_cores |
An integer indicating how many cores to parallelize on. |
class |
A string corresponding to the column name or index
of |
label1 |
A string from the |
label2 |
A string from the |
class_labels |
A list of vectors, each containing two strings
represeting labels to compare; this parameter is an alternative to
parameters |
node_features |
A string vector indicating which node feature(s)
to perform summary statistics on; set to |
edge_features |
A string vector indicating which edge feature(s)
to perform summary statistics on; set to |
test_name |
A string with the name of the test you are performing. |
diminish |
A logical variable indicating whether to use
diminishing summary statistics;
if |
p_thres |
A double indicating the summary statistic threshold;
if the result of a statistical test is greater than |
p_rate |
A double; if |
test_custom |
A function or a string indicating the statistical test
to use. If a string is provided, it should be one of
|
effect_size |
A logical variable indicating whether or not to calculate effect size statistic (cohen's d) for this set of class labels; later used for plotting. |
adjust0 |
A logical variable indicating whether or not to calculate the
minimum percentage of values from samples of each class label that falls
within the range of |
adjust0_lim |
A vector of two numeric values indicating a range around 0, default set to -0.1 and 0.1. |
btwn |
A logical variable indicating whether or not to calculate the
|
btwn_test_custom |
Same as |
save_functions |
A logical variable indicating whether to save test and adjust functions. |
overwrite |
A logical variable indicating whether to overwrite the existing summary statistics if it exists. |
fg_summary
calculates a summary statistic as specified
by the user in parameters test_name
, diminish
(p_thres
, p_rate
), and test_custom
.
The test is done for a node or edge feature of interest within a given
flowGraph object as specified by parameters node_features
,
edge_features
. It then returns information on the summary statistic
inside the same flowGraph object and returns it to the user.
See flowGraph-class
slot summary
for details on the contents.
flowGraph object containing claculated summary statistics.
flowGraph-class
fg_clear_summary
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg_get_summary_desc(fg) fg <- fg_summary(fg, no_cores=no_cores, class="class", label1="control", overwrite=FALSE, test_name="t", diminish=FALSE, node_features="count", edge_features="NONE") fg_get_summary_desc(fg)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) fg_get_summary_desc(fg) fg <- fg_summary(fg, no_cores=no_cores, class="class", label1="control", overwrite=FALSE, test_name="t", diminish=FALSE, node_features="count", edge_features="NONE") fg_get_summary_desc(fg)
Initializes a flowGraph
object given the cell counts
for one or more flow cytometry sample(s).
The flowGraph object returned holds meta data
for each sample, each cell population node,
edges representing how each cell population node relate to one another,
and features for these nodes and edges.
flowGraph( input_, meta = NULL, class = "class", no_cores = 1, markers = NULL, layout_fun = "layout.reingold.tilford", max_layer = NULL, cumsumpos = FALSE, prop = TRUE, specenr = TRUE, path = NULL, calculate_summary = TRUE, node_features = "SpecEnr", edge_features = "NONE", test_name = "t_diminish", test_custom = "t", diminish = TRUE, label1 = NULL, label2 = NULL, save_plots = FALSE )
flowGraph( input_, meta = NULL, class = "class", no_cores = 1, markers = NULL, layout_fun = "layout.reingold.tilford", max_layer = NULL, cumsumpos = FALSE, prop = TRUE, specenr = TRUE, path = NULL, calculate_summary = TRUE, node_features = "SpecEnr", edge_features = "NONE", test_name = "t_diminish", test_custom = "t", diminish = TRUE, label1 = NULL, label2 = NULL, save_plots = FALSE )
input_ |
Any of the following:
All input samples should have the same |
meta |
A data frame with meta data for each |
class |
A string corresponding to the column name or index
of |
no_cores |
An integer indicating how many cores to parallelize on. |
markers |
A string vector of marker names used in |
layout_fun |
A string of a function from the |
max_layer |
And integer indicating the maximum layer in the cell hierarchy to analyze; set to 'NULL' to analyze all layers. |
cumsumpos |
A logical variable indicating whether
or not to cumulate cell counts;
this applies only when |
prop |
A logical variable indicating whether or not to
calculate the proportion feature;
this can be done later on with |
specenr |
logical variable: whether or not to calculate the SpecEnr feature, Default: T |
path |
A string indicating the folder path to where the flowGraph object should save its elements, Default = NULL (don't save). |
calculate_summary |
A logical variable indicating whether or not to
calculate the summary statistics for SpecEnr based on default parameters
using the |
node_features |
A string vector indicating which node feature(s)
to perform summary statistics on; set to |
edge_features |
A string vector indicating which edge feature(s)
to perform summary statistics on; set to |
test_name |
A string with the name of the test you are performing. |
test_custom |
See |
diminish |
A logical variable; applicable if |
label1 |
A string indicating a class label in
|
label2 |
A string indicating a class label in
|
save_plots |
A logical indicating whether or not to save plots. |
flowGraph
is the constructor for the flowGraph
object.
The user can choose to input as input_
a vector, a Phenotypes
object (meaning there is only one sample), a matrix, or a Phenotypes
object list. If the user is also inputting a sample meta data frame, it
must contain a id
column corresponding to sample names.
flowGraph object
flowGraph-class
fg_get_feature
fg_get_feature_desc
fg_get_summary
fg_get_summary_desc
fg_add_feature
fg_rm_feature
fg_add_summary
fg_rm_summary
fg_gsub_markers
fg_gsub_ids
fg_merge_samples
fg_extract_samples
fg_extract_phenotypes
fg_merge
registerDoParallel
Matrix
no_cores <- 1 samplen <- 10 meta_file <- data.frame( id=1:samplen, class=append(rep("control", samplen/2), rep("exp", samplen/2)), stringsAsFactors=FALSE ) ## using the constructor ----------------------- data(fg_data_pos30) # input: vector of load-able Phenotypes paths fg <- flowGraph(fg_data_pos30$count[1,], no_cores=no_cores) # input: matrix + vector of class corresponding to samples fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) # - save to file directly # fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, # no_cores=no_cores, path="path_to_folder) # input: matrix + meta data frame # fg <- flowGraph(fg_data_pos30$count, meta=fg_data_pos30$meta, # no_cores=no_cores)
no_cores <- 1 samplen <- 10 meta_file <- data.frame( id=1:samplen, class=append(rep("control", samplen/2), rep("exp", samplen/2)), stringsAsFactors=FALSE ) ## using the constructor ----------------------- data(fg_data_pos30) # input: vector of load-able Phenotypes paths fg <- flowGraph(fg_data_pos30$count[1,], no_cores=no_cores) # input: matrix + vector of class corresponding to samples fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, no_cores=no_cores) # - save to file directly # fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, # no_cores=no_cores, path="path_to_folder) # input: matrix + meta data frame # fg <- flowGraph(fg_data_pos30$count, meta=fg_data_pos30$meta, # no_cores=no_cores)
'flowGraph': A class for storing cell count feature values for the Phenotype class.
## S4 method for signature 'flowGraph' show(object)
## S4 method for signature 'flowGraph' show(object)
object |
A flowGraph object. |
a flowGraph object.
show
: show method
feat
A list containing elements node
and edge
,
each containing a list with feature values;
each element in this list is named by the feature name and contains a
numeric matrix with the sample id's as row names and cell populations
phenotype labels or edge labels as column names. Column names
for edge features are labelled as <from>_<to> e.g. A+_A+B+.
feat_desc
A list containing elements node
and edge
,
each containing a data frame describing the features in the feat
slot
with columns:
feat
: feature name.
nrow
: number of samples.
ncol
: number of nodes or edges.
inf
: number of infinite values in the matrix.
neginf
: number of negative infinite values in the matrix.
na
: number of NA values in the matrix.
nan
: number of NaN values in the matrix.
neg
: number of negative values in the matrix.
pos
: number of positive values in the matrix.
zero
: number of 0's in the matrix.
max
: The maximum value in the matrix.
min
: The minimum value in the matrix.
summary
A list containing elements node
and edge
,
each containing a list with a feature summary list;
each feature summary in this list contains elements:
values
: a numeric vector the same length
as the number of nodes or edges.
test_custom: a function or a string name of the summary test method used.
summary_desc
A list containing elements node
and edge
,
each containing a data frame describing the features in feat
with
columns:
feat
: A string indicating feature name the
summary was created for.
test_name
: A string containing the name of the summary.
class
: A string corresponding to the column name
of the meta
slot whose values represent the class label of
each sample on which the summary was created to compare or analyze.
label1
: A string from the class
column of the
meta
slot indicating one of the labels compared to create
the summary statistic.
label2
: A string from the class
column of the
meta
slot indicating one of the labels compared to create
the summary statistic.
meta
A data frame containing the column(s) id
(sample id's
corresponding to row names of features in the feat
slot) and any
other meta data pertaining to samples being analyzed.
markers
A character vector containing markers used.
edge_list
A list containing elements child
and parent
.
These elements contain an edge list from child to parent and vice versa.
graph
A list containing data frames v
and e
with
information on cell population nodes and edges. v
contains columns:
phenotype
: The cell population node label names e.g. A+B+C+.
phenocode
: A string of "0", "1", "2", ... indicating the
whether each marker is expressed on a cell population.
phenolayer
: The layer on which a cell population resides i.e.
the numer of markers in its phenotype label.
phenogroup
: The markers used the make up the phenotype.
plot_layout
A string indicating the name of the igraph
layout
function used to layout the cell population nodes for plotting.
etc
A list containing other information
(see fg_get_summary
for other things stored
in this slot):
cumsumpos
: A logical indicating whether cell counts
in flowGraph
object contains cumulated cell counts;
this is optional and can be done only for there is
more than one threshold for one or more markers.
This should also only be ran when initializing a flowGraph
object
as converting back and forth is computationally expensive.
If the user is interested in seeing non- and cumulated counts,
we recommend keeping two flowGraph
objects, one for each version.
This function simply converts e.g. the count of A+ or A++ into
the sum of count of A+, A++, and A+++ or A++, and A+++.
class_mean_normalized
: A logical indicating whether the
features in the flowGraph object has been normalized according to
some sample meta e.g. subject.
save
: A list containing a string indicating the save ID
of the object
and a string indicating path where the object is saved – used in function
save_fg
to identify whether or not to save to the same folder.
Objects can be created using
new("flowFrame")
or the constructor flowGraph
,
with mandatory argument input_
.
Creating objects using new
is discouraged.
'object' represents a flowGraph
object.
show(fg)
: Shows a description of the flowGraph
object.
fg_get_meta
: Retrieves the sample meta data
from a given flowGraph
object.
See fg_get_meta
.
fg_get_graph
: Retrieves the cell population (v) and edge (e)
meta data from a given flowGraph
object.
See fg_get_graph
.
fg_get_feature
: Retrieves the numeric feature matrix requested
by the user from a given flowGraph
object.
See fg_get_feature
.
fg_get_summary
: Retrieves the feature summary list requested
by the user from a given flowGraph
object.
See fg_get_summary
.
fg_get_feature_desc
: Retrieves the data frame from the
feat_desc
slot of a given flowGraph
object.
See fg_get_feature_desc
.
fg_get_summary_desc
: Retrieves the data frame
from the summary_desc
slot of a given flowGraph
object.
See fg_get_summary_desc
.
fg_add_feature
: Adds a feature to a given
flowGraph
object;
we do not recommend users directly use this method, instead please use
wrapper functions e.g. fg_feat_node_prop
,
fg_feat_node_specenr
,
See fg_add_feature
.
fg_rm_feature
: Removes a user specified feature
from a given flowGraph object.
See fg_rm_feature
.
fg_add_summary
: Adds a feature to a given flowGraph
object;
we do not recommend users directly use this method, instead please use
wrapper function fg_summary
.
fg_clear_summary
: Removes all feature summaries
from a given flowGraph object.
See fg_clear_summary
.
fg_rm_summary
: Removes a user specified feature summaries
from a given flowGraph object.
See fg_rm_summary
.
fg_gsub_markers
:
Substitutes marker names in a given flowGraph
object.
See fg_gsub_markers
.
fg_gsub_ids
: substitutes sample id's in a flowGraph
object
See fg_gsub_ids
.
fg_merge_samples
: Merges the samples of two flowGraph
objects;
we recomment users use the wrapper function
fg_merge
instead.
See fg_merge_samples
.
fg_extract_samples
: Extract data for specific samples
from a flowGraph object.
See fg_extract_samples
.
fg_extract_phenotypes
: Extract data for specific
cell population nodes from a flowGraph
object.
See fg_extract_phenotypes
.
fg_merge
: Merges two given flowGraph
objects.
See fg_merge
.
fg_set_layout
: Sets layout for cell population nodes
for the purpose of plotting.
See fg_set_layout
.
fg_plot
: Plots cell hierarchies in the flowGraph object.
See fg_plot
.
showClass("flowGraph")
showClass("flowGraph")
Initializes a flowGraph
object given the cell counts
for one or more flow cytometry sample(s).
The flowGraph object returned holds meta data
for each sample, each cell population node,
edges representing how each cell population node relate to one another,
and features for these nodes and edges.
flowGraphSubset( input_, meta = NULL, class = "class", no_cores = 1, markers = NULL, layout_fun = "layout.reingold.tilford", max_layer = NULL, cumsumpos = FALSE, path = NULL, summary_pars = flowGraphSubset_summary_pars(), summary_adjust = flowGraphSubset_summary_adjust(), save_plots = TRUE )
flowGraphSubset( input_, meta = NULL, class = "class", no_cores = 1, markers = NULL, layout_fun = "layout.reingold.tilford", max_layer = NULL, cumsumpos = FALSE, path = NULL, summary_pars = flowGraphSubset_summary_pars(), summary_adjust = flowGraphSubset_summary_adjust(), save_plots = TRUE )
input_ |
a numeric matrix of the cell counts; its column/names must be the phenotype names and its rownames must be sample ID's. |
meta |
A data frame with meta data for each |
class |
A string corresponding to the column name or index
of |
no_cores |
An integer indicating how many cores to parallelize on, Default: 1 |
markers |
A string vector of marker names used in |
layout_fun |
A string of a function from the |
max_layer |
And integer indicating the maximum layer in the cell hierarchy to analyze; set to 'NULL' to analyze all layers. |
cumsumpos |
A logical variable indicating whether
or not to cumulate cell counts;
this applies only when |
path |
A string indicating the folder path to where the flowGraph object should save its elements, Default = NULL (don't save). |
summary_pars |
A list containing parameters for calculating the statistical significance summary significance that will determine whether to trim out phenotypes for this fast version of flowGraph. The lists' elements are:
|
summary_adjust |
A list of parameters on how to adjust the p-values; this also affects which phenotypes are tested. The elements in the list are:
|
save_plots |
A logical indicating whether or not to save plots. |
All node and edge features are trimmed such that only the
significant phenotypes are left; the original input is stored in the slot
etc$original_count
of the returned flowGraph object.
flowGraph object
## Not run: if(interactive()){ data(fg_data_pos2) fg <- flowGraph(fg_data_pos2$count, meta=fg_data_pos2$meta, no_cores=1) } ## End(Not run)
## Not run: if(interactive()){ data(fg_data_pos2) fg <- flowGraph(fg_data_pos2$count, meta=fg_data_pos2$meta, no_cores=1) } ## End(Not run)
Default input for flowGraphSubset's summary_adjust
parameter. ONLY USE THIS OVER flowGraph IF: 1) your data set has more than
10,000 cell populations and you want to speed up your calculation time AND
2) you only have one set of classes you want to test on the
SAME SET OF SAMPLES (e.g. control vs experiment).
As flowGraphSubset does not
calculate the SpecEnr for all cell populations, so if you want to test other
sets of classes on the same samples, you will not be able to test all
possible cell populations on the new set of classes.
flowGraphSubset_summary_adjust()
flowGraphSubset_summary_adjust()
Default list parameter flowGraphSubset's summary_adjust
parameter.
flowGraphSubset_summary_adjust()
flowGraphSubset_summary_adjust()
Default input for flowGraphSubset's summary_pars
parameter.
flowGraphSubset_summary_pars()
flowGraphSubset_summary_pars()
Default list parameter flowGraphSubset's summary_pars
parameter.
flowGraphSubset_summary_pars()
flowGraphSubset_summary_pars()
Wrapper for purrr::map
and furrr::future_map
to handle parallel-ization
fpurrr_map(x, f, no_cores = 1, prll = TRUE, ...)
fpurrr_map(x, f, no_cores = 1, prll = TRUE, ...)
x |
Variable to recurse over; must be indices! |
f |
Function to recurse over. |
no_cores |
Number of cores to use; |
prll |
If set to FALSE, forces use of purrr::map instead of furrr::future_map, Default: TRUE |
... |
Other parameters used by |
Wrapper for purrr::map
and furrr::future_map
to handle
parallel-ization easily; note that future
must have been ran already
outside of the function and outputs will always be a list.
Unnested named list.
Gets the child populations of a vector of given cell populations
parens
and updates pchild
the edge list if edge list doesn't contain
the requested information.
get_child(parens, pchild, pc_i, ac__, meta_cell__)
get_child(parens, pchild, pc_i, ac__, meta_cell__)
parens |
Character vector of cell population phenotypes. |
pchild |
Edge list where the name of the list is the cell population and the vector in each element contains the child cell populations of the named cell population. |
pc_i |
A cell population x marker matrix where the values are 0/1/2/... correspondng to marker conditions /-/+/... for possible PARENT populations. |
ac__ |
A list where the elements are marker index > "0"/"1"/"2"/... > a logical vector the same length as the number of cell population phenotypes indicating whether or not the marker condition exists in them; this is for the possible CHILD cell populations |
meta_cell__ |
data frame with meta data for cell population phenotypes from the flowGraph object; this is for the possible CHILD cell populations. |
A list containing child populations of parens
; also globally
updates pchild
.
Gets the edge proportions of the edges in edge matrix
edf_
and updates ep
edge proportion matrix if it didn't
contain the requested information.
get_eprop(edf_, ep, mp_, no_cores = 1)
get_eprop(edf_, ep, mp_, no_cores = 1)
edf_ |
edge x from&to data frame containing edges and their from and to cell population phenotypes. |
ep |
sample x edge (parent_child) matrix with edge proportions. |
mp_ |
sample x phenotype matrix with proportions. |
no_cores |
Number of cores to use, Default: 1 |
ep
with only the specific columns (edges) requested; also updates
ep
globally.
Gets the parent populations of a vector of given cell
childs
and updates pparen
the edge list if edge list doesn't
contain the requested information.
get_paren(childs, pparen, pc__i, ac_, meta_cell_)
get_paren(childs, pparen, pc__i, ac_, meta_cell_)
childs |
Character vector of cell population phenotypes. |
pparen |
Edge list where the name of the list is the cell population and the vector in each element contains the parent cell populations of the named cell population. |
pc__i |
A cell population x marker matrix where the values are 0/1/2/... correspondng to marker conditions /-/+/...; this is for the possible CHILD cell populations. |
ac_ |
A list where the elements are marker index > "0"/"1"/"2"/... > a logical vector the same length as the number of cell population phenotypes indicating whether or not the marker condition exists in them; this is for the possible PARENT cell populations. |
meta_cell_ |
data frame with meta data for cell population phenotypes from the flowGraph object; this is for the possible PARENT cell populations. |
A list containing parent populations of childs
; also globally
updates pparen
.
Creates edge lists indicating relationships
between cell populations
given meta data on these cell populations
produced by the get_phen_meta
function.
get_phen_list(meta_cell = NULL, phen = NULL, no_cores = 1)
get_phen_list(meta_cell = NULL, phen = NULL, no_cores = 1)
meta_cell |
A data frame containing meta data on cell populations
as produced by the |
phen |
A string vector of phenotype or cell population name labels.
Cannot be set to |
no_cores |
An integer indicating how many cores to parallelize on. |
A list containing 'pchild', an edge list indicating where edges point to, 'pparen', an edge list indicating where edges point from, and 'edf', a data frame where each row contains the nodes an edge points 'from' and 'to'.
get_phen_meta
cell_type_layers
phen <- c('A+B-C+', 'A+B-', 'A+') get_phen_list(phen=phen)
phen <- c('A+B-C+', 'A+B-', 'A+') get_phen_list(phen=phen)
Generates phenotype meta data given a vector of phenotypes and optionally phenocodes.
get_phen_meta(phen, phenocode = NULL)
get_phen_meta(phen, phenocode = NULL)
phen |
A string vector of phenotype or cell population name labels. |
phenocode |
A string vector of phenocodes corresponding
to the phenotypes in |
A data frame with columns containing meta data on cell poulation nodes with columns:
phenotype
: cell population node label e.g. "A+B+".
phenocode
: a string penocode containing a numeric
corresponding to the phenotype column e.g. "2200".
phenolayer
: a numeric layer on which a cell population
resides in e.g. 2.
get_phen_list
cell_type_layers
phen <- c('A+B+C-D++', 'A+B-', '', 'B++D-E+') phenc <- c('22130','21000','00000','03012') get_phen_meta(phen, phenc)
phen <- c('A+B+C-D++', 'A+B-', '', 'B++D-E+') phenc <- c('22130','21000','00000','03012') get_phen_meta(phen, phenc)
Prepares a given node and edge graph list for plotting by function plot_gr; do not use this function on its own.
ggdf(gr0)
ggdf(gr0)
gr0 |
A list containing data frames |
codeggdf adds to the data frames v
and e
in slot
graph
from a flowGraph
object specifying plotting options as
required by plot_gr
:
v
size
: a numeric indicating node size.
colour
: a numeric or string indicating node colour.
label
: a string indicating the label of a node.
label_long
: a string indicating teh long label of a node;
used in interactive plots in plot_gr
.
label_ind
: a vector of logical variables indicating which
nodes to add a label to in a static plot.
v_ind
: a vector of logical variables indicating which
nodes to plot.
e
colour
: a numeric or string indicating edge colour.
e_ind
: a vector of logical variables indicating which
edges to plot.
A list containing data frames e
and v
, each
with additional meta data column.
flowGraph-class
get_phen_meta
plot_gr
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) gr_ <- ggdf(fg_get_graph(fg)) head(gr_$v) head(gr_$e)
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) gr_ <- ggdf(fg_get_graph(fg)) head(gr_$v) head(gr_$e)
loop_ind_f
is a helper function that splits
a vector of loop indices into a list of multiple loop indices
for use in parallel processes within the flowGraph package.
loop_ind_f(x, n)
loop_ind_f(x, n)
x |
A vector of loop indices. |
n |
An integer, or the number of vectors to split |
list of n
vectors with elements from x
.
old_loop_inds <- 1:10 no_cores <- 5 new_loop_inds <- flowGraph:::loop_ind_f(old_loop_inds, no_cores) # future::plan(future::multisession) # example_indices <- furrr::future_map(new_loop_inds, function(ii) { # purrr::map(ii, function(i) i ) # s})
old_loop_inds <- 1:10 no_cores <- 5 new_loop_inds <- flowGraph:::loop_ind_f(old_loop_inds, no_cores) # future::plan(future::multisession) # example_indices <- furrr::future_map(new_loop_inds, function(ii) { # purrr::map(ii, function(i) i ) # s})
Used only in the fg_feat_mean_class
function; for each class in the classes
vector,
meandiff
takes the column mean
of the rows in the given matrix associated with that class;
it then takes the difference point by point between these means and
the original rows for that class.
mean_diff(m0, classes)
mean_diff(m0, classes)
m0 |
A numeric matrix. |
classes |
A vector whose length is equal to the number of rows in the given matrix. |
A numeric matrix whose dimensions equate to that of the input and whose values are normalized per class.
classes <- append(rep('apples',4), rep('oranges',3)) m0 <- matrix(rnorm(35), nrow=7) m <- flowGraph:::mean_diff(m0, classes)
classes <- append(rep('apples',4), rep('oranges',3)) m0 <- matrix(rnorm(35), nrow=7) m <- flowGraph:::mean_diff(m0, classes)
FUNCTION_DESCRIPTION
ms_create(mp_, me_)
ms_create(mp_, me_)
mp_ |
Numerical sample x cell population matrix w/ proportions. |
me_ |
Numerical sample x cell population matrix w/ expected proportions. |
Numerical sample x cell population matrix w/ SpecEnr.
Determines which phenotypes are statistically significant based on SpecEnr.
ms_psig( ms_, summary_pars, summary_adjust, test_cust, test_custom, lyrno, mp_, me_ )
ms_psig( ms_, summary_pars, summary_adjust, test_cust, test_custom, lyrno, mp_, me_ )
ms_ |
sample x phenotype SpecEnr matrix |
summary_pars |
See |
summary_adjust |
See |
test_cust |
Final significance test function. |
test_custom |
Raw significance test function. |
lyrno |
An integer indicating total number of layers in the cell hierarchy including layer 0. |
mp_ |
sample x phenotype proportion matrix. |
me_ |
sample x phenotype expected proportion matrix. |
A logical vector the same length as the number of columns in
ms_
indicating whether or not each phenotype is significant;
used only for the fast version of flowGraph to determine whether or not
to keep testing the phenotypes' children.
Plots a cell hierarchy given the output from fg_plot
, a list of nodes and edges.
plot_gr( gr, main = NULL, show_bgedges = TRUE, colour_palette = NULL, label_coloured = TRUE, shiny_plot = FALSE, interactive = FALSE, visNet_plot = TRUE, colour_edges = FALSE, ... )
plot_gr( gr, main = NULL, show_bgedges = TRUE, colour_palette = NULL, label_coloured = TRUE, shiny_plot = FALSE, interactive = FALSE, visNet_plot = TRUE, colour_edges = FALSE, ... )
gr |
A list containing data frames |
main |
A string containing the plot title. If this is set to NULL, the
function will look for a plot title in the |
show_bgedges |
A logical variable indicating whether or not
edges not specified for plotting should be plotted as light grey
in the background. If this is |
colour_palette |
A colour palette e.g. the default palette if the user
sets this to |
label_coloured |
A logical indicating whether to colour the node labels using the same colours as the nodes in the non-interactive plot. |
shiny_plot |
A logical indicating whether this plot is made for shiny; users don't need to change this. |
interactive |
A logical variable indicating whether the plot should be
an interactive plot; see package |
visNet_plot |
A logical variable indicating if an interactive plot is
chosen, if function should output a visNetwork plot; if set to |
colour_edges |
A logical variable indicating whether to colour edges if plotting a node feature summary. |
... |
Other parameters for |
A ggplot
object if interactive
is set to FALSE
;
a ggiraph
object if interactive
is set to TRUE
.
flowGraph-class
fg_plot
get_phen_meta
ggdf
fg_get_feature
fg_get_summary
no_cores <- 1 data(fg_data_pos2) fg <- flowGraph(fg_data_pos2$count, class=fg_data_pos2$meta$class, no_cores=no_cores) # fg <- fg_summary(fg, no_cores=no_cores, class="class", control="control", # overwrite=FALSE, test_name="t_byLayer", diminish=FALSE) gr_summary <- fg_plot( fg, type="node", p_thres=.05, show_bgedges=TRUE, path=NULL) # set path to a full path to save plot as a PNG plot_gr(gr_summary, main=gr_summary$main, show_bgedges=TRUE) plot_gr(gr_summary, main=gr_summary$main, show_bgedges=TRUE, interactive=TRUE)
no_cores <- 1 data(fg_data_pos2) fg <- flowGraph(fg_data_pos2$count, class=fg_data_pos2$meta$class, no_cores=no_cores) # fg <- fg_summary(fg, no_cores=no_cores, class="class", control="control", # overwrite=FALSE, test_name="t_byLayer", diminish=FALSE) gr_summary <- fg_plot( fg, type="node", p_thres=.05, show_bgedges=TRUE, path=NULL) # set path to a full path to save plot as a PNG plot_gr(gr_summary, main=gr_summary$main, show_bgedges=TRUE) plot_gr(gr_summary, main=gr_summary$main, show_bgedges=TRUE, interactive=TRUE)
Determines cell hierarchy layout and returns the X, Y coordinate of each cell population.
set_layout_graph(gr, layout_fun = "layout.reingold.tilford")
set_layout_graph(gr, layout_fun = "layout.reingold.tilford")
gr |
A list containing data frames |
layout_fun |
A string of a function from the |
A list containing data frames e
and v
; each data frame
contains an X, Y column or coordinate for each node and edge.
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) head(set_layout_graph(fg_get_graph(fg)))
no_cores <- 1 data(fg_data_pos30) fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class, prop=FALSE, specenr=FALSE, no_cores=no_cores) head(set_layout_graph(fg_get_graph(fg)))
Summarizes a numeric matrix.
summary_table(m, feat_type = "")
summary_table(m, feat_type = "")
m |
A numeric matrix. |
feat_type |
Name of the matrix |
A data frame containing one row summarizing m
;
see fg_get_feature_desc
.
summary_table(matrix(rnorm(12),nrow=3), feat_type='random')
summary_table(matrix(rnorm(12),nrow=3), feat_type='random')
Converts input into a significance test function
test_c(test_custom)
test_c(test_custom)
test_custom |
a string |
a statistical significance test function.
t.test
,wilcox.test
,
ks.test
,var.test
,
chisq.test
Given a time, prints the time elapsed from that time until now.
time_output(start, msg = "")
time_output(start, msg = "")
start |
A time variable of class |
msg |
A string with a message to print out after the elapsed time. |
Prints to console, the time from which process
started start
- ended, and > time elapsed from
start
until now.
start <- Sys.time() flowGraph:::time_output(start,'start - now > time elapsed')
start <- Sys.time() flowGraph:::time_output(start,'start - now > time elapsed')
Formats time into a string HH:MM:SS given time zone.
tstr(time)
tstr(time)
time |
A time variable of class |
Time formatted as a string; used in time_output
function.
# NOT EXPORTED flowGraph:::tstr(Sys.time())
# NOT EXPORTED flowGraph:::tstr(Sys.time())