-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jakob Russel
committed
Feb 19, 2020
1 parent
ceedc85
commit 67b93ea
Showing
6 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
Package: MicEco | ||
Title: Various functions for microbial community data | ||
Version: 0.9.5 | ||
Version: 0.9.6 | ||
Authors@R: person("Jakob", "Russel", email = "[email protected]", role = c("aut", "cre")) | ||
Description: Collection of functions for microbiome analyses. E.g. fitting neutral models and standardized effect sizes of phylogenetic beta diversities, and much more. | ||
Depends: R (>= 3.2.5) | ||
Imports: stats, utils, phyloseq, foreach, doSNOW, picante, vegan, snow, bbmle, Hmisc, abind, reshape2 | ||
Imports: stats, utils, phyloseq, foreach, doSNOW, picante, vegan, snow, bbmle, Hmisc, abind, reshape2, eulerr | ||
License: GPL (>= 3) | file LICENSE | ||
Encoding: UTF-8 | ||
LazyData: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#' Make Euler (Venn) diagram of shared taxa (ASVs, OTUs) across sample groups | ||
#' | ||
#' Make Euler (Venn) diagram of shared taxa (ASVs, OTUs) across sample groups from a phyloseq object. Overlap can be weighted by relative abundance | ||
#' @param ps A phyloseq object | ||
#' @param group The grouping factor. Should match variable in sample_data(ps) | ||
#' @param weight If TRUE, the overlaps are weighted by abundance | ||
#' @param type "percent" or "count" | ||
#' @param relative Should abundances be made relative | ||
#' @param ... Additional arguments | ||
#' @keywords venn euler diagram | ||
#' @return An euler plot | ||
#' @import phyloseq | ||
#' @import eulerr | ||
#' @importFrom stats aggregate as.formula | ||
#' @export | ||
|
||
phylo_euler <- function(ps, group, weight = FALSE, type = "percent", relative = TRUE, ...){ | ||
|
||
if(relative){ | ||
ps <- transform_sample_counts(ps, function(x) x/sum(x)) | ||
} | ||
|
||
ps_melted <- psmelt(ps) | ||
|
||
ps_agg <- aggregate(as.formula(paste("Abundance ~ OTU +",group)), data = ps_melted, function(x) mean(x)) | ||
|
||
ps_mat <- reshape2::dcast(as.formula(paste("OTU ~ ",group)), data = ps_agg, value.var = "Abundance") | ||
|
||
ps_mat <- ps_mat[, -1] | ||
ps_mat_bin <- (ps_mat>0)*1 | ||
|
||
if(weight){ | ||
df <- euler(ps_mat_bin, weights = rowMeans(ps_mat)) | ||
} else { | ||
df <- euler(ps_mat_bin) | ||
} | ||
|
||
plot(df, quantities = list(type=type), ...) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.