make_distance_df: Creates a data.frame of pairwise distances from a 'phyloseq'...

Description Usage Arguments Value Examples

View source: R/microbiome_tools.R

Description

This function outputs a data.frame of pairwise distances from each pair of samples contained in a phyloseq object.

Usage

1
2
3
make_distance_df(ps = ps, distances = c("wuf", "uuf", "bray", "jsd",
  "jaccard"), force_distance_calculations = FALSE, intragroup_only = FALSE,
  variables = NULL)

Arguments

ps

A phyloseq object that contains sample_data.

distances

A vector of distances metrics you want included. Defaults to c("wuf", "uuf", "bray", "jsd", "jaccard"). If the distance matrix is alrady present in the global enviroment, it will not calculate it again unless force_distance_calculations = TRUE. It will also check to make sure the sample_names(ps) are found in the exsiting distance matrix.

force_distance_calculations

(Logical) Would you like the function to overwrite any distance matrices in the global enviroment? Defaults to FALSE

intragroup_only

(Logical) If you would like to restrict comparisions to within a group, you can set this as TRUE (defaults to "Subject_ID") or you can specify which column in sample_variables.

variables

A vector of sample_variables that you would like compared in the output data.frame. For each factor, it will make a column for each sample, as well as a comparision column. For numerics, the comparison will be the absolute value of the difference of the numeric. For factors, the comparison will be if the two samples are the same or not.

Value

This function returns a data.frame with every pair of samples and their distance by several distance metrics. It can also output variables, as well as comparisions between those variables for easy subsetting.

Examples

1
2
3
4
5
df <- make_distance_df(ps = ps)
df <- make_distance_df(ps = ps,
                       distances = c("jsd", "jaccard"),
                       intragroup_only = "Subject_ID",
                       variables = c("Country", "Age_Months"))

DanielSprockett/reltools documentation built on May 5, 2019, 12:27 p.m.