Giter Club home page Giter Club logo

gunifrac's Introduction

GUniFrac

Generalized UniFrac Distances and Distance-based Multivariate Analysis of Variance

Overview

The package implements Generalized UniFrac distances for comparing microbial communities and three extensions to permutational multivariate analysis of variance (PERMANOVA) using distance matrix. The three extensions are

  • PERMANOVA using the Freedman-Lane permutation scheme;
  • PERMANOVA omnibus test using multiple matrices;
  • An analytical approach to approximating PERMANOVA p-value.

Installation

install.packages(c("ape", "vegan", "Matrix", "matrixStats"))
install.packages("devtools")
devtools::install_github("jchen1981/GUniFrac")

An Example

We illustrate the usage of package using simulated data.

require(GUniFrac)

data(throat.otu.tab)
data(throat.tree)
data(throat.meta)


# Rarefaction
otu.tab.rff <- Rarefy(throat.otu.tab)$otu.tab.rff

# Calculate the UniFrac distance
unifracs <- GUniFrac(otu.tab.rff, throat.tree, alpha=c(0, 0.5, 1))$unifracs

dw <- unifracs[, , "d_1"]          # Weighted UniFrac
du <- unifracs[, , "d_UW"]         # Unweighted UniFrac     
dv <- unifracs[, , "d_VAW"]        # Variance adjusted weighted UniFrac
d0 <- unifracs[, , "d_0"]          # GUniFrac with alpha 0  
d5 <- unifracs[, , "d_0.5"]        # GUniFrac with alpha 0.5 

# Test the smoking effect based on unweighted UniFrac distance, adjusting sex.

# PERMANOVA using Freedman-Lane permutation scheme ('Sex' should be put before 'SmokingStatus')
adonis3(as.dist(unifracs[, , 'd_UW']) ~ Sex + SmokingStatus, data = throat.meta)

# Or we can permute within each sex
adonis3(as.dist(unifracs[, , 'd_UW']) ~ SmokingStatus, data = throat.meta, 
strata = throat.meta$Sex)

# Compare the p-values to the analytical approach
dmanova(as.dist(unifracs[, , 'd_UW']) ~ Sex + SmokingStatus, data = throat.meta)

# PERMANOVA omnibus test combining weighted and unweighted distance matrices
PermanovaG2(unifracs[, , c("d_1", "d_UW")] ~ Sex + SmokingStatus, data = throat.meta)  

gunifrac's People

Watchers

Chen_LAB avatar

gunifrac's Issues

please supply a `strata` parameters used example

I want to perform paired samples.
The grp.name is "point", which has two labels, i.e. "Before", "After".
The subject-id column name is "Individual".

I excuted the script:

ZicoSeq.obj.p <- ZicoSeq(meta.dat = meta.dat, feature.dat = comm.p, 
                           grp.name = 'Point', feature.dat.type = "proportion",  
                           # Filter to remove rare taxa
                           prev.filter = 0.2, mean.abund.filter = 0, max.abund.filter = 0.002, min.prop = 0, 
                           # Winsorization to replace outliers
                           is.winsor = TRUE, outlier.pct = 0.03, winsor.end = 'top',
                           # Posterior sampling will be automatically disabled
                           is.post.sample = FALSE, post.sample.no = 25,            
                           stats.combine.func = max,  
                           # Permutation-based multiple testing correction
                           perm.no = 999,  strata = NULL, 
                           # Reference-based multiple stage normalization
                           ref.pct = 0.5, stage.no = 6, excl.pct = 0.2,
                           # Subjects ID column
                           strata = "Individual",
                           # Family-wise error rate control
                           is.fwer = TRUE, verbose = TRUE, return.feature.dat = T)

however, the error occured:

Error in ZicoSeq(meta.dat = meta.dat, feature.dat = comm.p, grp.name = "Point",  : 
  formal argument "strata" matched by multiple actual arguments

I have check 'Individual' data type (i.e. factor) and its labels. There seems to be all right.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.