View source: R/pairwiseMat2DT.R
pairwiseMat2DT | R Documentation |
This function takes pairwise matrix (all possible combinations in rows and columns) and converts it into a long-format data table. This function can also be flipped, i.e., going from a pairwise data table to a pairwise matrix.
pairwiseMat2DT(dat, flip = FALSE, X1, X2, Y, diagAdd = TRUE, diagVal = 0)
dat |
Matrix or Data table: The default parameterisation ( |
flip |
Logical: Should the function be flipped? Default is |
X1 |
Character: The column name for the first member of the pair.
If |
X2 |
Character: The column name for the first member of the pair.
If |
Y |
Character: The column name or the measured variable between pairs.
If |
diagAdd |
Logical: Should the diagonal be added? Default is
|
diagVal |
Numeric: The value to add along the diagonal when
|
library(genomalicious)
data(data_Genos)
# Calculate pairwise FST
pairFst <- fstat_calc(data_Genos, type='genos', fstat='FST', global=FALSE, pairwise=TRUE)
# Convert into a pairwise matrix
pairMat <- pairwiseMat2DT(
dat=pairFst$genome, flip=TRUE, X1='POP1', X2='POP2', Y='FST',
diagAdd=TRUE, diagVal=0
)
pairMat
# Convert the pairwise matrix into a data table
pairDT <- pairwiseMat2DT(
dat=pairMat, flip=FALSE, X1='POP1', X2='POP2', Y='FST'
)
pairDT
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.