Title: | Interactive microbiome analysis toolkit |
---|---|
Description: | animalcules is an R package for utilizing up-to-date data analytics, visualization methods, and machine learning models to provide users an easy-to-use interactive microbiome analysis framework. It can be used as a standalone software package or users can explore their data with the accompanying interactive R Shiny application. Traditional microbiome analysis such as alpha/beta diversity and differential abundance analysis are enhanced, while new methods like biomarker identification are introduced by animalcules. Powerful interactive and dynamic figures generated by animalcules enable users to understand their data better and discover new insights. |
Authors: | Jessica McClintock [cre], Yue Zhao [aut] , Anthony Federico [aut] , W. Evan Johnson [aut] |
Maintainer: | Jessica McClintock <[email protected]> |
License: | Artistic-2.0 |
Version: | 1.23.0 |
Built: | 2024-11-25 06:13:19 UTC |
Source: | https://github.com/bioc/animalcules |
Alpha diversity boxplot
alpha_div_boxplot( MAE, tax_level, condition, alpha_metric = c("inverse_simpson", "gini_simpson", "shannon", "fisher", "coverage", "unit") )
alpha_div_boxplot( MAE, tax_level, condition, alpha_metric = c("inverse_simpson", "gini_simpson", "shannon", "fisher", "coverage", "unit") )
MAE |
A multi-assay experiment object. Required. |
tax_level |
The taxon level used for organisms. Required. |
condition |
Which condition to group samples. Required. |
alpha_metric |
Which alpha diversity metric to use. Required. Can be one of:"inverse_simpson", "gini_simpson", "shannon", "fisher", "coverage", "unit" |
A plotly object
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) p <- alpha_div_boxplot(toy_data, tax_level = "genus", condition = "DISEASE", alpha_metric = "shannon" ) p
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) p <- alpha_div_boxplot(toy_data, tax_level = "genus", condition = "DISEASE", alpha_metric = "shannon" ) p
Get alpha diversity
alpha_div_test(sam_table, alpha_stat)
alpha_div_test(sam_table, alpha_stat)
sam_table |
A dataframe with 2 cols, richness and condition. Required. |
alpha_stat |
Wilcoxon rank sum test or T-test for the test |
A dataframe
df_test <- data.frame( richness = seq_len(10), condition = c(rep(1, 5), rep(0, 5)) ) alpha_div_test(df_test, alpha_stat = "Wilcoxon rank sum test")
df_test <- data.frame( richness = seq_len(10), condition = c(rep(1, 5), rep(0, 5)) ) alpha_div_test(df_test, alpha_stat = "Wilcoxon rank sum test")
Covert a counts table to a relative abundances table
counts_to_logcpm(counts_table)
counts_to_logcpm(counts_table)
counts_table |
A organism x sample data frame of counts |
A organism x sample data frame of logcpm counts
logcpm <- counts_to_logcpm(as.data.frame(matrix(seq_len(12), 4)))
logcpm <- counts_to_logcpm(as.data.frame(matrix(seq_len(12), 4)))
Covert a counts table to a relative abundances table
counts_to_relabu(counts_table)
counts_to_relabu(counts_table)
counts_table |
A organism x sample data frame of counts |
A organism x sample data frame of relative abundances
counts_to_relabu(matrix(seq_len(12), 4))
counts_to_relabu(matrix(seq_len(12), 4))
Factorize all categorical columns
df_char_to_factor(df)
df_char_to_factor(df)
df |
A sample x condition data frame |
A sample x condition data frame
df_char_to_factor(matrix(seq_len(12)))
df_char_to_factor(matrix(seq_len(12)))
Differential abundance analysis
differential_abundance( MAE, tax_level, input_da_condition = c(), input_da_condition_covariate = NULL, min_num_filter = 5, input_da_padj_cutoff = 0.05, method = "DESeq2" )
differential_abundance( MAE, tax_level, input_da_condition = c(), input_da_condition_covariate = NULL, min_num_filter = 5, input_da_padj_cutoff = 0.05, method = "DESeq2" )
MAE |
A multi-assay experiment object |
tax_level |
The taxon level used for organisms |
input_da_condition |
Which condition is the target condition |
input_da_condition_covariate |
Covariates added to linear function |
min_num_filter |
Minimum number reads mapped to this microbe |
input_da_padj_cutoff |
adjusted pValue cutoff |
method |
choose between DESeq2 and limma |
A output dataframe
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) differential_abundance(toy_data, tax_level = "phylum", input_da_condition = c("DISEASE"), min_num_filter = 2, input_da_padj_cutoff = 0.5, method = "DESeq2" )
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) differential_abundance(toy_data, tax_level = "phylum", input_da_condition = c("DISEASE"), min_num_filter = 2, input_da_padj_cutoff = 0.5, method = "DESeq2" )
Dimensionality reduction through PCA
dimred_pca( MAE, tax_level, color, shape = NULL, pcx = 1, pcy = 2, pcz = NULL, datatype = c("logcpm", "relabu", "counts") )
dimred_pca( MAE, tax_level, color, shape = NULL, pcx = 1, pcy = 2, pcz = NULL, datatype = c("logcpm", "relabu", "counts") )
MAE |
A multi-assay experiment object |
tax_level |
The taxon level used for organisms |
color |
A condition to color data points by e.g. "AGE" |
shape |
A condition to shape data points by e.g. "SEX" |
pcx |
Principal component on the x-axis e.g. 1 |
pcy |
Principal component on the y-axis e.g. 2 |
pcz |
Principal component on the z-axis e.g. 3 |
datatype |
Datatype to use e.g. c("logcpm", "relabu", "counts") |
A list with a plotly object and summary table
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) result <- dimred_pca(toy_data, tax_level = "genus", color = "AGE", shape = "DISEASE", pcx = 1, pcy = 2, datatype = "logcpm" ) result$plot result$table
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) result <- dimred_pca(toy_data, tax_level = "genus", color = "AGE", shape = "DISEASE", pcx = 1, pcy = 2, datatype = "logcpm" ) result$plot result$table
Dimensionality reduction through PCoA
dimred_pcoa( MAE, tax_level, color, shape = NULL, axx = 1, axy = 2, axz = NULL, method = c("bray", "jaccard") )
dimred_pcoa( MAE, tax_level, color, shape = NULL, axx = 1, axy = 2, axz = NULL, method = c("bray", "jaccard") )
MAE |
A multi-assay experiment object |
tax_level |
The taxon level used for organisms |
color |
A condition to color data points by e.g. "AGE" |
shape |
A condition to shape data points by e.g. "SEX" |
axx |
Principle coordinate on the x-axis e.g. 1 |
axy |
Principle coordinate on the y-axis e.g. 2 |
axz |
Principle coordinate on the z-axis e.g. 2 |
method |
Method to use e.g. c("bray", "jaccard") |
A list with a plotly object and summary table
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) result <- dimred_pcoa(toy_data, tax_level = "genus", color = "AGE", shape = "DISEASE", axx = 1, axy = 2, method = "bray" ) result$plot result$table
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) result <- dimred_pcoa(toy_data, tax_level = "genus", color = "AGE", shape = "DISEASE", axx = 1, axy = 2, method = "bray" ) result$plot result$table
Dimensionality reduction through t-SNE
dimred_tsne( MAE, tax_level, color, shape = NULL, k = c("2D", "3D"), initial_dims = 30, perplexity = 10, datatype = c("logcpm", "relabu", "counts"), tsne_cache = NULL )
dimred_tsne( MAE, tax_level, color, shape = NULL, k = c("2D", "3D"), initial_dims = 30, perplexity = 10, datatype = c("logcpm", "relabu", "counts"), tsne_cache = NULL )
MAE |
A multi-assay experiment object |
tax_level |
The taxon level used for organisms |
color |
A condition to color data points by e.g. "AGE" |
shape |
A condition to shape data points by e.g. "SEX" |
k |
Plot dimensions e.g. c("2D","3D") |
initial_dims |
The number of dimensions to use in reduction method |
perplexity |
Optimal number of neighbors |
datatype |
Datatype to use e.g. c("logcpm", "relabu", "counts") |
tsne_cache |
Pass the cached data back into the function |
A list with a plotly object and cached data
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) results <- dimred_tsne(toy_data, tax_level = "phylum", color = "AGE", shape = "GROUP", k = "3D", initial_dims = 30, perplexity = 10, datatype = "logcpm" ) results$plot
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) results <- dimred_tsne(toy_data, tax_level = "phylum", color = "AGE", shape = "GROUP", k = "3D", initial_dims = 30, perplexity = 10, datatype = "logcpm" ) results$plot
Dimensionality reduction through PCA
dimred_umap( MAE, tax_level, color, shape = NULL, cx = 1, cy = 2, cz = NULL, n_neighbors = 15, metric = c("euclidean", "manhattan"), n_epochs = 200, init = c("spectral", "random"), min_dist = 0.1, datatype = c("logcpm", "relabu", "counts") )
dimred_umap( MAE, tax_level, color, shape = NULL, cx = 1, cy = 2, cz = NULL, n_neighbors = 15, metric = c("euclidean", "manhattan"), n_epochs = 200, init = c("spectral", "random"), min_dist = 0.1, datatype = c("logcpm", "relabu", "counts") )
MAE |
A multi-assay experiment object |
tax_level |
The taxon level used for organisms |
color |
A condition to color data points by e.g. "AGE" |
shape |
A condition to shape data points by e.g. "SEX" |
cx |
Component on the x-axis e.g. 1 |
cy |
Component on the y-axis e.g. 2 |
cz |
Component on the z-axis e.g. 3 |
n_neighbors |
Number of nearest neighbors |
metric |
Distance function e.g. c("euclidean", "manhattan") |
n_epochs |
Number of iterations |
init |
Initial embedding using eigenvector e.g c("spectral", "random") |
min_dist |
Determines how close points appear in the final layout |
datatype |
Datatype to use e.g. c("logcpm", "relabu", "counts") |
A list with a plotly object and summary table
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) result <- dimred_umap(toy_data, tax_level = "genus", color = "AGE", shape = "DISEASE", cx = 1, cy = 2, datatype = "logcpm" ) result$plot
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) result <- dimred_umap(toy_data, tax_level = "genus", color = "AGE", shape = "DISEASE", cx = 1, cy = 2, datatype = "logcpm" ) result$plot
Get alpha diversity
diversities(counts_table, index = "all", zeroes = TRUE)
diversities(counts_table, index = "all", zeroes = TRUE)
counts_table |
A dataframe with organism x sample |
index |
One of inverse_simpson,gini_simpson,shannon,fisher,coverage,unit |
zeroes |
A boolean for whether to ignore zero values |
A list of alpha diversity
diversities(matrix(seq_len(12), nrow = 3), index = "shannon")
diversities(matrix(seq_len(12), nrow = 3), index = "shannon")
Get alpha diversity
diversities_help(counts_table, index = "all", zeroes = TRUE)
diversities_help(counts_table, index = "all", zeroes = TRUE)
counts_table |
A dataframe with organism x sample |
index |
one of inverse_simpson,gini_simpson,shannon,fisher,coverage,unit |
zeroes |
A boolean for whether to ignore zero values |
A list of alpha diversity
diversities_help(matrix(seq_len(12), nrow = 3), index = "shannon")
diversities_help(matrix(seq_len(12), nrow = 3), index = "shannon")
Beta diversity boxplot
diversity_beta_boxplot( MAE, tax_level, input_beta_method, input_select_beta_condition )
diversity_beta_boxplot( MAE, tax_level, input_beta_method, input_select_beta_condition )
MAE |
A multi-assay experiment object |
tax_level |
The taxon level used for organisms |
input_beta_method |
bray, jaccard |
input_select_beta_condition |
Which condition to group samples |
A plotly object
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) p <- diversity_beta_boxplot(toy_data, tax_level = "genus", input_beta_method = "bray", input_select_beta_condition = "DISEASE" ) p
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) p <- diversity_beta_boxplot(toy_data, tax_level = "genus", input_beta_method = "bray", input_select_beta_condition = "DISEASE" ) p
Beta diversity heatmap
diversity_beta_heatmap( MAE, tax_level, input_beta_method, input_bdhm_select_conditions, input_bdhm_sort_by = c("nosort", "conditions") )
diversity_beta_heatmap( MAE, tax_level, input_beta_method, input_bdhm_select_conditions, input_bdhm_sort_by = c("nosort", "conditions") )
MAE |
A multi-assay experiment object |
tax_level |
The taxon level used for organisms |
input_beta_method |
bray, jaccard |
input_bdhm_select_conditions |
Which condition to group samples |
input_bdhm_sort_by |
Sorting option e.g. "nosort", "conditions" |
A plotly object
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) p <- diversity_beta_heatmap(toy_data, tax_level = "genus", input_beta_method = "bray", input_bdhm_select_conditions = "DISEASE", input_bdhm_sort_by = "conditions" ) p
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) p <- diversity_beta_heatmap(toy_data, tax_level = "genus", input_beta_method = "bray", input_bdhm_select_conditions = "DISEASE", input_bdhm_sort_by = "conditions" ) p
Beta diversity NMDS plot
diversity_beta_NMDS( MAE, tax_level, input_beta_method, input_select_beta_condition )
diversity_beta_NMDS( MAE, tax_level, input_beta_method, input_select_beta_condition )
MAE |
A multi-assay experiment object |
tax_level |
The taxon level used for organisms |
input_beta_method |
bray, jaccard |
input_select_beta_condition |
Which condition to group samples |
A plotly object/NMDS plot
Perform a beta diversity test
diversity_beta_test( MAE, tax_level, input_beta_method, input_select_beta_condition, input_select_beta_stat_method, input_num_permutation_permanova = 999 )
diversity_beta_test( MAE, tax_level, input_beta_method, input_select_beta_condition, input_select_beta_stat_method, input_num_permutation_permanova = 999 )
MAE |
A Multi-Assay Experiment object. Required. |
tax_level |
The taxon level at which organisms should be grouped. Req'd. |
input_beta_method |
Can be either "bray" or "jaccard". Required. |
input_select_beta_condition |
Condition to group samples Should be a character string of a colData column name. Required. |
input_select_beta_stat_method |
The test to be used. Can be one of either "PERMANOVA", "Wilcoxon rank sum test", or "Kruskal-Wallis". Required. |
input_num_permutation_permanova |
The number of permutations to be used. |
A plotly object.
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) p <- diversity_beta_test(toy_data, tax_level = "genus", input_beta_method = "bray", input_select_beta_condition = "DISEASE", input_select_beta_stat_method = "Wilcoxon rank sum test", input_num_permutation_permanova = 999 ) p
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) p <- diversity_beta_test(toy_data, tax_level = "genus", input_beta_method = "bray", input_select_beta_condition = "DISEASE", input_select_beta_stat_method = "Wilcoxon rank sum test", input_num_permutation_permanova = 999 ) p
Alpha diversity statistical test
do_alpha_div_test( MAE, tax_level, condition, alpha_metric = c("inverse_simpson", "gini_simpson", "shannon", "fisher", "coverage", "unit"), alpha_stat = c("Wilcoxon rank sum test", "T-test", "Kruskal-Wallis") )
do_alpha_div_test( MAE, tax_level, condition, alpha_metric = c("inverse_simpson", "gini_simpson", "shannon", "fisher", "coverage", "unit"), alpha_stat = c("Wilcoxon rank sum test", "T-test", "Kruskal-Wallis") )
MAE |
A multi-assay experiment object |
tax_level |
The taxon level used for organisms |
condition |
Which condition to group samples |
alpha_metric |
Which alpha diversity metric to use |
alpha_stat |
Which stat test to use |
A dataframe
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) p <- do_alpha_div_test(toy_data, tax_level = "genus", condition = "DISEASE", alpha_metric = "shannon", alpha_stat = "Wilcoxon rank sum test" ) p
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) p <- do_alpha_div_test(toy_data, tax_level = "genus", condition = "DISEASE", alpha_metric = "shannon", alpha_stat = "Wilcoxon rank sum test" ) p
Categorize continuous variables
filter_categorize( sam_table, sample_condition, new_label, nbins = NULL, bin_breaks = c(), bin_labels = c() )
filter_categorize( sam_table, sample_condition, new_label, nbins = NULL, bin_breaks = c(), bin_labels = c() )
sam_table |
A sample x condition dataframe |
sample_condition |
Continuous variable to categorize |
new_label |
Column name for categorized variable |
nbins |
Auto select ranges for n bins/categories |
bin_breaks |
Manually select ranges for bins/categories |
bin_labels |
Manually label bins/categories |
A list with an updated sample table and before/after plots
library(SummarizedExperiment) data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) microbe <- MultiAssayExperiment::experiments(toy_data)[[1]] samples <- as.data.frame(colData(microbe)) result <- filter_categorize(samples, sample_condition = "AGE", new_label = "AGE_GROUP", bin_breaks = c(0, 55, 75, 100), bin_labels = c("Young", "Adult", "Elderly") ) result$sam_table result$plot.unbinned result$plot.binned
library(SummarizedExperiment) data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) microbe <- MultiAssayExperiment::experiments(toy_data)[[1]] samples <- as.data.frame(colData(microbe)) result <- filter_categorize(samples, sample_condition = "AGE", new_label = "AGE_GROUP", bin_breaks = c(0, 55, 75, 100), bin_labels = c("Young", "Adult", "Elderly") ) result$sam_table result$plot.unbinned result$plot.binned
Data visualization by bar plot / density plot
filter_summary_bar_density( MAE, samples_discard = NULL, filter_type, sample_condition )
filter_summary_bar_density( MAE, samples_discard = NULL, filter_type, sample_condition )
MAE |
A multi-assay experiment object |
samples_discard |
The list of samples to filter |
filter_type |
Either 'By Microbes' or 'By Metadata' |
sample_condition |
Which condition to check e.g. 'SEX' |
A plotly object
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) result <- filter_summary_bar_density(toy_data, samples_discard = c("subject_2", "subject_4"), filter_type = "By Metadata", sample_condition = "SEX" ) result
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) result <- filter_summary_bar_density(toy_data, samples_discard = c("subject_2", "subject_4"), filter_type = "By Metadata", sample_condition = "SEX" ) result
Data visualization by pie chart / box plot
filter_summary_pie_box( MAE, samples_discard = NULL, filter_type, sample_condition )
filter_summary_pie_box( MAE, samples_discard = NULL, filter_type, sample_condition )
MAE |
A multi-assay experiment object |
samples_discard |
The list of samples to filter |
filter_type |
Either 'By Microbes' or 'By Metadata' |
sample_condition |
Which condition to check e.g. 'SEX' |
A plotly object
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) result <- filter_summary_pie_box(toy_data, samples_discard = c("subject_2", "subject_4"), filter_type = "By Microbes", sample_condition = "SEX" ) result
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) result <- filter_summary_pie_box(toy_data, samples_discard = c("subject_2", "subject_4"), filter_type = "By Microbes", sample_condition = "SEX" ) result
Identify biomarkers
find_biomarker( MAE, tax_level, input_select_target_biomarker, nfolds = 3, nrepeats = 3, seed = 99, percent_top_biomarker = 0.2, model_name = c("logistic regression", "random forest") )
find_biomarker( MAE, tax_level, input_select_target_biomarker, nfolds = 3, nrepeats = 3, seed = 99, percent_top_biomarker = 0.2, model_name = c("logistic regression", "random forest") )
MAE |
A multi-assay experiment object |
tax_level |
The taxon level used for organisms |
input_select_target_biomarker |
Which condition is the target condition |
nfolds |
number of splits in CV |
nrepeats |
number of CVs with different random splits |
seed |
for repeatable research |
percent_top_biomarker |
Top importance percentage to pick biomarker |
model_name |
one of 'logistic regression', 'random forest' |
A list
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) p <- find_biomarker(toy_data, tax_level = "family", input_select_target_biomarker = c("DISEASE"), nfolds = 3, nrepeats = 3, seed = 99, percent_top_biomarker = 0.2, model_name = "logistic regression" ) p
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) p <- find_biomarker(toy_data, tax_level = "family", input_select_target_biomarker = c("DISEASE"), nfolds = 3, nrepeats = 3, seed = 99, percent_top_biomarker = 0.2, model_name = "logistic regression" ) p
Find the Taxonomy Information Matrix
find_taxon_mat(names, taxonLevels)
find_taxon_mat(names, taxonLevels)
names |
Row names of the taxonomy matrix |
taxonLevels |
Taxon Levels of all tids |
taxmat Taxonomy Information Matrix
ids <- c("ti|54005", "ti|73001", "ti|573", "ti|228277", "ti|53458") tids <- c("54005", "73001", "573", "228277", "53458") taxonLevels <- find_taxonomy(tids) tax_table <- find_taxon_mat(ids, taxonLevels)
ids <- c("ti|54005", "ti|73001", "ti|573", "ti|228277", "ti|53458") tids <- c("54005", "73001", "573", "228277", "53458") taxonLevels <- find_taxonomy(tids) tax_table <- find_taxon_mat(ids, taxonLevels)
Find the taxonomy for unlimited tids
find_taxonomy(tids)
find_taxonomy(tids)
tids |
Given taxonomy ids |
A list of taxon levels with information
taxonLevels <- find_taxonomy(tids = 1200)
taxonLevels <- find_taxonomy(tids = 1200)
Find the taxonomy for maximum 300 tids
find_taxonomy_300(tids)
find_taxonomy_300(tids)
tids |
Given taxonomy ids |
taxondata Data with the taxonomy information
taxonLevels <- find_taxonomy_300(tids = 1200)
taxonLevels <- find_taxonomy_300(tids = 1200)
Get alpha diversity using gini
gini_simpson(x)
gini_simpson(x)
x |
A list of counts |
A single value
gini_simpson(seq_len(10))
gini_simpson(seq_len(10))
Greps the tid from the given identifier string
grep_tid(id)
grep_tid(id)
id |
Given identifier string |
tid string
grep_tid("ti|700015|org|Coriobacterium_glomerans_PW2")
grep_tid("ti|700015|org|Coriobacterium_glomerans_PW2")
Get alpha diversity using inverse simpson
inverse_simpson(x)
inverse_simpson(x)
x |
A list of counts |
A single value
inverse_simpson(seq_len(10))
inverse_simpson(seq_len(10))
Check if object is categorical
is_categorical(v)
is_categorical(v)
v |
A single value |
Boolean
nums <- 2 is_categorical(nums)
nums <- 2 is_categorical(nums)
check if integer(0)
is_integer0(x)
is_integer0(x)
x |
A single value |
Boolean
nums <- 2 is_integer0(nums)
nums <- 2 is_integer0(nums)
check if integer(1)
is_integer1(x)
is_integer1(x)
x |
A single value |
Boolean
nums <- 2 is_integer1(nums)
nums <- 2 is_integer1(nums)
Modify organisms of multi-assay experiment object
mae_pick_organisms(MAE, isolate_organisms = NULL, discard_organisms = NULL)
mae_pick_organisms(MAE, isolate_organisms = NULL, discard_organisms = NULL)
MAE |
A multi-assay experiment object |
isolate_organisms |
Isolate specific organisms e.g. ti|001, ti|002 |
discard_organisms |
Discard specific organisms e.g. ti|001, ti|002 |
A multi-assay experiment object
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) subset <- mae_pick_organisms(toy_data, isolate_organisms = c("ti|001", "ti|002") )
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) subset <- mae_pick_organisms(toy_data, isolate_organisms = c("ti|001", "ti|002") )
Modify samples of multi-assay experiment object
mae_pick_samples(MAE, isolate_samples = NULL, discard_samples = NULL)
mae_pick_samples(MAE, isolate_samples = NULL, discard_samples = NULL)
MAE |
A multi-assay experiment object |
isolate_samples |
Isolate specific samples e.g. c('SAM_01', 'SAM_02') |
discard_samples |
Discard specific samples e.g. c('SAM_01', 'SAM_02') |
A multi-assay experiment object
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) subset <- mae_pick_samples(toy_data, isolate_samples = c( "subject_9", "subject_14" ) )
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) subset <- mae_pick_samples(toy_data, isolate_samples = c( "subject_9", "subject_14" ) )
Converts decimal percentage to string with specified digits
pct2str(v, digits = 2)
pct2str(v, digits = 2)
v |
A single value |
digits |
number of digits |
Boolean
nums <- 0.23 pct2str(nums)
nums <- 0.23 pct2str(nums)
Format decimals to percentages
percent(x, digits = 2, format = "f")
percent(x, digits = 2, format = "f")
x |
An array of decimals |
digits |
number of digits |
format |
f |
An array of formatted strings
nums <- c(0.42, 0.15, 0.4, 0.563, 0.2) percent(nums)
nums <- c(0.42, 0.15, 0.4, 0.563, 0.2) percent(nums)
Reads the data from PathoScope reports and returns a list of final guess relative abundance and count data
read_pathoscope_data( input_dir = ".", pathoreport_file_suffix = "-sam-report.tsv", use.input.files = FALSE, input.files.path.vec = NULL, input.files.name.vec = NULL )
read_pathoscope_data( input_dir = ".", pathoreport_file_suffix = "-sam-report.tsv", use.input.files = FALSE, input.files.path.vec = NULL, input.files.name.vec = NULL )
input_dir |
Directory where the tsv files from PathoScope are located |
pathoreport_file_suffix |
PathoScope report files suffix |
use.input.files |
whether input dir to pathoscope files or directly pathoscope files |
input.files.path.vec |
vector of pathoscope file paths |
input.files.name.vec |
vector of pathoscope file names |
List of final guess relative abundance and count data
Plot bar plots of sample and group level relative abundance
relabu_barplot( MAE, tax_level, order_organisms = c(), sort_by = c("nosort", "conditions", "organisms", "alphabetically"), group_samples = FALSE, group_conditions = "ALL", sample_conditions = c(), isolate_samples = c(), discard_samples = c(), show_legend = TRUE )
relabu_barplot( MAE, tax_level, order_organisms = c(), sort_by = c("nosort", "conditions", "organisms", "alphabetically"), group_samples = FALSE, group_conditions = "ALL", sample_conditions = c(), isolate_samples = c(), discard_samples = c(), show_legend = TRUE )
MAE |
A multi-assay experiment object |
tax_level |
The taxon level used for organisms |
order_organisms |
A character list of organisms to send to top |
sort_by |
Sort bars by one of c("nosort", "conditions", "organisms", "alphabetically") |
group_samples |
A bool specifying whether to group samples |
group_conditions |
Group by one or more conditions e.g. "ALL" or "SEX" |
sample_conditions |
Plot associatied conditions with samples. |
isolate_samples |
Isolate specific samples e.g. c("SAM_01", "SAM_02") |
discard_samples |
Discard specific samples e.g. c("SAM_01", "SAM_02") |
show_legend |
A bool specifying whether or not to show organisms legend |
A plotly object
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) p <- relabu_barplot(toy_data, tax_level = "family", order_organisms = c("Retroviridae"), sort_by = "organisms", sample_conditions = c("SEX", "AGE"), show_legend = TRUE ) p
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) p <- relabu_barplot(toy_data, tax_level = "family", order_organisms = c("Retroviridae"), sort_by = "organisms", sample_conditions = c("SEX", "AGE"), show_legend = TRUE ) p
Plot boxplots comparing different organism prevalence across conditions
relabu_boxplot( MAE, tax_level, condition, organisms = c(), datatype = c("counts", "relative abundance", "logcpm") )
relabu_boxplot( MAE, tax_level, condition, organisms = c(), datatype = c("counts", "relative abundance", "logcpm") )
MAE |
A multi-assay experiment object |
tax_level |
The taxon level used for organisms |
condition |
Compare groups by condition e.g. 'SEX' |
organisms |
Include organisms for plotting. |
datatype |
counts, relative abundance,logcpm |
A plotly object
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) p <- relabu_boxplot(toy_data, tax_level = "genus", organisms = c("Escherichia", "Actinomyces"), condition = "SEX", datatype = "logcpm" ) p
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) p <- relabu_boxplot(toy_data, tax_level = "genus", organisms = c("Escherichia", "Actinomyces"), condition = "SEX", datatype = "logcpm" ) p
Plot heatmap of sample level counts in logcpm
relabu_heatmap( MAE, tax_level, sort_by = c("nosort", "conditions", "organisms", "alphabetically"), sample_conditions = c(), isolate_organisms = c(), isolate_samples = c(), discard_samples = c(), log_cpm = TRUE )
relabu_heatmap( MAE, tax_level, sort_by = c("nosort", "conditions", "organisms", "alphabetically"), sample_conditions = c(), isolate_organisms = c(), isolate_samples = c(), discard_samples = c(), log_cpm = TRUE )
MAE |
A multi-assay experiment object |
tax_level |
The taxon level used for organisms |
sort_by |
Sort bars by one of c('nosort', 'conditions', 'organisms', 'alphabetically') |
sample_conditions |
Plot conditions e.g. c('SEX', 'AGE') |
isolate_organisms |
Isolate specific organisms e.g. c('Hepacivirus') |
isolate_samples |
Isolate specific samples e.g. c('SAM_01', 'SAM_02') |
discard_samples |
Discard specific samples e.g. c('SAM_01', 'SAM_02') |
log_cpm |
Convert counts to logcpm |
A plotly object
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) p <- relabu_heatmap(toy_data, tax_level = "genus", sort_by = "conditions", sample_conditions = c("SEX", "AGE") ) p
data_dir <- system.file("extdata/MAE.rds", package = "animalcules") toy_data <- readRDS(data_dir) p <- relabu_heatmap(toy_data, tax_level = "genus", sort_by = "conditions", sample_conditions = c("SEX", "AGE") ) p
Run animalcules shiny app
run_animalcules(dev = FALSE)
run_animalcules(dev = FALSE)
dev |
Run the applicaiton in developer mode |
The shiny app will open
## Not run: run_animalcules() ## End(Not run)
## Not run: run_animalcules() ## End(Not run)
Get alpha diversity using shannon
shannon(x)
shannon(x)
x |
A list of counts |
A single value
shannon(seq_len(10))
shannon(seq_len(10))
Get alpha diversity using simpson
simpson_index(x)
simpson_index(x)
x |
A list of counts |
A single value
simpson_index(seq_len(10))
simpson_index(seq_len(10))
Upsample a counts table to a higher taxon level
upsample_counts(counts_table, tax_table, higher_level)
upsample_counts(counts_table, tax_table, higher_level)
counts_table |
A organism x sample data frame of counts |
tax_table |
A organism x taxlev data frame of labels |
higher_level |
Higher taxon level to upsample to |
A organism x sample data frame of counts
toy_data <- readRDS(system.file("extdata/toy_data.rds", package = "animalcules")) tax_table <- toy_data$tax_table sam_table <- toy_data$sam_table counts_table <- toy_data$counts_table counts_table <- upsample_counts(counts_table, tax_table, "phylum")
toy_data <- readRDS(system.file("extdata/toy_data.rds", package = "animalcules")) tax_table <- toy_data$tax_table sam_table <- toy_data$sam_table counts_table <- toy_data$counts_table counts_table <- upsample_counts(counts_table, tax_table, "phylum")
Output biom
write_to_biom(MAE, path_to_output)
write_to_biom(MAE, path_to_output)
MAE |
A multi-assay experiment object |
path_to_output |
The folder to output biom file |
A message