fg_add_summary {flowGraph} | R Documentation |
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 |
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)