Dirichlet Multinomial - meyermicrobiolab/Meyer_Lab_Resources GitHub Wiki
Dirichlet Multinomial
Dirichlet Multinomial Mixture Models can be used to describe variability in microbial metagenomic data. Using the Bioconductor package Dirichlet Multinomial we can take our OTUs from Phyloseq and transform them into DMM models. The package is available on HiPer Gator and if you have a large sample size I recommend running it there as it will consume alot of resources.
Get your OTUS
ps <- readRDS("phyloseq.rds")
otu <- as(otu_table(ps), "matrix")
Run DMM
Where 1:7 is specifying the number of Dirichlet components to fit to. I recommend saving your fit once the DMM is finished that way you wont have to run it every time you want your fit.
my_fit <- mclapply(1:7, dmn, count=otu, verbose=TRUE)
save(my_fit, file= "my_fit.rda"))
Getting the best fit
Your fit can be queried for measures of fit. I used the laplace measure.
lplc <- sapply(my_fit, laplace)
pdf("min-laplace.pdf")
plot(lplc, type="b", xlab="Number of Dirichlet Components",+ylab="Model Fit")
dev.off()
(best <- fit[which.min(lplc)](/meyermicrobiolab/Meyer_Lab_Resources/wiki/which.min(lplc)))
Plotting a Heatmap
The bioconductor package also has a handy built in heatmap function. In the map samples arranged by Dirichlet component. Narrow columns are samples, broader columns component averages and rows are taxonomic groups. Color represents square-root counts, with dark colors corresponding to larger counts.
pdf("heatmap1.pdf")
heatmapdmn(count, fit[1](/meyermicrobiolab/Meyer_Lab_Resources/wiki/1), best, 30)
dev.off()