knitr::opts_chunk$set(echo = TRUE)
options(tidyverse.quiet = TRUE)
library(volatility)
#install and load volatility library
#devtools::install_github("thomazbastiaanssen/volatility")
library(volatility)

#load tidyverse to wrangle and plot results.
library(tidyverse)

#devtools::install_github("thomazbastiaanssen/deleuze")
library(deleuze)    

#load example data + metadata from the volatility study.
data(summer_school)
#Ensure microbiome table is in the same order as the metadata
mb_table <- mb_table[metadata$sample_id]

#Perform a double-centered log-ratio transformation:
mb.exp <- dclr(as.matrix(mb_table), type = "numeric")

#compute distance matrix
mb.dist <- dist(t(mb.exp))

#Compute volatility
vola_df <- get_pairwise_distance(mb.dist, metadata = metadata, g = 'id_num')

#Compute feature-wise volatility 
get_fw_volatility(vola_df, f_table = mb_table)


thomazbastiaanssen/Volatility documentation built on July 13, 2024, 9:09 a.m.