Methods for DeeDeeExperiment objects
Source:R/DeeDeeExperiment-methods.R
DeeDeeExperiment-methods.RdThe DeeDeeExperiment() class provides a family of methods to get
and set DE-related information and functional enrichment results in
DeeDeeExperiment objects.
Usage
# S4 method for class 'DeeDeeExperiment'
getDEAInfo(x)
# S4 method for class 'DeeDeeExperiment'
getDEAInfo(x) <- value
# S4 method for class 'DeeDeeExperiment'
getDEANames(x)
# S4 method for class 'DeeDeeExperiment'
renameDEA(x, old_name, new_name)
# S4 method for class 'DeeDeeExperiment'
addDEA(x, dea, force = FALSE)
# S4 method for class 'DeeDeeExperiment'
removeDEA(x, dea_name, remove_linked_fea = FALSE)
# S4 method for class 'DeeDeeExperiment'
getDEA(
x,
dea_name = NULL,
format = c("minimal", "original"),
extra_rd = NULL,
type = c("DFrame", "data.frame"),
verbose = FALSE
)
# S4 method for class 'DeeDeeExperiment'
getDEAList(x, format = c("minimal", "original"), verbose = FALSE)
# S4 method for class 'DeeDeeExperiment'
addScenarioInfo(x, dea_name, info = NULL, force = FALSE)
# S4 method for class 'DeeDeeExperiment'
getFEAInfo(x)
# S4 method for class 'DeeDeeExperiment'
getFEAInfo(x) <- value
# S4 method for class 'DeeDeeExperiment'
getFEANames(x)
# S4 method for class 'DeeDeeExperiment'
renameFEA(x, old_name, new_name)
# S4 method for class 'DeeDeeExperiment'
addFEA(
x,
fea,
de_name = NA_character_,
fe_name = NULL,
fea_tool = "auto",
force = FALSE,
verbose = FALSE
)
# S4 method for class 'DeeDeeExperiment'
removeFEA(x, fea_name)
# S4 method for class 'DeeDeeExperiment'
getFEA(x, fea_name = NULL, format = c("minimal", "original"), verbose = FALSE)
# S4 method for class 'DeeDeeExperiment'
getFEAList(
x,
dea_name = NULL,
format = c("minimal", "original"),
verbose = FALSE
)
# S4 method for class 'DeeDeeExperiment'
linkDEAandFEA(x, dea_name, fea_name, force = FALSE)Arguments
- x
A
DeeDeeExperiment()object- value
Replacement value for replacement methods.
- old_name
A character vector of existing DEA names to be renamed in a
DeeDeeExperimentobject- new_name
A character vector with new names to assign to existing DEA names in a
DeeDeeExperimentobject. It must be the same length ofold_name, and contains unique values that don't overlap with existing DEA names.- dea
A named list of DE results, in any of the formats supported by the package (currently: results from DESeq2, edgeR, limma).
- force
A logical, indicating whether to overwrite results when introducing the same results name. It defaults to FALSE.
- dea_name
Character value, specifying the name of the DE analysis to get or remove, or match against (e.g., to fetch associated FEA results), or to which additional context and information can be attached
- remove_linked_fea
A logical, specifying whether to remove or not the linked FEA when a DEA results is removed
- format
A character string, specifying the DEA/FEAs output format. It takes either "minimal" to return only essential columns (e.g. log2FC, p-value, adjusted p-value for DEAs, or gs_id, gs_description, gs_pvalue, gs_genes... for FEAs), or "original" to return the full result object. It defaults to "minimal"
- extra_rd
A character vector of additional columns from rowData(x) to include. It defaults to c("gene_id", "SYMBOL").
- type
A character string referring to the type of object returned by
getDEA(). It defaults toDFrame, but can also take the value ofdata.frame- verbose
Logical, whether or not to display warnings. If TRUE, warnings/messages will be displayed. If FALSE, the function runs silently
- info
A character vector, containing contextual information about the specified DE analysis. It defaults to NULL
- fea
A named list of Functional Enrichment results. Each element can be either a data.frame (currently supports results from
topGO,enrichR,gProfiler,fgsea,gsea,DAVID, and output ofGeneTonicshakers), or anenrichResult/gseaResultobjects (currently supportsclusterProfiler)- de_name
A character string to explicitly specify the name of the de result this fea should be linked to. If not provided, the function will attempt to match fea names to de results automatically.
- fe_name
A character string giving a name to the FE results.
- fea_tool
A character string indicating the FEA tool used. It can take any of the following values : "topGO", "clusterProfiler", "GeneTonic", "DAVID", "gsea", "fgsea", "enrichr", "gProfiler". When not specified, it defaults to "auto" and the tool is inferred automatically based on the input.
- fea_name
Character value, specifying the name of the functional enrichment result to add or remove
Details
DEAs
getDEAInfoandgetDEAInfo<-are the methods to get and set thedeainformation as a whole. These methods returnDeeDeeExperimentobjects.getDEANamesreturns the names of the available DE contrasts inDeeDeeExperimentobjects.renameDEAis the method to rename one or multiple DEAs stored in aDeeDeeExperimentobject.addDEAandremoveDEAare used to respectively add or remove DE-results items. These methods also returnDeeDeeExperimentobjects, with updated content in thedeaslot.getDEAandgetDEAListretrieve the DEA information, as well as some extra rowData information and provide this as aDataFrameobject (for a specific analysis) or as a list, with one element for each reported analysis.addScenarioInfois the method to add user defined contextual information for a specific DE analysis. It allows users to attach free-text notes to a specific DEA results that stored in aDeeDeeExperimentobject. This information can include any other relevant information to help document that DEA scenario. This context is stored in thedeaslot under the nameaddScenarioInfo, which is not a default element indea.
FEAs
getFEAInfoandgetFEAInfo<-are the methods to get and set thefeainformation as a whole. These methods returnDeeDeeExperimentobjects.getFEANamesreturns the names of the available enrichment results inDeeDeeExperimentobjects.renameFEAis the method to rename one or multiple FEAs stored in aDeeDeeExperimentobject.addFEAandremoveFEAare used to respectively add or remove functional enrichment results items. These methods also returnDeeDeeExperimentobjects, with updated content in thefeaslot.getFEAis the method to retrieve FE results stored in aDeeDeeExperimentobject for a specific contrast, as a standardized format similar to the output ofGeneTonicshakers.getFEAListis the method that retrieves FEA results as a list. if thedea_nameis indicated, the method will return only FEAs linked to thatdea_name, otherwise it returns all FEAs in thefeaslot.linkDEAandFEAis the method that allows the user to manually link a FEA result to a specific DEA result.showis the method to nicely print out the information of aDeeDeeExperimentobject.summaryis the method to print a summary of the available DE and FE results in aDeeDeeExperimentobject.
Examples
data("de_named_list", package = "DeeDeeExperiment")
data("topGO_results_list", package = "DeeDeeExperiment")
library("SummarizedExperiment")
rd_macrophage <- DataFrame(
gene_id = rownames(de_named_list$ifng_vs_naive)
)
rownames(rd_macrophage) <- rownames(de_named_list$ifng_vs_naive)
se_macrophage_noassays <- SummarizedExperiment(
assays = SimpleList(),
rowData = rd_macrophage
)
# creating a `DeeDeeExperiment`
dde <- DeeDeeExperiment(
se_macrophage_noassays,
de_results = de_named_list
)
dde
#> class: DeeDeeExperiment
#> dim: 1000 0
#> metadata(2): singlecontrast version
#> assays(0):
#> rownames(1000): ENSG00000164741 ENSG00000078808 ... ENSG00000273680
#> ENSG00000073536
#> rowData names(13): gene_id ifng_vs_naive_log2FoldChange ...
#> salmo_both_pvalue salmo_both_padj
#> colnames: NULL
#> colData names(0):
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):
#> dea(4): ifng_vs_naive, ifngsalmo_vs_naive, salmonella_vs_naive, salmo_both
#> fea(0):
new_del <- list(
ifng2 = de_named_list$ifng_vs_naive,
ifngsalmo2 = de_named_list$ifngsalmo_vs_naive
)
# add a new (set of) DE result(s)
dde_new <- addDEA(dde, new_del)
dde_new
#> class: DeeDeeExperiment
#> dim: 1000 0
#> metadata(2): singlecontrast version
#> assays(0):
#> rownames(1000): ENSG00000164741 ENSG00000078808 ... ENSG00000273680
#> ENSG00000073536
#> rowData names(19): gene_id ifng_vs_naive_log2FoldChange ...
#> ifngsalmo2_pvalue ifngsalmo2_padj
#> colnames: NULL
#> colData names(0):
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):
#> dea(6): ifng_vs_naive, ifngsalmo_vs_naive, salmonella_vs_naive, salmo_both, ifng2, ifngsalmo2
#> fea(0):
# removing DEAs
dde_removed <- removeDEA(dde, "ifng_vs_naive")
dde_removed
#> class: DeeDeeExperiment
#> dim: 1000 0
#> metadata(2): singlecontrast version
#> assays(0):
#> rownames(1000): ENSG00000164741 ENSG00000078808 ... ENSG00000273680
#> ENSG00000073536
#> rowData names(10): gene_id ifngsalmo_vs_naive_log2FoldChange ...
#> salmo_both_pvalue salmo_both_padj
#> colnames: NULL
#> colData names(0):
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):
#> dea(3): ifngsalmo_vs_naive, salmonella_vs_naive, salmo_both
#> fea(0):
# add a new (set of) FE result(s)
dde_new <- addFEA(dde, fea = topGO_results_list)
#> Found 955 gene sets in `topGOtableResult` object.
#> Converting for usage within the DeeDeeExperiment framework...
#> Found 955 gene sets in `topGOtableResult` object.
#> Converting for usage within the DeeDeeExperiment framework...
#> Found 955 gene sets in `topGOtableResult` object.
#> Converting for usage within the DeeDeeExperiment framework...
#> Found 955 gene sets in `topGOtableResult` object.
#> Converting for usage within the DeeDeeExperiment framework...
# removing FEAs
dde_rem <- removeFEA(dde_new, "ifng_vs_naive")
# display available DEAs
getDEANames(dde)
#> [1] "ifng_vs_naive" "ifngsalmo_vs_naive" "salmonella_vs_naive"
#> [4] "salmo_both"
# display available FEAs
getFEANames(dde)
#> NULL
# print a summary of the available DEAs and FEAs
summary(dde, FDR = 0.01)
#> Error in .Vector_summary(object, ...): unused argument (FDR = 0.01)
# rename DEA
dde_new <- renameDEA(dde_new,
old_name = "salmonella_vs_naive",
new_name = "Salmo_vs_Naive_renamed"
)
#> ✔ Renamed DEA entries: "salmonella_vs_naive" to "Salmo_vs_Naive_renamed"
# assign DEA to FEA
dde_new <- linkDEAandFEA(dde_new,
dea_name = "ifngsalmo_vs_naive",
fea_name = "ifngsalmo_vs_naive"
)
#> ✔ Assigning DEA: "ifngsalmo_vs_naive" to FEA "ifngsalmo_vs_naive"