Convert Distance matrix to Data Frame

meltDistanceToTable(x, dist_mat = NULL, name_dist_column = "value", ...)

Arguments

x

A phyloseq object

dist_mat

An object of class dist

name_dist_column

A specific name for column where distance values are stored. Default="value"

...

Option to pass biomeUtils::getSampleTibble like column name and columns to be included in the output.

Value

A data frame with pairwise distance and sample information

Details

Converts dist object from phyloseq::distance() to a data frame combined with sample data

Author

Sudarshan A. Shetty

Examples

library(biomeUtils)
data("FuentesIliGutData")
ps <- filterSampleData(FuentesIliGutData, ILI != "L2")
ps <- phyloseq::rarefy_even_depth(ps)
#> You set `rngseed` to FALSE. Make sure you've set & recorded
#>  the random seed of your session for reproducibility.
#> See `?set.seed`
#> ...
dist.mat <- phyloseq::distance(ps, "bray")
dist.melt.sample <- meltDistanceToTable(ps,
                                        dist_mat = dist.mat,
                                        name_dist_column = "Bray-Curtis",
                                        select_cols = c("participant_id", "ILI"))
head(dist.melt.sample)
#>         S1       S2 Bray.Curtis participant_id_S1 ILI_S1 participant_id_S2
#> 1 sample_2 sample_1   0.5506150              ELD2      C              ELD1
#> 2 sample_3 sample_1   0.5848747              ELD3      C              ELD1
#> 3 sample_4 sample_1   0.5572665              ELD4      C              ELD1
#> 4 sample_5 sample_1   0.6357175              ELD5     L1              ELD1
#> 5 sample_6 sample_1   0.7339408              ELD6      C              ELD1
#> 6 sample_7 sample_1   0.5845103              ELD7     L1              ELD1
#>   ILI_S2
#> 1      C
#> 2      C
#> 3      C
#> 4      C
#> 5      C
#> 6      C