Title: | Enjoy Analyzing And Integrating The Results From Differential Expression Analysis And Functional Enrichment Analysis |
---|---|
Description: | This package provides functionality to combine the existing pieces of the transcriptome data and results, making it easier to generate insightful observations and hypothesis. Its usage is made easy with a Shiny application, combining the benefits of interactivity and reproducibility e.g. by capturing the features and gene sets of interest highlighted during the live session, and creating an HTML report as an artifact where text, code, and output coexist. Using the GeneTonicList as a standardized container for all the required components, it is possible to simplify the generation of multiple visualizations and summaries. |
Authors: | Federico Marini [aut, cre] , Annekathrin Ludt [aut] |
Maintainer: | Federico Marini <[email protected]> |
License: | MIT + file LICENSE |
Version: | 3.1.0 |
Built: | 2024-10-30 07:26:22 UTC |
Source: | https://github.com/bioc/GeneTonic |
pandoc
and pandoc-citeproc
are availableCheck whether pandoc
and pandoc-citeproc
are available
.check_pandoc(ignore_pandoc)
.check_pandoc(ignore_pandoc)
ignore_pandoc |
Logical. If TRUE, just give a warning if one of pandoc or pandoc-citeproc is not available. If FALSE, an error is thrown. |
Credits to the original implementation proposed by Charlotte Soneson, upon which this function is heavily inspired.
No value is returned. If pandoc
or pandoc-citeproc
are missing,
either warning or error messages are triggered.
Check correct specification of colors
check_colors(x)
check_colors(x)
x |
A vector of strings specifying colors |
This is a vectorized version of grDevices::col2rgb()
A vector of logical values, one for each specified color - TRUE
if
the color is specified correctly
# simple case mypal <- c("steelblue", "#FF1100") check_colors(mypal) mypal2 <- rev( scales::alpha( colorRampPalette(RColorBrewer::brewer.pal(name = "RdYlBu", 11))(50), 0.4 ) ) check_colors(mypal2) # useful with long vectors to check at once if all cols are fine all(check_colors(mypal2))
# simple case mypal <- c("steelblue", "#FF1100") check_colors(mypal) mypal2 <- rev( scales::alpha( colorRampPalette(RColorBrewer::brewer.pal(name = "RdYlBu", 11))(50), 0.4 ) ) check_colors(mypal2) # useful with long vectors to check at once if all cols are fine all(check_colors(mypal2))
Checking the input objects for GeneTonic, whether these are all set for running the app
checkup_GeneTonic(dds, res_de, res_enrich, annotation_obj, verbose = FALSE)
checkup_GeneTonic(dds, res_de, res_enrich, annotation_obj, verbose = FALSE)
dds |
A |
res_de |
A |
res_enrich |
A |
annotation_obj |
A |
verbose |
Logical, to control level of verbosity of the messages generated |
Some suggestions on the requirements for each parameter are returned in the error messages.
Invisible NULL
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) checkup_GeneTonic( dds = dds_macrophage, res_de = res_de, res_enrich = res_enrich, annotation_obj = anno_df ) # if all is fine, it should return an invisible NULL and a simple message
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) checkup_GeneTonic( dds = dds_macrophage, res_de = res_de, res_enrich = res_enrich, annotation_obj = anno_df ) # if all is fine, it should return an invisible NULL and a simple message
gtl
input object for GeneTonicChecking the gtl
("GeneTonic list") input object for GeneTonic, with the
correct content and format expected
checkup_gtl(gtl, verbose = FALSE)
checkup_gtl(gtl, verbose = FALSE)
gtl |
A
|
verbose |
Logical, to control level of verbosity of the messages generated |
Some suggestions on the requirements for the gtl
are returned in the
error messages.
Invisible NULL
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gtl <- list( dds = dds_macrophage, res_de = res_de, res_enrich = res_enrich, annotation_obj = anno_df ) checkup_gtl(gtl) # if all is fine, it should return an invisible NULL and a simple message
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gtl <- list( dds = dds_macrophage, res_de = res_de, res_enrich = res_enrich, annotation_obj = anno_df ) checkup_gtl(gtl) # if all is fine, it should return an invisible NULL and a simple message
This function implements the Markov Clustering (MCL) algorithm for finding community
structure, in an analogous way to other existing algorithms in igraph
.
cluster_markov( g, add_self_loops = TRUE, loop_value = 1, mcl_expansion = 2, mcl_inflation = 2, allow_singletons = TRUE, max_iter = 100, return_node_names = TRUE, return_esm = FALSE )
cluster_markov( g, add_self_loops = TRUE, loop_value = 1, mcl_expansion = 2, mcl_inflation = 2, allow_singletons = TRUE, max_iter = 100, return_node_names = TRUE, return_esm = FALSE )
g |
The input graph object |
add_self_loops |
Logical, whether to add self-loops to the matrix by
setting the diagonal to |
loop_value |
Numeric, the value to use for self-loops |
mcl_expansion |
Numeric, cluster expansion factor for the Markov clustering iteration - defaults to 2 |
mcl_inflation |
Numeric, cluster inflation factor for the Markov clustering iteration - defaults to 2 |
allow_singletons |
Logical; if |
max_iter |
Numeric value for the maximum number of iterations for the Markov clustering |
return_node_names |
Logical, if the graph is named and set to |
return_esm |
Logical, controlling whether the equilibrium state matrix should be returned |
This implementation has been driven by the nice explanations provided in
https://sites.cs.ucsb.edu/~xyan/classes/CS595D-2009winter/MCL_Presentation2.pdf
https://medium.com/analytics-vidhya/demystifying-markov-clustering-aeb6cdabbfc7
https://github.com/GuyAllard/markov_clustering (python implementation)
More info on the MCL: https://micans.org/mcl/index.html, and https://micans.org/mcl/sec_description1.html
This function returns a communities
object, containing the numbers of
the assigned membership (in the slot membership
). Please see the
igraph::communities()
manual page for additional details
van Dongen, S.M., Graph clustering by flow simulation (2000) PhD thesis, Utrecht University Repository - https://dspace.library.uu.nl/handle/1874/848
Enright AJ, van Dongen SM, Ouzounis CA, An efficient algorithm for large-scale detection of protein families (2002) Nucleic Acids Research, Volume 30, Issue 7, 1 April 2002, Pages 1575–1584, https://doi.org/10.1093/nar/30.7.1575
library("igraph") g <- make_full_graph(5) %du% make_full_graph(5) %du% make_full_graph(5) g <- add_edges(g, c(1, 6, 1, 11, 6, 11)) cluster_markov(g) V(g)$color <- cluster_markov(g)$membership plot(g)
library("igraph") g <- make_full_graph(5) %du% make_full_graph(5) %du% make_full_graph(5) g <- add_edges(g, c(1, 6, 1, 11, 6, 11)) cluster_markov(g) V(g)$color <- cluster_markov(g)$membership plot(g)
Compute the overlap matrix for enrichment results, based on the Jaccard Index between each pair of sets
create_jaccard_matrix( res_enrich, gtl = NULL, n_gs = nrow(res_enrich), gs_ids = NULL, return_sym = FALSE )
create_jaccard_matrix( res_enrich, gtl = NULL, n_gs = nrow(res_enrich), gs_ids = NULL, return_sym = FALSE )
res_enrich |
A |
gtl |
A |
n_gs |
Integer value, corresponding to the maximal number of gene sets to
be included (from the top ranked ones). Defaults to the number of rows of
|
gs_ids |
Character vector, containing a subset of |
return_sym |
Logical, whether to return the symmetrical matrix or just the
upper triangular - as needed by |
A matrix with the kappa scores between gene sets
# res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) jmat <- create_jaccard_matrix(res_enrich[1:200, ]) dim(jmat)
# res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) jmat <- create_jaccard_matrix(res_enrich[1:200, ]) dim(jmat)
Compute the kappa matrix for enrichment results, as a measure of overlap
create_kappa_matrix( res_enrich, gtl = NULL, n_gs = nrow(res_enrich), gs_ids = NULL )
create_kappa_matrix( res_enrich, gtl = NULL, n_gs = nrow(res_enrich), gs_ids = NULL )
res_enrich |
A |
gtl |
A |
n_gs |
Integer value, corresponding to the maximal number of gene sets to
be included (from the top ranked ones). Defaults to the number of rows of
|
gs_ids |
Character vector, containing a subset of |
A matrix with the kappa scores between gene sets
# res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) kmat <- create_kappa_matrix(res_enrich[1:200, ]) dim(kmat)
# res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) kmat <- create_kappa_matrix(res_enrich[1:200, ]) dim(kmat)
Create a data frame that can be fed to the upset function
create_upsetdata(res_enrich, use_ids = FALSE)
create_upsetdata(res_enrich, use_ids = FALSE)
res_enrich |
A |
use_ids |
Logical - whether to use the |
A data.frame to be used in ComplexUpset::upset()
# res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) create_upsetdata(res_enrich[1:20, ]) dim(create_upsetdata(res_enrich[1:20, ])) create_upsetdata(res_enrich[1:5, ], use_ids = TRUE)
# res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) create_upsetdata(res_enrich[1:20, ]) dim(create_upsetdata(res_enrich[1:20, ])) create_upsetdata(res_enrich[1:5, ], use_ids = TRUE)
Functions that are on their way to the function afterlife. Their successors are also listed.
... |
Ignored arguments. |
The successors of these functions are likely coming after the rework that
led to the creation of the mosdef
package. See more into its
documentation for more details.
All functions throw a warning, with a deprecation message pointing towards its descendent (if available).
deseqresult2df()
, now replaced by the more consistent
mosdef::deresult_to_df()
. The only change in its functionality concerns
the parameter names
gene_plot()
has now been moved to mosdef::gene_plot()
, where it
generalizes with respect to the container of the DE workflow object. In a
similar fashion, get_expression_values()
is replaced by
mosdef::get_expr_values()
. Both functions lose the gtl
parameter, which
was anyways not really exploited throughout the different calls in the
package
go_2_html()
and geneinfo_2_html()
have been replaced by the more
information-rich (and flexible) mosdef::go_to_html()
and
mosdef::geneinfo_to_html()
, respectively. No change is expected for the
end user
map2color()
and styleColorBar_divergent()
are now moved to the
mosdef::map_to_color()
and mosdef::styleColorBar_divergent()
, again with
no visible changes for the end user
The internally defined functions .link2amigo()
, .link2ncbi()
,
.link2genecards()
and .link2gtex()
are now replaced by the equivalent
functions in mosdef
:
mosdef::create_link_GO()
, mosdef::create_link_NCBI()
,
mosdef::create_link_GeneCards()
and mosdef::create_link_GO()
.
Notably, the mosdef
package expanded on the
concept of automatically generated buttons, taking this to the extreme of
efficiency with the mosdef::buttonifier()
function
Federico Marini
# try(deseqresult2df())
# try(deseqresult2df())
Obtain a quick textual overview of the essential features of the components of the GeneTonic list object
describe_gtl(gtl)
describe_gtl(gtl)
gtl |
A |
A character string, that can further be processed (e.g. by message()
or cat()
, or easily rendered inside Shiny's renderText
elements)
DESeq2
resultsGenerate a tidy table with the results of DESeq2
deseqresult2df(res_de, FDR = NULL)
deseqresult2df(res_de, FDR = NULL)
res_de |
A |
FDR |
Numeric value, specifying the significance level for thresholding adjusted p-values. Defaults to NULL, which would return the full set of results without performing any subsetting based on FDR. |
A tidy data.frame
with the results from differential expression,
sorted by adjusted p-value. If FDR is specified, the table contains only genes
with adjusted p-value smaller than the value.
data(res_de_macrophage, package = "GeneTonic") head(res_macrophage_IFNg_vs_naive) res_df <- mosdef::deresult_to_df(res_macrophage_IFNg_vs_naive) head(res_df)
data(res_de_macrophage, package = "GeneTonic") head(res_macrophage_IFNg_vs_naive) res_df <- mosdef::deresult_to_df(res_macrophage_IFNg_vs_naive) head(res_df)
Distill the main topics from the enrichment results, based on the graph derived from constructing an enrichment map
distill_enrichment( res_enrich, res_de, annotation_obj, gtl = NULL, n_gs = nrow(res_enrich), cluster_fun = "cluster_markov" )
distill_enrichment( res_enrich, res_de, annotation_obj, gtl = NULL, n_gs = nrow(res_enrich), cluster_fun = "cluster_markov" )
res_enrich |
A |
res_de |
A |
annotation_obj |
A |
gtl |
A |
n_gs |
Integer value, corresponding to the maximal number of gene sets to be used. |
cluster_fun |
Character, referring to the name of the function used for
the community detection in the enrichment map graph. Could be one of "cluster_markov",
"cluster_louvain", or "cluster_walktrap", as they all return a |
A list containing three objects:
the distilled table of enrichment, distilled_table
, where the new meta-genesets
are identified and defined, specifying e.g. the names of each component, and the
genes associated to these.
the distilled graph for the enrichment map, distilled_em
, with the information
on the membership
the original res_enrich
, augmented with the information of the membership
related to the meta-genesets
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) distilled <- distill_enrichment(res_enrich, res_de, annotation_obj, n_gs = 100, cluster_fun = "cluster_markov" ) colnames(distilled$distilled_table) distilled$distilled_em
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) distilled <- distill_enrichment(res_enrich, res_de, annotation_obj, n_gs = 100, cluster_fun = "cluster_markov" ) colnames(distilled$distilled_table) distilled$distilled_em
Extract vectors from the shinyAce editor content, also removing comments and whitespaces from text.
editor_to_vector_sanitized(txt)
editor_to_vector_sanitized(txt)
txt |
A single character text input. |
A character vector representing valid lines in the text input of the editor.
Creates a visual summary for the results of a functional enrichment analysis, by displaying also the components of each gene set and their expression change in the contrast of interest
enhance_table( res_enrich, res_de, annotation_obj, gtl = NULL, n_gs = 50, gs_ids = NULL, chars_limit = 70, plot_style = c("point", "ridgeline"), ridge_color = c("gs_id", "gs_score"), plot_title = NULL )
enhance_table( res_enrich, res_de, annotation_obj, gtl = NULL, n_gs = 50, gs_ids = NULL, chars_limit = 70, plot_style = c("point", "ridgeline"), ridge_color = c("gs_id", "gs_score"), plot_title = NULL )
res_enrich |
A |
res_de |
A |
annotation_obj |
A |
gtl |
A |
n_gs |
Integer value, corresponding to the maximal number of gene sets to be displayed. |
gs_ids |
Character vector, containing a subset of |
chars_limit |
Integer, number of characters to be displayed for each geneset name. |
plot_style |
Character value, one of "point" or "ridgeline". Defines the style of the plot to summarize visually the table. |
ridge_color |
Character value, one of "gs_id" or "gs_score", controls the
fill color of the ridge lines. If selecting "gs_score", the |
plot_title |
Character string, used as title for the plot. If left |
A ggplot
object
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) enhance_table(res_enrich, res_de, anno_df, n_gs = 10 ) # using the ridge line as a style, also coloring by the Z score res_enrich_withscores <- get_aggrscores( res_enrich, res_de, anno_df ) enhance_table(res_enrich_withscores, res_de, anno_df, n_gs = 10, plot_style = "ridgeline", ridge_color = "gs_score" )
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) enhance_table(res_enrich, res_de, anno_df, n_gs = 10 ) # using the ridge line as a style, also coloring by the Z score res_enrich_withscores <- get_aggrscores( res_enrich, res_de, anno_df ) enhance_table(res_enrich_withscores, res_de, anno_df, n_gs = 10, plot_style = "ridgeline", ridge_color = "gs_score" )
Generates a graph for the enrichment map, combining information from res_enrich
and res_de
. This object can be further plotted, e.g. statically via
igraph::plot.igraph()
, or dynamically via
visNetwork::visIgraph()
enrichment_map( res_enrich, res_de, annotation_obj, gtl = NULL, n_gs = 50, gs_ids = NULL, overlap_threshold = 0.1, scale_edges_width = 200, scale_nodes_size = 5, color_by = "gs_pvalue" )
enrichment_map( res_enrich, res_de, annotation_obj, gtl = NULL, n_gs = 50, gs_ids = NULL, overlap_threshold = 0.1, scale_edges_width = 200, scale_nodes_size = 5, color_by = "gs_pvalue" )
res_enrich |
A |
res_de |
A |
annotation_obj |
A |
gtl |
A |
n_gs |
Integer value, corresponding to the maximal number of gene sets to be displayed |
gs_ids |
Character vector, containing a subset of |
overlap_threshold |
Numeric value, between 0 and 1. Defines the threshold to be used for removing edges in the enrichment map - edges below this value will be excluded from the final graph. Defaults to 0.1. |
scale_edges_width |
A numeric value, to define the scaling factor for the
edges between nodes. Defaults to 200 (works well chained to |
scale_nodes_size |
A numeric value, to define the scaling factor for the
node sizes. Defaults to 5 - works well chained to |
color_by |
Character, specifying the column of |
An igraph
object to be further manipulated or processed/plotted
GeneTonic()
embeds an interactive visualization for the enrichment map
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) em <- enrichment_map(res_enrich, res_de, anno_df, n_gs = 20 ) em # could be viewed interactively with # library("visNetwork") # library("magrittr") # em %>% # visIgraph() %>% # visOptions(highlightNearest = list(enabled = TRUE, # degree = 1, # hover = TRUE), # nodesIdSelection = TRUE)
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) em <- enrichment_map(res_enrich, res_de, anno_df, n_gs = 20 ) em # could be viewed interactively with # library("visNetwork") # library("magrittr") # em %>% # visIgraph() %>% # visOptions(highlightNearest = list(enabled = TRUE, # degree = 1, # hover = TRUE), # nodesIdSelection = TRUE)
A sample output object as created from a call to Enrichr, with the interface
provided by enrichR
- using the enrichr()
function
This object has been created on the data from the macrophage
package
by analyzing downstream the differentially expressed genes
when comparing IFNg treated samples vs naive samples, accounting
for the different cell lines included.
Details on how this object has been created are included in the create_gt_data.R
script, included in the scripts
folder of the GeneTonic
package.
Alasoo, et al. "Shared genetic effects on chromatin and gene expression indicate a role for enhancer priming in immune response", Nature Genetics, January 2018 doi: 10.1038/s41588-018-0046-7.
Other pathway-analysis-results:
gostres_macrophage
,
topgoDE_macrophage_IFNg_vs_naive
Combine data from a typical DESeq2 run
export_for_iSEE(dds, res_de, gtl = NULL)
export_for_iSEE(dds, res_de, gtl = NULL)
dds |
A |
res_de |
A |
gtl |
A |
Combines the DESeqDataSet input and DESeqResults into a SummarizedExperiment object, which can be readily explored with iSEE.
A typical usage would be after running the DESeq2 pipeline and/or after exploring
the functional enrichment results with GeneTonic()
A SummarizedExperiment
object, with raw counts, normalized counts, and
variance-stabilizing transformed counts in the assay slots; and with colData
and rowData extracted from the corresponding input parameters - mainly the
results for differential expression analysis.
library("macrophage") library("DESeq2") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # now everything is in place to launch the app # dds_macrophage <- DESeq2::DESeq(dds_macrophage) se_macrophage <- export_for_iSEE(dds_macrophage, res_de) # iSEE(se_macrophage)
library("macrophage") library("DESeq2") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # now everything is in place to launch the app # dds_macrophage <- DESeq2::DESeq(dds_macrophage) se_macrophage <- export_for_iSEE(dds_macrophage, res_de) # iSEE(se_macrophage)
Export a graph to a Simple Interaction Format file
export_to_sif(g, sif_file = "", edge_label = "relates_to")
export_to_sif(g, sif_file = "", edge_label = "relates_to")
g |
An |
sif_file |
Character string, the path to the file where to save the exported graph as .sif file |
edge_label |
Character string, defining the name of the interaction type. Defaults here to "relates_to" |
Returns the path to the exported file, invisibly
library("igraph") g <- make_full_graph(5) %du% make_full_graph(5) %du% make_full_graph(5) g <- add_edges(g, c(1, 6, 1, 11, 6, 11)) export_to_sif(g, tempfile())
library("igraph") g <- make_full_graph(5) %du% make_full_graph(5) %du% make_full_graph(5) g <- add_edges(g, c(1, 6, 1, 11, 6, 11)) export_to_sif(g, tempfile())
A sample output object as created from a call to the fgsea()
function, in
the fgsea
package, as a practical framework for performing GSEA
This object has been created on the data from the macrophage
package
by analyzing downstream the differentially expressed genes
when comparing IFNg treated samples vs naive samples, accounting
for the different cell lines included.
Alasoo, et al. "Shared genetic effects on chromatin and gene expression indicate a role for enhancer priming in immune response", Nature Genetics, January 2018 doi: 10.1038/s41588-018-0046-7.
Plot expression values (e.g. normalized counts) for a gene of interest, grouped by experimental group(s) of interest
gene_plot( dds, gene, intgroup = "condition", assay = "counts", annotation_obj = NULL, normalized = TRUE, transform = TRUE, labels_display = TRUE, labels_repel = TRUE, plot_type = "auto", return_data = FALSE, gtl = NULL )
gene_plot( dds, gene, intgroup = "condition", assay = "counts", annotation_obj = NULL, normalized = TRUE, transform = TRUE, labels_display = TRUE, labels_repel = TRUE, plot_type = "auto", return_data = FALSE, gtl = NULL )
dds |
A |
gene |
Character, specifies the identifier of the feature (gene) to be plotted |
intgroup |
A character vector of names in |
assay |
Character, specifies with assay of the |
annotation_obj |
A |
normalized |
Logical value, whether the expression values should be
normalized by their size factor. Defaults to TRUE, applies when |
transform |
Logical value, corresponding whether to have log scale y-axis or not. Defaults to TRUE. |
labels_display |
Logical value. Whether to display the labels of samples, defaults to TRUE. |
labels_repel |
Logical value. Whether to use |
plot_type |
Character, one of "auto", "jitteronly", "boxplot", "violin",
or "sina". Defines the type of |
return_data |
Logical, whether the function should just return the data.frame of expression values and covariates for custom plotting. Defaults to FALSE. |
gtl |
A |
The result of this function can be fed directly to plotly::ggplotly()
for interactive visualization, instead of the static ggplot
viz.
A ggplot
object
library("macrophage") library("DESeq2") library("org.Hs.eg.db") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) gene_plot(dds_macrophage, gene = "ENSG00000125347", intgroup = "condition", annotation_obj = anno_df )
library("macrophage") library("DESeq2") library("org.Hs.eg.db") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) gene_plot(dds_macrophage, gene = "ENSG00000125347", intgroup = "condition", annotation_obj = anno_df )
Assembles information, in HTML format, regarding a gene symbol identifier
geneinfo_2_html(gene_id, res_de = NULL)
geneinfo_2_html(gene_id, res_de = NULL)
gene_id |
Character specifying the gene identifier for which to retrieve information |
res_de |
A |
Creates links to the NCBI and the GeneCards databases
HTML content related to a gene identifier, to be displayed in web applications (or inserted in Rmd documents)
geneinfo_2_html("ACTB") geneinfo_2_html("Pf4")
geneinfo_2_html("ACTB") geneinfo_2_html("Pf4")
GeneTonic, main function for the Shiny app
GeneTonic( dds = NULL, res_de = NULL, res_enrich = NULL, annotation_obj = NULL, gtl = NULL, project_id = "", size_gtl = 50 )
GeneTonic( dds = NULL, res_de = NULL, res_enrich = NULL, annotation_obj = NULL, gtl = NULL, project_id = "", size_gtl = 50 )
dds |
A |
res_de |
A |
res_enrich |
A
|
annotation_obj |
A |
gtl |
A |
project_id |
A character string, which can be considered as an identifier
for the set/session, and will be e.g. used in the title of the report created
via |
size_gtl |
Numeric value, specifying the maximal size in MB for the accepted GeneTonicList object - this applies when uploading the dataset at runtime |
A Shiny app object is returned, for interactive data exploration
Federico Marini
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) # now everything is in place to launch the app if (interactive()) { GeneTonic( dds = dds_macrophage, res_de = res_de, res_enrich = res_enrich, annotation_obj = anno_df, project_id = "myexample" ) } # alternatively... gtl_macrophage <- GeneTonicList( dds = dds_macrophage, res_de = res_de, res_enrich = res_enrich, annotation_obj = anno_df ) # GeneTonic(gtl = gtl_macrophage) # if running it "as a server", without input data specified: if (interactive()) { GeneTonic(size_gtl = 300) # for fairly large gtl objects }
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) # now everything is in place to launch the app if (interactive()) { GeneTonic( dds = dds_macrophage, res_de = res_de, res_enrich = res_enrich, annotation_obj = anno_df, project_id = "myexample" ) } # alternatively... gtl_macrophage <- GeneTonicList( dds = dds_macrophage, res_de = res_de, res_enrich = res_enrich, annotation_obj = anno_df ) # GeneTonic(gtl = gtl_macrophage) # if running it "as a server", without input data specified: if (interactive()) { GeneTonic(size_gtl = 300) # for fairly large gtl objects }
Create a list for GeneTonic from the single required components.
GeneTonicList(dds, res_de, res_enrich, annotation_obj) GeneTonic_list(dds, res_de, res_enrich, annotation_obj)
GeneTonicList(dds, res_de, res_enrich, annotation_obj) GeneTonic_list(dds, res_de, res_enrich, annotation_obj)
dds |
A |
res_de |
A |
res_enrich |
A
|
annotation_obj |
A |
Having this dedicated function saves the pain of remembering which names
the components of the list should have.
For backwards compatibility, the GeneTonic_list
function is still provided
as a synonim, and will likely be deprecated in the upcoming release cycles.
A GeneTonic
-list object, containing in its named slots the arguments
specified above: dds
, res_de
, res_enrich
, and annotation_obj
- the names
of the list are specified following the requirements for using it as single
input to GeneTonic()
Federico Marini
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gtl_macrophage <- GeneTonicList( dds = dds_macrophage, res_de = res_de, res_enrich = res_enrich, annotation_obj = anno_df ) # now everything is in place to launch the app if (interactive()) { GeneTonic(gtl = gtl_macrophage) }
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gtl_macrophage <- GeneTonicList( dds = dds_macrophage, res_de = res_de, res_enrich = res_enrich, annotation_obj = anno_df ) # now everything is in place to launch the app if (interactive()) { GeneTonic(gtl = gtl_macrophage) }
Computes for each gene set in the res_enrich
object a Z score and an aggregated
score (using the log2FoldChange values, provided in the res_de
)
get_aggrscores(res_enrich, res_de, annotation_obj, gtl = NULL, aggrfun = mean)
get_aggrscores(res_enrich, res_de, annotation_obj, gtl = NULL, aggrfun = mean)
res_enrich |
A |
res_de |
A |
annotation_obj |
A |
gtl |
A |
aggrfun |
Specifies the function to use for aggregating the scores for
each term. Common values could be |
A data.frame
with the same columns as provided in the input, with
additional information on the z_score
and the aggr_score
for each gene set.
This information is used by other functions such as gs_volcano()
or
enrichment_map()
gs_volcano()
and enrichment_map()
make efficient use of the computed
aggregated scores
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores( res_enrich, res_de, anno_df )
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores( res_enrich, res_de, anno_df )
Extract expression values, with the possibility to select other assay slots
get_expression_values( dds, gene, intgroup, assay = "counts", normalized = TRUE, gtl = NULL )
get_expression_values( dds, gene, intgroup, assay = "counts", normalized = TRUE, gtl = NULL )
dds |
A |
gene |
Character, specifies the identifier of the feature (gene) to be extracted |
intgroup |
A character vector of names in |
assay |
Character, specifies with assay of the |
normalized |
Logical value, whether the expression values should be
normalized by their size factor. Defaults to TRUE, applies when |
gtl |
A |
A tidy data.frame with the expression values and covariates for further processing
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) df_exp <- get_expression_values(dds_macrophage, gene = "ENSG00000125347", intgroup = "condition" ) head(df_exp)
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) df_exp <- get_expression_values(dds_macrophage, gene = "ENSG00000125347", intgroup = "condition" ) head(df_exp)
Extract the backbone for the gene-geneset graph, either for the genes or for the genesets
ggs_backbone( res_enrich, res_de, annotation_obj = NULL, gtl = NULL, n_gs = 15, gs_ids = NULL, bb_on = c("genesets", "features"), bb_method = c("sdsm", "fdsm", "fixedrow"), bb_extract_alpha = 0.05, bb_extract_fwer = c("none", "bonferroni", "holm"), bb_fullinfo = FALSE, bb_remove_singletons = TRUE, color_graph = TRUE, color_by_geneset = "z_score", color_by_feature = "log2FoldChange", ... )
ggs_backbone( res_enrich, res_de, annotation_obj = NULL, gtl = NULL, n_gs = 15, gs_ids = NULL, bb_on = c("genesets", "features"), bb_method = c("sdsm", "fdsm", "fixedrow"), bb_extract_alpha = 0.05, bb_extract_fwer = c("none", "bonferroni", "holm"), bb_fullinfo = FALSE, bb_remove_singletons = TRUE, color_graph = TRUE, color_by_geneset = "z_score", color_by_feature = "log2FoldChange", ... )
res_enrich |
A |
res_de |
A |
annotation_obj |
A |
gtl |
A |
n_gs |
Integer value, corresponding to the maximal number of gene sets to be included |
gs_ids |
Character vector, containing a subset of |
bb_on |
A character string, either "genesets" or "features", to specify which entity should be based the backbone graph on. |
bb_method |
A character string, referring to the function to be called (
from the |
bb_extract_alpha |
A numeric value, specifying the significance level to use when detecting the backbone of the network |
bb_extract_fwer |
A character string, defaulting to "none", specifying which method to use for the multiple testing correction for controlling the family-wise error rate |
bb_fullinfo |
Logical value, determining what will be returned as output:
either a simple |
bb_remove_singletons |
Logical value, defines whether to remove or leave in the returned graph the nodes that are not connected to other vertices |
color_graph |
Logical value, specifies whether to use information about genesets or features to colorize the nodes, e.g. for this info to be used in interactive versions of the graph |
color_by_geneset |
Character string, corresponding to the column in
|
color_by_feature |
Character string, corresponding to the column in
|
... |
Additional parameters to be passed internally |
According to the bb_fullinfo
, either a simple ìgraph
object with
the graph backbone, or a named list object containing:
the igraph
of the extracted backbone
the backbone
object itself
the gene-geneset graph used for the computation
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) ggs_bbg <- ggs_backbone(res_enrich, res_de, anno_df, n_gs = 50, bb_on = "genesets", color_graph = TRUE, color_by_geneset = "z_score" ) plot(ggs_bbg) # if desired, one can also plot the interactive version visNetwork::visIgraph(ggs_bbg)
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) ggs_bbg <- ggs_backbone(res_enrich, res_de, anno_df, n_gs = 50, bb_on = "genesets", color_graph = TRUE, color_by_geneset = "z_score" ) plot(ggs_bbg) # if desired, one can also plot the interactive version visNetwork::visIgraph(ggs_bbg)
Construct a gene-geneset-graph from the results of a functional enrichment analysis
ggs_graph( res_enrich, res_de, annotation_obj = NULL, gtl = NULL, n_gs = 15, gs_ids = NULL, prettify = TRUE, geneset_graph_color = "gold", genes_graph_colpal = NULL )
ggs_graph( res_enrich, res_de, annotation_obj = NULL, gtl = NULL, n_gs = 15, gs_ids = NULL, prettify = TRUE, geneset_graph_color = "gold", genes_graph_colpal = NULL )
res_enrich |
A |
res_de |
A |
annotation_obj |
A |
gtl |
A |
n_gs |
Integer value, corresponding to the maximal number of gene sets to be included |
gs_ids |
Character vector, containing a subset of |
prettify |
Logical, controlling the aspect of the returned graph object. If TRUE (default value), different shapes of the nodes are returned, based on the node type |
geneset_graph_color |
Character value, specifying which color should be used for the fill of the shapes related to the gene sets. |
genes_graph_colpal |
A vector of colors, also provided with their hex string, to be used as a palette for coloring the gene nodes. If unspecified, defaults to a color ramp palette interpolating from blue through yellow to red. |
An igraph
object to be further manipulated or processed/plotted (e.g.
via igraph::plot.igraph()
or
visNetwork::visIgraph())
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) ggs <- ggs_graph( res_enrich, res_de, anno_df ) ggs #' # could be viewed interactively with # library(visNetwork) # library(magrittr) # ggs %>% # visIgraph() %>% # visOptions(highlightNearest = list(enabled = TRUE, # degree = 1, # hover = TRUE), # nodesIdSelection = TRUE)
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) ggs <- ggs_graph( res_enrich, res_de, anno_df ) ggs #' # could be viewed interactively with # library(visNetwork) # library(magrittr) # ggs %>% # visIgraph() %>% # visOptions(highlightNearest = list(enabled = TRUE, # degree = 1, # hover = TRUE), # nodesIdSelection = TRUE)
Assembles information, in HTML format, regarding a Gene Ontology identifier
go_2_html(go_id, res_enrich = NULL)
go_2_html(go_id, res_enrich = NULL)
go_id |
Character, specifying the GeneOntology identifier for which to retrieve information |
res_enrich |
A |
Also creates a link to the AmiGO database
HTML content related to a GeneOntology identifier, to be displayed in web applications (or inserted in Rmd documents)
go_2_html("GO:0002250") go_2_html("GO:0043368")
go_2_html("GO:0002250") go_2_html("GO:0043368")
A sample output object as created from a call to g:Profiler, with the interface
provided by gprofiler2
- using the gost()
function
This object has been created on the data from the macrophage
package
by analyzing downstream the differentially expressed genes
when comparing IFNg treated samples vs naive samples, accounting
for the different cell lines included.
Details on how this object has been created are included in the create_gt_data.R
script, included in the scripts
folder of the GeneTonic
package.
Alasoo, et al. "Shared genetic effects on chromatin and gene expression indicate a role for enhancer priming in immune response", Nature Genetics, January 2018 doi: 10.1038/s41588-018-0046-7.
Other pathway-analysis-results:
enrichr_output_macrophage
,
topgoDE_macrophage_IFNg_vs_naive
Generate an interactive alluvial plot linking genesets to their associated genes
gs_alluvial( res_enrich, res_de, annotation_obj, gtl = NULL, n_gs = 5, gs_ids = NULL ) gs_sankey( res_enrich, res_de, annotation_obj, gtl = NULL, n_gs = 5, gs_ids = NULL )
gs_alluvial( res_enrich, res_de, annotation_obj, gtl = NULL, n_gs = 5, gs_ids = NULL ) gs_sankey( res_enrich, res_de, annotation_obj, gtl = NULL, n_gs = 5, gs_ids = NULL )
res_enrich |
A |
res_de |
A |
annotation_obj |
A |
gtl |
A |
n_gs |
Integer value, corresponding to the maximal number of gene sets to be displayed |
gs_ids |
Character vector, containing a subset of |
A plotly
object
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gs_alluvial( res_enrich = res_enrich, res_de = res_de, annotation_obj = anno_df, n_gs = 4 ) # or using the alias... gs_sankey( res_enrich = res_enrich, res_de = res_de, annotation_obj = anno_df, n_gs = 4 )
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gs_alluvial( res_enrich = res_enrich, res_de = res_de, annotation_obj = anno_df, n_gs = 4 ) # or using the alias... gs_sankey( res_enrich = res_enrich, res_de = res_de, annotation_obj = anno_df, n_gs = 4 )
Calculate (and plot) the dendrogram of the gene set enrichment results
gs_dendro( res_enrich, gtl = NULL, n_gs = nrow(res_enrich), gs_ids = NULL, gs_dist_type = "kappa", clust_method = "ward.D2", color_leaves_by = "z_score", size_leaves_by = "gs_pvalue", color_branches_by = "clusters", create_plot = TRUE )
gs_dendro( res_enrich, gtl = NULL, n_gs = nrow(res_enrich), gs_ids = NULL, gs_dist_type = "kappa", clust_method = "ward.D2", color_leaves_by = "z_score", size_leaves_by = "gs_pvalue", color_branches_by = "clusters", create_plot = TRUE )
res_enrich |
A |
gtl |
A |
n_gs |
Integer value, corresponding to the maximal number of gene sets to
be included (from the top ranked ones). Defaults to the number of rows of
|
gs_ids |
Character vector, containing a subset of |
gs_dist_type |
Character string, specifying which type of similarity (and
therefore distance measure) will be used. Defaults to |
clust_method |
Character string defining the agglomeration method to be
used for the hierarchical clustering. See |
color_leaves_by |
Character string, which columns of |
size_leaves_by |
Character string, which columns of |
color_branches_by |
Character string, which columns of |
create_plot |
Logical, whether to create the plot as well. |
A dendrogram object is returned invisibly, and a plot can be generated as well on that object.
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gs_dendro(res_enrich, n_gs = 100 )
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gs_dendro(res_enrich, n_gs = 100 )
Compute fuzzy clusters of different gene sets, aiming to identify grouped categories that can better represent the distinct biological themes in the enrichment results
gs_fuzzyclustering( res_enrich, gtl = NULL, n_gs = nrow(res_enrich), gs_ids = NULL, similarity_matrix = NULL, similarity_threshold = 0.35, fuzzy_seeding_initial_neighbors = 3, fuzzy_multilinkage_rule = 0.5 )
gs_fuzzyclustering( res_enrich, gtl = NULL, n_gs = nrow(res_enrich), gs_ids = NULL, similarity_matrix = NULL, similarity_threshold = 0.35, fuzzy_seeding_initial_neighbors = 3, fuzzy_multilinkage_rule = 0.5 )
res_enrich |
A |
gtl |
A |
n_gs |
Integer value, corresponding to the maximal number of gene sets to be displayed |
gs_ids |
Character vector, containing a subset of |
similarity_matrix |
A similarity matrix between gene sets. Can be e.g.
computed with |
similarity_threshold |
A numeric value for the similarity matrix, used to determine the initial seeds as in the implementation of DAVID. Higher values will lead to more genesets being initially unclustered, leading to a functional classification result with fewer groups and fewer geneset members. Defaults to 0.35, recommended to not go below 0.3 (see DAVID help pages) |
fuzzy_seeding_initial_neighbors |
Integer value, corresponding to the minimum geneset number in a seeding group. Lower values will lead to the inclusion of more genesets in the functional groups, and may generate a lot of small size groups. Defaults to 3 |
fuzzy_multilinkage_rule |
Numeric value, comprised between 0 and 1. This parameter will determine how the seeding groups merge with each other, by specifying the percentage of shared genesets required to merge the two subsets into one group. Higher values will give sharper separation between the groups of genesets. Defaults to 0.5 (50%) |
A data frame, shaped in a similar way as the originally provided
res_enrich
object, containing two extra columns: gs_fuzzycluster
, to specify
the identifier of the fuzzy cluster of genesets, and gs_cluster_status
, which
can specify whether the geneset is the "Representative" for that cluster or
a simple "Member".
Notably, the number of rows in the returned object can be higher than the
original number of rows in res_enrich
.
See https://david.ncifcrf.gov/helps/functional_classification.html#clustering for details on the original implementation
data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) # taking a smaller subset res_enrich_subset <- res_enrich[1:100, ] fuzzy_subset <- gs_fuzzyclustering( res_enrich = res_enrich_subset, n_gs = nrow(res_enrich_subset), gs_ids = NULL, similarity_matrix = NULL, similarity_threshold = 0.35, fuzzy_seeding_initial_neighbors = 3, fuzzy_multilinkage_rule = 0.5 ) # show all genesets members of the first cluster fuzzy_subset[fuzzy_subset$gs_fuzzycluster == "1", ] # list only the representative clusters head(fuzzy_subset[fuzzy_subset$gs_cluster_status == "Representative", ], 10)
data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) # taking a smaller subset res_enrich_subset <- res_enrich[1:100, ] fuzzy_subset <- gs_fuzzyclustering( res_enrich = res_enrich_subset, n_gs = nrow(res_enrich_subset), gs_ids = NULL, similarity_matrix = NULL, similarity_threshold = 0.35, fuzzy_seeding_initial_neighbors = 3, fuzzy_multilinkage_rule = 0.5 ) # show all genesets members of the first cluster fuzzy_subset[fuzzy_subset$gs_fuzzycluster == "1", ] # list only the representative clusters head(fuzzy_subset[fuzzy_subset$gs_cluster_status == "Representative", ], 10)
Plot a heatmap for the selected gene signature on the provided data, with the possibility to compactly display also DE only genes
gs_heatmap( se, res_de, res_enrich, annotation_obj = NULL, gtl = NULL, geneset_id = NULL, genelist = NULL, FDR = 0.05, de_only = FALSE, cluster_rows = TRUE, cluster_columns = FALSE, center_mean = TRUE, scale_row = FALSE, winsorize_threshold = NULL, anno_col_info = NULL, plot_title = NULL, ... )
gs_heatmap( se, res_de, res_enrich, annotation_obj = NULL, gtl = NULL, geneset_id = NULL, genelist = NULL, FDR = 0.05, de_only = FALSE, cluster_rows = TRUE, cluster_columns = FALSE, center_mean = TRUE, scale_row = FALSE, winsorize_threshold = NULL, anno_col_info = NULL, plot_title = NULL, ... )
se |
A |
res_de |
A |
res_enrich |
A |
annotation_obj |
A |
gtl |
A |
geneset_id |
Character specifying the gene set identifier to be plotted |
genelist |
A vector of character strings, specifying the identifiers
contained in the row names of the |
FDR |
Numeric value, specifying the significance level for thresholding adjusted p-values. Defaults to 0.05. |
de_only |
Logical, whether to include only differentially expressed genes in the plot |
cluster_rows |
Logical, determining if rows should be clustered, as
specified by |
cluster_columns |
Logical, determining if columns should be clustered, as
specified by |
center_mean |
Logical, whether to perform mean centering on the row-wise |
scale_row |
Logical, whether to standardize by row the expression values |
winsorize_threshold |
Numeric value, to be applied as value to winsorize
the extreme values of the heatmap. Should be a positive number. Defaults to
NULL, which corresponds to not applying any winsorization. Suggested values:
enter 2 or 3 if using row-standardized values ( |
anno_col_info |
A character vector of names in |
plot_title |
Character string, to specify the title of the plot,
displayed over the heatmap. If left to |
... |
Additional arguments passed to other methods, e.g. in the call to
|
A plot returned by the ComplexHeatmap::Heatmap()
function
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) vst_macrophage <- vst(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gs_heatmap(vst_macrophage, res_de, res_enrich, anno_df, geneset_id = res_enrich$gs_id[1], cluster_columns = TRUE, anno_col_info = "condition" )
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) vst_macrophage <- vst(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gs_heatmap(vst_macrophage, res_de, res_enrich, anno_df, geneset_id = res_enrich$gs_id[1], cluster_columns = TRUE, anno_col_info = "condition" )
Plots a summary of enrichment results - horizon plot to compare one or more sets of results
gs_horizon( res_enrich, compared_res_enrich_list, n_gs = 20, p_value_column = "gs_pvalue", color_by = "z_score", ref_name = "ref_scenario", sort_by = c("clustered", "first_set") )
gs_horizon( res_enrich, compared_res_enrich_list, n_gs = 20, p_value_column = "gs_pvalue", color_by = "z_score", ref_name = "ref_scenario", sort_by = c("clustered", "first_set") )
res_enrich |
A |
compared_res_enrich_list |
A named list, where each element is a |
n_gs |
Integer value, corresponding to the maximal number of gene sets to be displayed |
p_value_column |
Character string, specifying the column of |
color_by |
Character, specifying the column of |
ref_name |
Character, defining the name of the scenario to compare
against (the one in |
sort_by |
Character string, either "clustered", or "first_set". This controls the sorting order of the included terms in the final plot. "clustered" presents the terms grouped by the scenario where they assume the highest values. "first_set" sorts the terms by the significance value in the reference scenario. |
It makes sense to have the results in res_enrich
sorted by
increasing gs_pvalue
, to make sure the top results are first sorted by the
significance (when selecting the common gene sets across the res_enrich
elements provided in compared_res_enrich_list
)
The gene sets included are a subset of the ones in common to all different
scenarios included in res_enrich
and the elements of compared_res_enrich_list
.
A ggplot
object
gs_summary_overview()
, gs_summary_overview_pair()
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) res_enrich2 <- res_enrich[1:42, ] res_enrich3 <- res_enrich[1:42, ] res_enrich4 <- res_enrich[1:42, ] set.seed(2 * 42) shuffled_ones_2 <- sample(seq_len(42)) # to generate permuted p-values res_enrich2$gs_pvalue <- res_enrich2$gs_pvalue[shuffled_ones_2] res_enrich2$z_score <- res_enrich2$z_score[shuffled_ones_2] res_enrich2$aggr_score <- res_enrich2$aggr_score[shuffled_ones_2] set.seed(3 * 42) shuffled_ones_3 <- sample(seq_len(42)) # to generate permuted p-values res_enrich3$gs_pvalue <- res_enrich3$gs_pvalue[shuffled_ones_3] res_enrich3$z_score <- res_enrich3$z_score[shuffled_ones_3] res_enrich3$aggr_score <- res_enrich3$aggr_score[shuffled_ones_3] set.seed(4 * 42) shuffled_ones_4 <- sample(seq_len(42)) # to generate permuted p-values res_enrich4$gs_pvalue <- res_enrich4$gs_pvalue[shuffled_ones_4] res_enrich4$z_score <- res_enrich4$z_score[shuffled_ones_4] res_enrich4$aggr_score <- res_enrich4$aggr_score[shuffled_ones_4] compa_list <- list( scenario2 = res_enrich2, scenario3 = res_enrich3, scenario4 = res_enrich4 ) gs_horizon(res_enrich, compared_res_enrich_list = compa_list, n_gs = 50, sort_by = "clustered" ) gs_horizon(res_enrich, compared_res_enrich_list = compa_list, n_gs = 20, sort_by = "first_set" )
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) res_enrich2 <- res_enrich[1:42, ] res_enrich3 <- res_enrich[1:42, ] res_enrich4 <- res_enrich[1:42, ] set.seed(2 * 42) shuffled_ones_2 <- sample(seq_len(42)) # to generate permuted p-values res_enrich2$gs_pvalue <- res_enrich2$gs_pvalue[shuffled_ones_2] res_enrich2$z_score <- res_enrich2$z_score[shuffled_ones_2] res_enrich2$aggr_score <- res_enrich2$aggr_score[shuffled_ones_2] set.seed(3 * 42) shuffled_ones_3 <- sample(seq_len(42)) # to generate permuted p-values res_enrich3$gs_pvalue <- res_enrich3$gs_pvalue[shuffled_ones_3] res_enrich3$z_score <- res_enrich3$z_score[shuffled_ones_3] res_enrich3$aggr_score <- res_enrich3$aggr_score[shuffled_ones_3] set.seed(4 * 42) shuffled_ones_4 <- sample(seq_len(42)) # to generate permuted p-values res_enrich4$gs_pvalue <- res_enrich4$gs_pvalue[shuffled_ones_4] res_enrich4$z_score <- res_enrich4$z_score[shuffled_ones_4] res_enrich4$aggr_score <- res_enrich4$aggr_score[shuffled_ones_4] compa_list <- list( scenario2 = res_enrich2, scenario3 = res_enrich3, scenario4 = res_enrich4 ) gs_horizon(res_enrich, compared_res_enrich_list = compa_list, n_gs = 50, sort_by = "clustered" ) gs_horizon(res_enrich, compared_res_enrich_list = compa_list, n_gs = 20, sort_by = "first_set" )
Multi Dimensional Scaling plot for gene sets, extracted from a res_enrich
object
gs_mds( res_enrich, res_de, annotation_obj, gtl = NULL, n_gs = nrow(res_enrich), gs_ids = NULL, similarity_measure = "kappa_matrix", mds_k = 2, mds_labels = 0, mds_colorby = "z_score", gs_labels = NULL, plot_title = NULL, return_data = FALSE )
gs_mds( res_enrich, res_de, annotation_obj, gtl = NULL, n_gs = nrow(res_enrich), gs_ids = NULL, similarity_measure = "kappa_matrix", mds_k = 2, mds_labels = 0, mds_colorby = "z_score", gs_labels = NULL, plot_title = NULL, return_data = FALSE )
res_enrich |
A |
res_de |
A |
annotation_obj |
A |
gtl |
A |
n_gs |
Integer value, corresponding to the maximal number of gene sets to
be included (from the top ranked ones). Defaults to the number of rows of
|
gs_ids |
Character vector, containing a subset of |
similarity_measure |
Character, currently defaults to |
mds_k |
Integer value, number of dimensions to compute in the multi dimensional scaling procedure |
mds_labels |
Integer, defines the number of labels to be plotted on top of the scatter plot for the provided gene sets. |
mds_colorby |
Character specifying the column of |
gs_labels |
Character vector, containing a subset of |
plot_title |
Character string, used as title for the plot. If left |
return_data |
Logical, whether the function should just return the
data.frame of the MDS coordinates, related to the original |
A ggplot
object
create_kappa_matrix()
is used to calculate the similarity between
gene sets
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gs_mds(res_enrich, res_de, anno_df, n_gs = 200, mds_labels = 10 )
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gs_mds(res_enrich, res_de, anno_df, n_gs = 200, mds_labels = 10 )
Radar (spider) plot for gene sets, either for one or more results from functional enrichment analysis.
gs_radar( res_enrich, res_enrich2 = NULL, n_gs = 20, p_value_column = "gs_pvalue" ) gs_spider( res_enrich, res_enrich2 = NULL, n_gs = 20, p_value_column = "gs_pvalue" )
gs_radar( res_enrich, res_enrich2 = NULL, n_gs = 20, p_value_column = "gs_pvalue" ) gs_spider( res_enrich, res_enrich2 = NULL, n_gs = 20, p_value_column = "gs_pvalue" )
res_enrich |
A |
res_enrich2 |
Analogous to |
n_gs |
Integer value, corresponding to the maximal number of gene sets to be displayed |
p_value_column |
Character string, specifying the column of |
A plotly
object
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gs_radar(res_enrich = res_enrich) # or using the alias... gs_spider(res_enrich = res_enrich) # with more than one set res_enrich2 <- res_enrich[1:60, ] set.seed(42) shuffled_ones <- sample(seq_len(60)) # to generate permuted p-values res_enrich2$gs_pvalue <- res_enrich2$gs_pvalue[shuffled_ones] # ideally, I would also permute the z scores and aggregated scores gs_radar( res_enrich = res_enrich, res_enrich2 = res_enrich2 )
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gs_radar(res_enrich = res_enrich) # or using the alias... gs_spider(res_enrich = res_enrich) # with more than one set res_enrich2 <- res_enrich[1:60, ] set.seed(42) shuffled_ones <- sample(seq_len(60)) # to generate permuted p-values res_enrich2$gs_pvalue <- res_enrich2$gs_pvalue[shuffled_ones] # ideally, I would also permute the z scores and aggregated scores gs_radar( res_enrich = res_enrich, res_enrich2 = res_enrich2 )
Compute gene set scores for each sample, by transforming the gene-wise change to a geneset-wise change
gs_scores(se, res_de, res_enrich, annotation_obj = NULL, gtl = NULL)
gs_scores(se, res_de, res_enrich, annotation_obj = NULL, gtl = NULL)
se |
A |
res_de |
A |
res_enrich |
A |
annotation_obj |
A |
gtl |
A |
A matrix with the geneset Z scores, e.g. to be plotted with gs_scoresheat()
gs_scoresheat()
plots these scores
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) vst_macrophage <- vst(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) scores_mat <- gs_scores( vst_macrophage, res_de, res_enrich[1:50, ], anno_df )
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) vst_macrophage <- vst(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) scores_mat <- gs_scores( vst_macrophage, res_de, res_enrich[1:50, ], anno_df )
Plots a matrix of geneset Z scores, across all samples
gs_scoresheat( mat, n_gs = nrow(mat), gs_ids = NULL, clustering_distance_rows = "euclidean", clustering_distance_cols = "euclidean", cluster_rows = TRUE, cluster_cols = TRUE )
gs_scoresheat( mat, n_gs = nrow(mat), gs_ids = NULL, clustering_distance_rows = "euclidean", clustering_distance_cols = "euclidean", cluster_rows = TRUE, cluster_cols = TRUE )
mat |
A matrix, e.g. returned by the |
n_gs |
Integer value, corresponding to the maximal number of gene sets to be displayed. |
gs_ids |
Character vector, containing a subset of |
clustering_distance_rows |
Character, a distance measure used in clustering rows |
clustering_distance_cols |
Character, a distance measure used in clustering columns |
cluster_rows |
Logical, determining if rows should be clustered |
cluster_cols |
Logical, determining if columns should be clustered |
A ggplot
object
gs_scores()
computes the scores plotted by this function
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) vst_macrophage <- vst(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) scores_mat <- gs_scores( vst_macrophage, res_de, res_enrich[1:30, ], anno_df ) gs_scoresheat(scores_mat, n_gs = 30 )
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) vst_macrophage <- vst(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) scores_mat <- gs_scores( vst_macrophage, res_de, res_enrich[1:30, ], anno_df ) gs_scoresheat(scores_mat, n_gs = 30 )
Simplify results from functional enrichment analysis, removing genesets that are redundant to enhance interpretation of the results
gs_simplify(res_enrich, gs_overlap = 0.75)
gs_simplify(res_enrich, gs_overlap = 0.75)
res_enrich |
A |
gs_overlap |
Numeric value, which defines the threshold for removing
terms that present an overlap greater than the specified value. Changing its
value can control the granularity of how redundant terms are removed from the
original |
A data.frame
with a subset of the original gene sets
gs_volcano()
and ggs_graph()
can e.g. show an overview on the
simplified table of gene sets
# res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) dim(res_enrich) res_enrich_simplified <- gs_simplify(res_enrich) dim(res_enrich_simplified) # and then use this further for all other functions expecting a res_enrich
# res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) dim(res_enrich) res_enrich_simplified <- gs_simplify(res_enrich) dim(res_enrich_simplified) # and then use this further for all other functions expecting a res_enrich
Plots a heatmap for genes and genesets, useful to spot out intersections across genesets and an overview of them
gs_summary_heat(res_enrich, res_de, annotation_obj, gtl = NULL, n_gs = 80)
gs_summary_heat(res_enrich, res_de, annotation_obj, gtl = NULL, n_gs = 80)
res_enrich |
A |
res_de |
A |
annotation_obj |
A |
gtl |
A |
n_gs |
Integer value, corresponding to the maximal number of gene sets to be displayed |
A ggplot
object
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gs_summary_heat( res_enrich = res_enrich, res_de = res_de, annotation_obj = anno_df, n_gs = 20 )
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gs_summary_heat( res_enrich = res_enrich, res_de = res_de, annotation_obj = anno_df, n_gs = 20 )
Plots a summary of enrichment results for one set
gs_summary_overview( res_enrich, gtl = NULL, n_gs = 20, p_value_column = "gs_pvalue", color_by = "z_score", return_barchart = FALSE )
gs_summary_overview( res_enrich, gtl = NULL, n_gs = 20, p_value_column = "gs_pvalue", color_by = "z_score", return_barchart = FALSE )
res_enrich |
A |
gtl |
A |
n_gs |
Integer value, corresponding to the maximal number of gene sets to be displayed |
p_value_column |
Character string, specifying the column of |
color_by |
Character, specifying the column of |
return_barchart |
Logical, whether to return a barchart (instead of the default dot-segment plot); defaults to FALSE. |
A ggplot
object
gs_summary_overview_pair()
, gs_horizon()
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gs_summary_overview(res_enrich) # if desired, it can also be shown as a barplot gs_summary_overview(res_enrich, n_gs = 30, return_barchart = TRUE)
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gs_summary_overview(res_enrich) # if desired, it can also be shown as a barplot gs_summary_overview(res_enrich, n_gs = 30, return_barchart = TRUE)
Plots a summary of enrichment results - for two sets of results
gs_summary_overview_pair( res_enrich, res_enrich2, n_gs = 20, p_value_column = "gs_pvalue", color_by = "z_score", alpha_set2 = 1 )
gs_summary_overview_pair( res_enrich, res_enrich2, n_gs = 20, p_value_column = "gs_pvalue", color_by = "z_score", alpha_set2 = 1 )
res_enrich |
A |
res_enrich2 |
As |
n_gs |
Integer value, corresponding to the maximal number of gene sets to be displayed |
p_value_column |
Character string, specifying the column of |
color_by |
Character, specifying the column of |
alpha_set2 |
Numeric value, between 0 and 1, which specified the alpha transparency used for plotting the points for gene set 2. |
A ggplot
object
gs_summary_overview()
, gs_horizon()
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) res_enrich2 <- res_enrich[1:42, ] set.seed(42) shuffled_ones <- sample(seq_len(42)) # to generate permuted p-values res_enrich2$gs_pvalue <- res_enrich2$gs_pvalue[shuffled_ones] res_enrich2$z_score <- res_enrich2$z_score[shuffled_ones] res_enrich2$aggr_score <- res_enrich2$aggr_score[shuffled_ones] # ideally, I would also permute the z scores and aggregated scores gs_summary_overview_pair( res_enrich = res_enrich, res_enrich2 = res_enrich2 )
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) res_enrich2 <- res_enrich[1:42, ] set.seed(42) shuffled_ones <- sample(seq_len(42)) # to generate permuted p-values res_enrich2$gs_pvalue <- res_enrich2$gs_pvalue[shuffled_ones] res_enrich2$z_score <- res_enrich2$z_score[shuffled_ones] res_enrich2$aggr_score <- res_enrich2$aggr_score[shuffled_ones] # ideally, I would also permute the z scores and aggregated scores gs_summary_overview_pair( res_enrich = res_enrich, res_enrich2 = res_enrich2 )
Create an upset plot for genesets
gs_upset( res_enrich, res_de = NULL, annotation_obj = NULL, n_gs = 10, gtl = NULL, gs_ids = NULL, add_de_direction = FALSE, add_de_gsgenes = FALSE, col_upDE = "#E41A1C", col_downDE = "#377EB8", upset_geom = geom_point(size = 2), return_upsetgsg = FALSE )
gs_upset( res_enrich, res_de = NULL, annotation_obj = NULL, n_gs = 10, gtl = NULL, gs_ids = NULL, add_de_direction = FALSE, add_de_gsgenes = FALSE, col_upDE = "#E41A1C", col_downDE = "#377EB8", upset_geom = geom_point(size = 2), return_upsetgsg = FALSE )
res_enrich |
A |
res_de |
A |
annotation_obj |
A |
n_gs |
Integer value, corresponding to the maximal number of gene sets to be included |
gtl |
A |
gs_ids |
Character vector, containing a subset of |
add_de_direction |
Logical, whether to add an annotation with info on the DE direction of single genes |
add_de_gsgenes |
Logical, if set to TRUE adds an annotation with detail on the single components of each defined subset |
col_upDE |
Character, specifying the color value to be used to mark upregulated genes |
col_downDE |
Character, specifying the color value to be used to mark downregulated genes |
upset_geom |
A geom specification to be used in the upset chart. Defaults
sensibly to |
return_upsetgsg |
Logical, controlling the returned value. If set to TRUE, this function will not generate the plot but only create the corresponding data.frame, in case the user wants to proceed with a custom call to create an upset plot. |
A ggplot
object (if plotting), or alternatively a data.frame
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gs_upset(res_enrich, n_gs = 10 ) gs_upset(res_enrich, res_de = res_de, annotation_obj = anno_df, n_gs = 8, add_de_direction = TRUE, add_de_gsgenes = TRUE ) # or using the practical gtl (GeneTonicList) gtl_macrophage <- GeneTonic_list( dds = dds_macrophage, res_de = res_de, res_enrich = res_enrich, annotation_obj = anno_df ) gs_upset( gtl = gtl_macrophage, n_gs = 15, add_de_direction = TRUE, add_de_gsgenes = TRUE )
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gs_upset(res_enrich, n_gs = 10 ) gs_upset(res_enrich, res_de = res_de, annotation_obj = anno_df, n_gs = 8, add_de_direction = TRUE, add_de_gsgenes = TRUE ) # or using the practical gtl (GeneTonicList) gtl_macrophage <- GeneTonic_list( dds = dds_macrophage, res_de = res_de, res_enrich = res_enrich, annotation_obj = anno_df ) gs_upset( gtl = gtl_macrophage, n_gs = 15, add_de_direction = TRUE, add_de_gsgenes = TRUE )
Volcano plot for gene sets, to summarize visually the functional enrichment results
gs_volcano( res_enrich, gtl = NULL, p_threshold = 0.05, color_by = "aggr_score", volcano_labels = 10, scale_circles = 1, gs_ids = NULL, plot_title = NULL )
gs_volcano( res_enrich, gtl = NULL, p_threshold = 0.05, color_by = "aggr_score", volcano_labels = 10, scale_circles = 1, gs_ids = NULL, plot_title = NULL )
res_enrich |
A |
gtl |
A |
p_threshold |
Numeric, defines the threshold to be used for filtering the gene sets to display. Defaults to 0.05 |
color_by |
Character specifying the column of |
volcano_labels |
Integer, maximum number of labels for the gene sets to be plotted as labels on the volcano scatter plot. |
scale_circles |
A numeric value, to define the scaling factor for the circle sizes. Defaults to 1. |
gs_ids |
Character vector, containing a subset of |
plot_title |
Character string, used as title for the plot. If left |
It is also possible to reduce the redundancy of the input res_enrich
object,
if it is passed in advance to the gs_simplify()
function.
A ggplot
object
gs_simplify()
can be applied in advance to res_enrich
to reduce
the redundancy of the displayed gene sets
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gs_volcano(res_enrich)
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) gs_volcano(res_enrich)
Start the happy hour, creating a report containing a document full of goodies derived from the provided objects.
happy_hour( dds, res_de, res_enrich, annotation_obj, gtl = NULL, project_id, mygenesets, mygenes, mygroup = NULL, usage_mode = "batch_mode", input_rmd = NULL, output_file = "my_first_GeneTonic_happyhour.html", output_dir = tempdir(), output_format = NULL, force_overwrite = FALSE, knitr_show_progress = FALSE, ignore_pandoc = FALSE, open_after_creating = TRUE, ... )
happy_hour( dds, res_de, res_enrich, annotation_obj, gtl = NULL, project_id, mygenesets, mygenes, mygroup = NULL, usage_mode = "batch_mode", input_rmd = NULL, output_file = "my_first_GeneTonic_happyhour.html", output_dir = tempdir(), output_format = NULL, force_overwrite = FALSE, knitr_show_progress = FALSE, ignore_pandoc = FALSE, open_after_creating = TRUE, ... )
dds |
A |
res_de |
A |
res_enrich |
A |
annotation_obj |
A |
gtl |
A |
project_id |
A character string, which can be considered as an identifier
for the set/session, and will be e.g. used in the title of the report created
via |
mygenesets |
A vector of character strings, containing the genesets to focus on in the report - for each geneset, e.g. a signature heatmap can be created. |
mygenes |
A vector of character strings, containing the genes to focus on in the report - for each gene, the plot of the expression values is included. |
mygroup |
A character string, or a vector thereof. Contains the experimental variables to be used to split into groups the expression data, and color accordingly. |
usage_mode |
A character string, which controls the behavior of the Rmd document, based on whether the rendering is triggered while using the app ("shiny_mode"), or offline, in batch mode. Defaults to "batch_mode". |
input_rmd |
Character string with the path to the RMarkdown (.Rmd) file
that will be used as the template for generating the report. Defaults to NULL,
which will then use the one provided with the |
output_file |
Character string, specifying the file name of the output
report. The file name extension must be either |
output_dir |
Character, defining the path to the output directory where
the report will be generated. Defaults to the temp directory ( |
output_format |
The format of the output report. Either |
force_overwrite |
Logical, whether to force overwrite an existing report with the same name in the output directory. Defaults to FALSE. |
knitr_show_progress |
Logical, whether to display the progress of |
ignore_pandoc |
Logical, controlling how the report generation function
will behave if |
open_after_creating |
Logical, whether to open the report in the default browser after being generated. Defaults to TRUE. |
... |
Other arguments that will be passed to |
When happy_hour
is called, a RMarkdown template file will be copied
into the output directory, and rmarkdown::render()
will be called to
generate the final report.
As a default template, happy_hour
uses the one delivered together with the
GeneTonic
package, which provides a comprehensive overview of what the user
can extract. Experienced users can take that as a starting point to further
edit and customize.
If there is already a .Rmd file with the same name in the output directory, the function will raise an error and stop, to avoid overwriting the existing file. The reason for this behaviour is that the copied template in the output directory will be deleted once the report is generated.
Credits to the original implementation proposed by Charlotte Soneson, upon which this function is heavily inspired.
Generates a fully fledged report in the output_dir
directory, called
output_file
and returns (invisibly) the name of the generated report.
GeneTonic()
, shake_topGOtableResult()
, shake_enrichResult()
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) ## Not run: happy_hour( dds = dds_macrophage, res_de = res_de, res_enrich = res_enrich, annotation_obj = anno_df, project_id = "examplerun", mygroup = "condition", # mygroup = "line", # alternatively mygenesets = res_enrich$gs_id[c(1:5, 11, 31)], mygenes = c( "ENSG00000125347", "ENSG00000172399", "ENSG00000137496" ) ) ## End(Not run)
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) ## Not run: happy_hour( dds = dds_macrophage, res_de = res_de, res_enrich = res_enrich, annotation_obj = anno_df, project_id = "examplerun", mygroup = "condition", # mygroup = "line", # alternatively mygenesets = res_enrich$gs_id[c(1:5, 11, 31)], mygenes = c( "ENSG00000125347", "ENSG00000172399", "ENSG00000137496" ) ) ## End(Not run)
Maps numeric continuous values to values in a color palette
map2color(x, pal, symmetric = TRUE, limits = NULL)
map2color(x, pal, symmetric = TRUE, limits = NULL)
x |
A character vector of numeric values (e.g. log2FoldChange values) to be converted to a vector of colors |
pal |
A vector of characters specifying the definition of colors for the
palette, e.g. obtained via |
symmetric |
Logical value, whether to return a palette which is symmetrical
with respect to the minimum and maximum values - "respecting" the zero.
Defaults to |
limits |
A vector containing the limits of the values to be mapped. If
not specified, defaults to the range of values in the |
A vector of colors, each corresponding to an element in the original vector
a <- 1:9 pal <- RColorBrewer::brewer.pal(9, "Set1") map2color(a, pal) plot(a, col = map2color(a, pal), pch = 20, cex = 4) b <- 1:50 pal2 <- grDevices::colorRampPalette( RColorBrewer::brewer.pal(name = "RdYlBu", 11) )(50) plot(b, col = map2color(b, pal2), pch = 20, cex = 3)
a <- 1:9 pal <- RColorBrewer::brewer.pal(9, "Set1") map2color(a, pal) plot(a, col = map2color(a, pal), pch = 20, cex = 4) b <- 1:50 pal2 <- grDevices::colorRampPalette( RColorBrewer::brewer.pal(name = "RdYlBu", 11) )(50) plot(b, col = map2color(b, pal2), pch = 20, cex = 3)
Calculate similarity coefficient between two sets, based on the overlap
overlap_coefficient(x, y)
overlap_coefficient(x, y)
x |
Character vector, corresponding to set 1 |
y |
Character vector, set 2 |
A numeric value between 0 and 1
https://en.wikipedia.org/wiki/Overlap_coefficient
a <- seq(1, 21, 2) b <- seq(1, 11, 2) overlap_coefficient(a, b)
a <- seq(1, 21, 2) b <- seq(1, 11, 2) overlap_coefficient(a, b)
Calculate similarity coefficient with the Jaccard Index
overlap_jaccard_index(x, y)
overlap_jaccard_index(x, y)
x |
Character vector, corresponding to set 1 |
y |
Character vector, corresponding to set 2 |
A numeric value between 0 and 1
a <- seq(1, 21, 2) b <- seq(1, 11, 2) overlap_jaccard_index(a, b)
a <- seq(1, 21, 2) b <- seq(1, 11, 2) overlap_jaccard_index(a, b)
DESeqResults
objectA sample DESeqResults
object, generated in the DESeq2
framework
This DESeqResults
object on the data from the macrophage
package
has been created comparing IFNg treated samples vs naive samples, accounting
for the different cell lines included.
Details on how this object has been created are included in the create_gt_data.R
script, included in the scripts
folder of the GeneTonic
package.
Alasoo, et al. "Shared genetic effects on chromatin and gene expression indicate a role for enhancer priming in immune response", Nature Genetics, January 2018 doi: 10.1038/s41588-018-0046-7.
Convert the output of DAVID for straightforward use in GeneTonic()
shake_davidResult(david_output_file)
shake_davidResult(david_output_file)
david_output_file |
The location of the text file output, as exported from DAVID |
A data.frame
compatible for use in GeneTonic()
as res_enrich
Other shakers:
shake_enrichResult()
,
shake_enrichrResult()
,
shake_fgseaResult()
,
shake_gprofilerResult()
,
shake_gsenrichResult()
,
shake_topGOtableResult()
david_output_file <- system.file("extdata", "david_output_chart_BPonly_ifng_vs_naive.txt", package = "GeneTonic" ) res_enrich <- shake_davidResult(david_output_file)
david_output_file <- system.file("extdata", "david_output_chart_BPonly_ifng_vs_naive.txt", package = "GeneTonic" ) res_enrich <- shake_davidResult(david_output_file)
Convert an enrichResult object for straightforward use in GeneTonic()
shake_enrichResult(obj)
shake_enrichResult(obj)
obj |
An |
This function is able to handle the output of clusterProfiler
and reactomePA
,
as they both return an object of class enrichResult
- and this in turn
contains the information required to create correctly a res_enrich
object.
A data.frame
compatible for use in GeneTonic()
as res_enrich
Other shakers:
shake_davidResult()
,
shake_enrichrResult()
,
shake_fgseaResult()
,
shake_gprofilerResult()
,
shake_gsenrichResult()
,
shake_topGOtableResult()
# dds library("macrophage") library("DESeq2") data(gse) dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive de_symbols_IFNg_vs_naive <- res_macrophage_IFNg_vs_naive[ (!(is.na(res_macrophage_IFNg_vs_naive$padj))) & (res_macrophage_IFNg_vs_naive$padj <= 0.05), "SYMBOL" ] bg_ids <- rowData(dds_macrophage)$SYMBOL[rowSums(counts(dds_macrophage)) > 0] ## Not run: library("clusterProfiler") library("org.Hs.eg.db") ego_IFNg_vs_naive <- enrichGO( gene = de_symbols_IFNg_vs_naive, universe = bg_ids, keyType = "SYMBOL", OrgDb = org.Hs.eg.db, ont = "BP", pAdjustMethod = "BH", pvalueCutoff = 0.01, qvalueCutoff = 0.05, readable = FALSE ) res_enrich <- shake_enrichResult(ego_IFNg_vs_naive) head(res_enrich) ## End(Not run)
# dds library("macrophage") library("DESeq2") data(gse) dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive de_symbols_IFNg_vs_naive <- res_macrophage_IFNg_vs_naive[ (!(is.na(res_macrophage_IFNg_vs_naive$padj))) & (res_macrophage_IFNg_vs_naive$padj <= 0.05), "SYMBOL" ] bg_ids <- rowData(dds_macrophage)$SYMBOL[rowSums(counts(dds_macrophage)) > 0] ## Not run: library("clusterProfiler") library("org.Hs.eg.db") ego_IFNg_vs_naive <- enrichGO( gene = de_symbols_IFNg_vs_naive, universe = bg_ids, keyType = "SYMBOL", OrgDb = org.Hs.eg.db, ont = "BP", pAdjustMethod = "BH", pvalueCutoff = 0.01, qvalueCutoff = 0.05, readable = FALSE ) res_enrich <- shake_enrichResult(ego_IFNg_vs_naive) head(res_enrich) ## End(Not run)
Convert the output of Enrichr for straightforward use in GeneTonic()
shake_enrichrResult(enrichr_output_file, enrichr_output = NULL)
shake_enrichrResult(enrichr_output_file, enrichr_output = NULL)
enrichr_output_file |
The location of the text file output, as exported from Enrichr |
enrichr_output |
A data.frame with the output of |
A data.frame
compatible for use in GeneTonic()
as res_enrich
Other shakers:
shake_davidResult()
,
shake_enrichResult()
,
shake_fgseaResult()
,
shake_gprofilerResult()
,
shake_gsenrichResult()
,
shake_topGOtableResult()
# library("enrichR") # dbs <- c("GO_Molecular_Function_2018", # "GO_Cellular_Component_2018", # "GO_Biological_Process_2018", # "KEGG_2019_Human", # "Reactome_2016", # "WikiPathways_2019_Human") # degenes <- (mosdef::deresult_to_df(res_macrophage_IFNg_vs_naive, FDR = 0.01)$SYMBOL) # if called directly within R... # enrichr_output_macrophage <- enrichr(degenes, dbs) # or alternatively, if downloaded from the website in tabular format enrichr_output_file <- system.file("extdata", "enrichr_tblexport_IFNg_vs_naive.txt", package = "GeneTonic" ) res_from_enrichr <- shake_enrichrResult(enrichr_output_file = enrichr_output_file) # res_from_enrichr2 <- shake_enrichrResult( # enrichr_output = enrichr_output_macrophage[["GO_Biological_Process_2018"]])
# library("enrichR") # dbs <- c("GO_Molecular_Function_2018", # "GO_Cellular_Component_2018", # "GO_Biological_Process_2018", # "KEGG_2019_Human", # "Reactome_2016", # "WikiPathways_2019_Human") # degenes <- (mosdef::deresult_to_df(res_macrophage_IFNg_vs_naive, FDR = 0.01)$SYMBOL) # if called directly within R... # enrichr_output_macrophage <- enrichr(degenes, dbs) # or alternatively, if downloaded from the website in tabular format enrichr_output_file <- system.file("extdata", "enrichr_tblexport_IFNg_vs_naive.txt", package = "GeneTonic" ) res_from_enrichr <- shake_enrichrResult(enrichr_output_file = enrichr_output_file) # res_from_enrichr2 <- shake_enrichrResult( # enrichr_output = enrichr_output_macrophage[["GO_Biological_Process_2018"]])
Convert the output of fgsea for straightforward use in GeneTonic()
shake_fgseaResult(fgsea_output)
shake_fgseaResult(fgsea_output)
fgsea_output |
A data.frame with the output of |
A data.frame
compatible for use in GeneTonic()
as res_enrich
Other shakers:
shake_davidResult()
,
shake_enrichResult()
,
shake_enrichrResult()
,
shake_gprofilerResult()
,
shake_gsenrichResult()
,
shake_topGOtableResult()
data(fgseaRes, package = "GeneTonic") res_from_fgsea <- shake_fgseaResult(fgseaRes)
data(fgseaRes, package = "GeneTonic") res_from_fgsea <- shake_fgseaResult(fgseaRes)
Convert the output of g:Profiler for straightforward use in GeneTonic()
shake_gprofilerResult(gprofiler_output_file, gprofiler_output = NULL)
shake_gprofilerResult(gprofiler_output_file, gprofiler_output = NULL)
gprofiler_output_file |
The location of the text file output, as exported from g:Profiler |
gprofiler_output |
A data.frame with the output of |
A data.frame
compatible for use in GeneTonic()
as res_enrich
Other shakers:
shake_davidResult()
,
shake_enrichResult()
,
shake_enrichrResult()
,
shake_fgseaResult()
,
shake_gsenrichResult()
,
shake_topGOtableResult()
# degenes <- (mosdef::deresult_to_df(res_macrophage_IFNg_vs_naive, FDR = 0.01)$SYMBOL) # if called directly withín R... # enrichr_output_macrophage <- enrichr(degenes, dbs) # or alternatively, if downloaded from the website in tabular format gprofiler_output_file <- system.file( "extdata", "gProfiler_hsapiens_5-25-2020_tblexport_IFNg_vs_naive.csv", package = "GeneTonic" ) res_from_gprofiler <- shake_gprofilerResult(gprofiler_output_file = gprofiler_output_file) data(gostres_macrophage, package = "GeneTonic") res_from_gprofiler_2 <- shake_gprofilerResult( gprofiler_output = gostres_macrophage$result )
# degenes <- (mosdef::deresult_to_df(res_macrophage_IFNg_vs_naive, FDR = 0.01)$SYMBOL) # if called directly withín R... # enrichr_output_macrophage <- enrichr(degenes, dbs) # or alternatively, if downloaded from the website in tabular format gprofiler_output_file <- system.file( "extdata", "gProfiler_hsapiens_5-25-2020_tblexport_IFNg_vs_naive.csv", package = "GeneTonic" ) res_from_gprofiler <- shake_gprofilerResult(gprofiler_output_file = gprofiler_output_file) data(gostres_macrophage, package = "GeneTonic") res_from_gprofiler_2 <- shake_gprofilerResult( gprofiler_output = gostres_macrophage$result )
Convert a gseaResult object for straightforward use in GeneTonic()
shake_gsenrichResult(obj)
shake_gsenrichResult(obj)
obj |
A |
This function is able to handle the output of clusterProfiler
's gseGO
and
GSEA
, as they both return an object of class gseaResult
- and this in turn
contains the information required to create correctly a res_enrich
object.
A data.frame
compatible for use in GeneTonic()
as res_enrich
Other shakers:
shake_davidResult()
,
shake_enrichResult()
,
shake_enrichrResult()
,
shake_fgseaResult()
,
shake_gprofilerResult()
,
shake_topGOtableResult()
# dds library("macrophage") library("DESeq2") data(gse) dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) # res object data(res_de_macrophage, package = "GeneTonic") sorted_genes <- sort( setNames(res_macrophage_IFNg_vs_naive$log2FoldChange, res_macrophage_IFNg_vs_naive$SYMBOL), decreasing = TRUE ) ## Not run: library("clusterProfiler") library("org.Hs.eg.db") gsego_IFNg_vs_naive <- gseGO( geneList = sorted_genes, ont = "BP", OrgDb = org.Hs.eg.db, keyType = "SYMBOL", minGSSize = 10, maxGSSize = 500, pvalueCutoff = 0.05, verbose = TRUE ) res_enrich <- shake_gsenrichResult(gsego_IFNg_vs_naive) head(res_enrich) gtl_macrophage <- GeneTonicList( dds = dds_macrophage, res_de = res_macrophage_IFNg_vs_naive, res_enrich = res_enrich, annotation_obj = anno_df ) ## End(Not run)
# dds library("macrophage") library("DESeq2") data(gse) dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) # res object data(res_de_macrophage, package = "GeneTonic") sorted_genes <- sort( setNames(res_macrophage_IFNg_vs_naive$log2FoldChange, res_macrophage_IFNg_vs_naive$SYMBOL), decreasing = TRUE ) ## Not run: library("clusterProfiler") library("org.Hs.eg.db") gsego_IFNg_vs_naive <- gseGO( geneList = sorted_genes, ont = "BP", OrgDb = org.Hs.eg.db, keyType = "SYMBOL", minGSSize = 10, maxGSSize = 500, pvalueCutoff = 0.05, verbose = TRUE ) res_enrich <- shake_gsenrichResult(gsego_IFNg_vs_naive) head(res_enrich) gtl_macrophage <- GeneTonicList( dds = dds_macrophage, res_de = res_macrophage_IFNg_vs_naive, res_enrich = res_enrich, annotation_obj = anno_df ) ## End(Not run)
Convert a topGOtableResult object for straightforward use in GeneTonic()
shake_topGOtableResult(obj, p_value_column = "p.value_elim")
shake_topGOtableResult(obj, p_value_column = "p.value_elim")
obj |
A |
p_value_column |
Character, specifying which column the p value for enrichment has to be used. Example values are "p.value_elim" or "p.value_classic" |
A data.frame
compatible for use in GeneTonic()
as res_enrich
Other shakers:
shake_davidResult()
,
shake_enrichResult()
,
shake_enrichrResult()
,
shake_fgseaResult()
,
shake_gprofilerResult()
,
shake_gsenrichResult()
# res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive)
# res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive)
Plot a volcano plot for the geneset of the provided data, with the remaining genes as shaded dots in the background of the plot.
signature_volcano( res_de, res_enrich, annotation_obj = NULL, gtl = NULL, geneset_id = NULL, genelist = NULL, FDR = 0.05, color = "#1a81c2", volcano_labels = 25, plot_title = NULL )
signature_volcano( res_de, res_enrich, annotation_obj = NULL, gtl = NULL, geneset_id = NULL, genelist = NULL, FDR = 0.05, color = "#1a81c2", volcano_labels = 25, plot_title = NULL )
res_de |
A |
res_enrich |
A |
annotation_obj |
A |
gtl |
A |
geneset_id |
Character specifying the gene set identifier to be plotted. |
genelist |
A vector of character strings, specifying the identifiers
contained in the |
FDR |
Numeric value, specifying the significance level for thresholding adjusted p-values. Defaults to 0.05. |
color |
Character string to specify color of filtered points in the plot. Defaults to #1a81c2 (shade of blue). |
volcano_labels |
Integer, maximum number of labels for the gene sets to be plotted as labels on the volcano scatter plot. Defaults to 25. |
plot_title |
Character string, to specify the title of the plot,
displayed over the volcano plot. If left to |
A plot returned by the ggplot()
function
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) signature_volcano(res_de, res_enrich, anno_df, geneset_id = res_enrich$gs_id[1] ) # alternatively chemokine_list <- c( "ENSG00000108702", "ENSG00000172156", "ENSG00000181374", "ENSG00000276409" ) signature_volcano(res_de, res_enrich, anno_df, genelist = chemokine_list )
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) signature_volcano(res_de, res_enrich, anno_df, geneset_id = res_enrich$gs_id[1] ) # alternatively chemokine_list <- c( "ENSG00000108702", "ENSG00000172156", "ENSG00000181374", "ENSG00000276409" ) signature_volcano(res_de, res_enrich, anno_df, genelist = chemokine_list )
Style DT color bars for values that diverge from 0.
styleColorBar_divergent(data, color_pos, color_neg)
styleColorBar_divergent(data, color_pos, color_neg)
data |
The numeric vector whose range will be used for scaling the table data from 0-100 before being represented as color bars. A vector of length 2 is acceptable here for specifying a range possibly wider or narrower than the range of the table data itself. |
color_pos |
The color of the bars for the positive values |
color_neg |
The color of the bars for the negative values |
This function draws background color bars behind table cells in a column, width the width of bars being proportional to the column values and the color dependent on the sign of the value.
A typical usage is for values such as log2FoldChange
for tables resulting from
differential expression analysis.
Still, the functionality of this can be quickly generalized to other cases -
see in the examples.
The code of this function is heavily inspired from styleColorBar, and borrows at full hands from an excellent post on StackOverflow - https://stackoverflow.com/questions/33521828/stylecolorbar-center-and-shift-left-right-dependent-on-sign/33524422#33524422
This function generates JavaScript and CSS code from the values specified in R, to be used in DT tables formatting.
data(res_de_macrophage, package = "GeneTonic") res_df <- mosdef::deresult_to_df(res_macrophage_IFNg_vs_naive) library("magrittr") library("DT") DT::datatable(res_df[1:50, ], options = list( pageLength = 25, columnDefs = list( list(className = "dt-center", targets = "_all") ) ) ) %>% formatRound(columns = c("log2FoldChange"), digits = 3) %>% formatStyle( "log2FoldChange", background = styleColorBar_divergent( res_df$log2FoldChange, scales::alpha("navyblue", 0.4), scales::alpha("darkred", 0.4) ), backgroundSize = "100% 90%", backgroundRepeat = "no-repeat", backgroundPosition = "center" ) simplest_df <- data.frame( a = c(rep("a", 9)), value = c(-4, -3, -2, -1, 0, 1, 2, 3, 4) ) # or with a very simple data frame DT::datatable(simplest_df) %>% formatStyle( "value", background = styleColorBar_divergent( simplest_df$value, scales::alpha("forestgreen", 0.4), scales::alpha("gold", 0.4) ), backgroundSize = "100% 90%", backgroundRepeat = "no-repeat", backgroundPosition = "center" )
data(res_de_macrophage, package = "GeneTonic") res_df <- mosdef::deresult_to_df(res_macrophage_IFNg_vs_naive) library("magrittr") library("DT") DT::datatable(res_df[1:50, ], options = list( pageLength = 25, columnDefs = list( list(className = "dt-center", targets = "_all") ) ) ) %>% formatRound(columns = c("log2FoldChange"), digits = 3) %>% formatStyle( "log2FoldChange", background = styleColorBar_divergent( res_df$log2FoldChange, scales::alpha("navyblue", 0.4), scales::alpha("darkred", 0.4) ), backgroundSize = "100% 90%", backgroundRepeat = "no-repeat", backgroundPosition = "center" ) simplest_df <- data.frame( a = c(rep("a", 9)), value = c(-4, -3, -2, -1, 0, 1, 2, 3, 4) ) # or with a very simple data frame DT::datatable(simplest_df) %>% formatStyle( "value", background = styleColorBar_divergent( simplest_df$value, scales::alpha("forestgreen", 0.4), scales::alpha("gold", 0.4) ), backgroundSize = "100% 90%", backgroundRepeat = "no-repeat", backgroundPosition = "center" )
Summarize information on the hub genes in the Gene-Geneset graph
summarize_ggs_hubgenes(g)
summarize_ggs_hubgenes(g)
g |
An |
A data.frame object, formatted for use in DT::datatable()
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) ggs <- ggs_graph( res_enrich, res_de, anno_df ) dt_df <- summarize_ggs_hubgenes(ggs) DT::datatable(dt_df, escape = FALSE)
library("macrophage") library("DESeq2") library("org.Hs.eg.db") library("AnnotationDbi") # dds object data("gse", package = "macrophage") dds_macrophage <- DESeqDataSet(gse, design = ~ line + condition) rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15) dds_macrophage <- estimateSizeFactors(dds_macrophage) # annotation object anno_df <- data.frame( gene_id = rownames(dds_macrophage), gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL" ), stringsAsFactors = FALSE, row.names = rownames(dds_macrophage) ) # res object data(res_de_macrophage, package = "GeneTonic") res_de <- res_macrophage_IFNg_vs_naive # res_enrich object data(res_enrich_macrophage, package = "GeneTonic") res_enrich <- shake_topGOtableResult(topgoDE_macrophage_IFNg_vs_naive) res_enrich <- get_aggrscores(res_enrich, res_de, anno_df) ggs <- ggs_graph( res_enrich, res_de, anno_df ) dt_df <- summarize_ggs_hubgenes(ggs) DT::datatable(dt_df, escape = FALSE)
res_enrich
objectA sample res_enrich
object, generated with the topGOtable
function (from
the pcaExplorer
package).
This res_enrich
object on the data from the macrophage
package
has been created by analyzing downstream the differentially expressed genes
when comparing IFNg treated samples vs naive samples, accounting
for the different cell lines included.
Details on how this object has been created are included in the create_gt_data.R
script, included in the scripts
folder of the GeneTonic
package.
Alasoo, et al. "Shared genetic effects on chromatin and gene expression indicate a role for enhancer priming in immune response", Nature Genetics, January 2018 doi: 10.1038/s41588-018-0046-7.
Other pathway-analysis-results:
enrichr_output_macrophage
,
gostres_macrophage