creer_matrice {SARP.compo} | R Documentation |
Create p-values matrix from pairwise tests of all possible ratios of a compositional vector
Description
This function performs hypothesis testing on all possible pairwise ratios or differences of a set of variables in a given data frame, and store their results in a (symmetric) matrix
Usage
creer.Mp( d, noms, f.p, log = FALSE, en.log = !log,
nom.var = 'R', n.coeurs = 1, controles = TRUE, ... )
Arguments
d |
The data frame that contains the compositional variables. Other
objects will be coerced as data frames using
|
noms |
A character vector containing the column names of the compositional variables to be used for ratio computations. Names absent from the data frame will be ignored with a warning. Optionnally, an integer vector containing the column numbers can be given instead. They will be converted to column names before further processing. |
f.p |
An R function that will perform the hypothesis test on a single
ratio (or log ratio, depending on This function should return a single numerical value, typically the p-value from the test. This function must accept at least two named arguments: Such functions are provided for several common situations, see references at the end of this manual page. |
log |
If If |
en.log |
If |
nom.var |
A length-one character vector giving the name of the
variable containing a single ratio (or log-ratio). No sanity check
is performed on it: if you experience strange behaviour, check you
gave a valid column name, for instance using
|
n.coeurs |
The number of CPU cores to use in computation, with parallelization using forks (does not work on Windows) with the help of the parallel package. |
controles |
If TRUE, sanity checks are done on the obtained
matrix. Columns and Rows containing only non-finite values are
removed, with warnings; corresponding component names are stored as
attribute |
... |
additional arguments to |
Details
This function constructs a n\times n
matrix, where n =
length( noms )
(after eventually removing names in noms
that
do not correspond to numeric variables). Term (i,j)
in this
matrix is the result of the f.p
function when applied on the
ratio of variables noms[ i ]
and noms[ j ]
(or on its
log, if either (log == TRUE) && (en.log == FALSE)
or (log
== FALSE) && (en.log == TRUE)
).
The f.p
function is always called only once, for i < j
,
and the other term is obtained by symmetry.
The diagonal of the matrix is filled with 1 without calling f.p
,
since corresponding ratios are always identically equal to 1 so
nothing useful can be tested on.
Value
These function returns the matrix obtained as described above,
with row an column names set to the names in noms
(after
conversion into column names and removing all non-numeric variables).
Note
Since the whole matrix is stored and since it is a dense
matrix, memory consumption (and computation time) increases as
n^2
. For compositional data with a large number of components,
like in RNA-Seq data, consider instead creating a file.
Author(s)
Emmanuel Curis (emmanuel.curis@parisdescartes.fr)
See Also
Predefined f.p
functions: anva1.fpc
for one-way
analysis of variance; kw.fpc
for the non-parametric
equivalent (Kruskal-Wallis test).
grf.Mp to create a graphe from the obtained matrix.
Examples
# load the potery data set
data( poteries )
# Compute one-way ANOVA p-values for all ratios in this data set
Mp <- creer.Mp( poteries, c( 'Al', 'Na', 'Fe', 'Ca', 'Mg' ),
f.p = anva1.fpc, v.X = 'Site' )
Mp
# Make a graphe from it and plot it
plot( grf.Mp( Mp ) )