createEnrichment | R Documentation |
Create a data.frame
object with several information to perform
enrichment analysis.
createEnrichment( object, priorKnowledge, enrichmentCol, namesCol = NULL, slot = "pValMat", colName = "adjP", type = "pvalue", direction = NULL, threshold_pvalue = 1, threshold_logfc = 0, top = NULL, alternative = "greater", verbose = FALSE )
object |
Output of differential abundance detection methods.
|
priorKnowledge |
|
enrichmentCol |
name of the column containing information for enrichment analysis. |
namesCol |
name of the column containing new names for features (default
|
slot |
A character vector with 1 or number-of-methods-times repeats of
the slot names where to extract values for each method
(default |
colName |
A character vector with 1 or number-of-methods-times repeats
of the column name of the slot where to extract values for each method
(default |
type |
A character vector with 1 or number-of-methods-times repeats
of the value type of the column selected where to extract values for each
method. Two values are possible: |
direction |
A character vector with 1 or number-of-methods-times repeats
of the |
threshold_pvalue |
A single or a numeric vector of thresholds for
p-values. If present, features with p-values lower than
|
threshold_logfc |
A single or a numeric vector of thresholds for log
fold changes. If present, features with log fold change absolute values
higher than |
top |
If not null, the |
alternative |
indicates the alternative hypothesis and must be
one of |
verbose |
Boolean to display the kind of extracted values
(default |
a list of objects for each method. Each list contains:
data
a data.frame
object with DA directions,
statistics, and feature names;
tables
a list of 2x2 contingency tables;
tests
the list of Fisher exact tests' p-values for each
contingency table;
summaries
a list with the first element of each
contingency table and its p-value (for graphical purposes);
addKnowledge
, extractDA
, and
enrichmentTest
.
data("ps_plaque_16S") data("microbial_metabolism") # Extract genera from the phyloseq tax_table slot genera <- phyloseq::tax_table(ps_plaque_16S)[, "GENUS"] # Genera as rownames of microbial_metabolism data.frame rownames(microbial_metabolism) <- microbial_metabolism$Genus # Match OTUs to their metabolism priorInfo <- data.frame(genera, "Type" = microbial_metabolism[genera, "Type"]) # Unmatched genera becomes "Unknown" unknown_metabolism <- is.na(priorInfo$Type) priorInfo[unknown_metabolism, "Type"] <- "Unknown" priorInfo$Type <- factor(priorInfo$Type) # Add a more informative names column priorInfo[, "newNames"] <- paste0(rownames(priorInfo), priorInfo[, "GENUS"]) # Add some normalization/scaling factors to the phyloseq object my_norm <- setNormalizations(fun = c("norm_edgeR", "norm_CSS"), method = c("TMM", "CSS")) ps_plaque_16S <- runNormalizations(normalization_list = my_norm, object = ps_plaque_16S) # Initialize some limma based methods my_limma <- set_limma(design = ~ 1 + RSID + HMP_BODY_SUBSITE, coef = "HMP_BODY_SUBSITESupragingival Plaque", norm = c("TMM", "CSS")) # Make sure the subject ID variable is a factor phyloseq::sample_data(ps_plaque_16S)[, "RSID"] <- as.factor( phyloseq::sample_data(ps_plaque_16S)[["RSID"]]) # Perform DA analysis Plaque_16S_DA <- runDA(method_list = my_limma, object = ps_plaque_16S) # Enrichment analysis enrichment <- createEnrichment(object = Plaque_16S_DA, priorKnowledge = priorInfo, enrichmentCol = "Type", namesCol = "GENUS", slot = "pValMat", colName = "adjP", type = "pvalue", direction = "logFC", threshold_pvalue = 0.1, threshold_logfc = 1, top = 10, verbose = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.