# testing the basic enriched class
library(categoryCompare2)
library(GO.db)
library(parallel)
options(mc.cores = 4)
load("test_data2.RData")
bp_annotation_obj <- new("annotation",
annotation_features = bp_annotation,
description = Term(names(bp_annotation)),
counts = sapply(bp_annotation, length),
type = "GO.BP")
c1 <- enriched_result(c1_enrichment$features,
c1_enrichment$universe,
bp_annotation_obj,
new("statistical_results",
statistic_data = c1_enrichment$enrich[c("pvalues", "odds_ratio", "counts")],
annotation_id = c1_enrichment$enrich$stat_names))
c2 <- enriched_result(c2_enrichment$features,
c2_enrichment$universe,
bp_annotation_obj,
new("statistical_results",
statistic_data = c2_enrichment$enrich[c("pvalues", "odds_ratio", "counts")],
annotation_id = c2_enrichment$enrich$stat_names))
sum(c1@statistics@statistic_data$pvalues <= 0.05)
sum(c2@statistics@statistic_data$pvalues <= 0.05)
# get 328 and 307 in C1 and C2, respectively
bp_combined <- combine_enrichments(c1 = c1, c2 = c2)
bp_sig <- get_significant_annotations(bp_combined, pvalues <= 0.05)
bp_graph <- generate_annotation_graph(bp_sig, low_cut = 10) # default graph gen
bp_sig <- get_significant_annotations(bp_combined, pvalues <= 0.05, counts >= 2) # add significant annotations
bp_graph_sig <- generate_annotation_graph(bp_sig) # generate graph from sig annotations
bp_table <- generate_table(bp_combined)
bp_table_sig <- generate_table(bp_sig)
bp_graph_sig2 <- filter_annotation_graph(bp_graph, bp_sig) # filter a previously generated annotation graph
# check that graphs generated by each method are the same
library(graph)
sig1_nodes <- sort(graph::nodes(bp_graph_sig))
sig2_nodes <- sort(graph::nodes(bp_graph_sig2))
all.equal(sig1_nodes, sig2_nodes)
sig1_edges <- graph::edges(bp_graph_sig)
sig2_edges <- graph::edges(bp_graph_sig2)
all.equal(sig1_edges[sig1_nodes], sig2_edges[sig2_nodes])
sig1_matrix <- bp_graph_sig@significant[sig1_nodes, ]
sig2_matrix <- bp_graph_sig2@significant[sig2_nodes, ]
all.equal(sig1_matrix, sig2_matrix)
# visualization
# determine the unique groups in the significant matrix and generate colors or pie charts
node_assign <- annotation_combinations(bp_graph_sig)
node_assign_pie <- assign_colors(node_assign)
node_assign_solid <- assign_colors(node_assign, type = "group")
# pass the graph and the node_assignments off to Cytoscape for visualization
# test_cy <- vis_in_cytoscape(bp_graph_sig, node_assign_pie)
# remove_edges(test_cy, 0.9)
# why not remove edges *before* passing to cytoscape to make loading faster
bp_graph_sig3 <- remove_edges(bp_graph_sig, 0.8)
node_assign_pie <- annotation_combinations(bp_graph_sig3)
node_assign_pie <- assign_colors(node_assign_pie)
test_cy2 <- vis_in_cytoscape(bp_graph_sig3, node_assign_pie, "test2")
remove_edges(test_cy2, 0.95)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.