View source: R/fava_functions.R
fava | R Documentation |
This function computes the population-genetic statistic Fst on any matrix with rows that sum to 1. Values of 0 are achieved when each row is a permutation of (1,0,..., 0) and at least two categories have non-zero abundance across all rows. The value equals 1 when each row is identical.
fava(
relab_matrix,
K = NULL,
S = NULL,
w = NULL,
time = NULL,
group = NULL,
normalized = FALSE
)
relab_matrix |
A matrix or data frame with rows containing non-negative entries that sum to 1. Each row represents
a sample, each column represents a category, and each entry represents the abundance of that category in the sample.
If |
K |
Optional; an integer specifying the number of categories in the data. Default is |
S |
Optional; a K x K similarity matrix with diagonal elements equal to 1 and off-diagonal elements between 0 and 1. Entry |
w |
Optional; a vector of length |
time |
Optional; a string specifying the name of the column that describes the sampling time for each row. Include if you wish to weight FAVA by the distance between samples. |
group |
Optional; a string (or vector of strings) specifying the name(s) of the column(s) that describes which group(s) each row (sample) belongs to. Use if |
normalized |
Optional; should normalized FAVA be used? Default is |
A numeric value between 0 and 1.
# Compute the Fst of
# the following compositional vectors:
q1 = c(1, 0, 0, 0)
q2 = c(0.5, 0.5, 0, 0)
q3 = c(1/4, 1/4, 1/4, 1/4)
q4 = c(0, 0, 1, 0)
relative_abundances = matrix(c(q1, q2, q3, q4),
byrow = TRUE, nrow = 4)
fava(relative_abundances)
# Incoporating weights:
# Compute fava ignoring
# rows 2 and 3
row_weights = c(0.5, 0, 0, 0.5)
fava(relative_abundances, w = row_weights)
# Compute fava assuming that
# categories 1 and 2 are identical:
similarity_matrix = diag(4)
similarity_matrix[1,2] = 1
similarity_matrix[2,1] = 1
fava(relative_abundances, S = similarity_matrix)
# Assume categories 1 and 2 are identical AND
# ignore rows 2 and 4:
row_weights = c(0.5, 0, 0.5, 0)
fava(relative_abundances, w = row_weights, S = similarity_matrix)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.