Skip to content

Commit 03e949d

Browse files
committed
getting tables out of enriched_result objects
1 parent e1449fa commit 03e949d

7 files changed

Lines changed: 29470 additions & 2 deletions

File tree

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
^test_data_gen2\.R$
1414
^test_bp\.csv$
1515
^test_file2\.json$
16+
^test_small\.json$
1617
^features\.json$
1718
^cc2_results$
1819
^bp_annotations\.csv$

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: categoryCompare2
2-
Version: 0.200.5
2+
Version: 0.200.6
33
Title: Meta-Analysis of High-Throughput Experiments Using Feature
44
Annotations
55
Authors@R: c(
@@ -49,5 +49,5 @@ SystemRequirements: Cytoscape (>= 3.0) (if used for visualization of
4949
biocViews: Annotation, GO, MultipleComparison, Pathways, GeneExpression
5050
VignetteBuilder: knitr
5151
Encoding: UTF-8
52-
RoxygenNote: 7.3.2
52+
RoxygenNote: 7.3.3
5353
Config/testthat/edition: 3

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# categoryCompare2 0.200.6
2+
3+
- implements a method for getting a statistical table for a single `enriched_result`.
4+
15
# categoryCompare2 0.200.5
26

37
- fixes getting statistics from `gsea` results, and actually has a test that it works.

R/combine_enrichments.R

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,52 @@ setMethod(
612612
out_data
613613
}
614614

615+
#' extract statistics
616+
#'
617+
#' extract single set of statistics from a \code{\link{enriched_result}} object and
618+
#' create a \code{data.frame}.
619+
#'
620+
#' @param in_results the \code{\link{enriched_result}} object
621+
#' @return data.frame
622+
#' @exportMethod extract_statistics
623+
setMethod(
624+
"extract_statistics",
625+
signature = list(in_results = "enriched_result"),
626+
function(in_results) .extract_statistics_enriched_results(in_results)
627+
)
628+
629+
.extract_statistics_enriched_results <- function(in_enriched) {
630+
tmp_stats = .extract_statistics_statistical_results(in_enriched@statistics)
631+
tmp_stats$id = rownames(tmp_stats)
632+
tmp_stats$description = in_enriched@annotation@description[tmp_stats$id]
633+
if ("features" %in% slotNames(in_enriched)) {
634+
significant_features = lapply(
635+
in_enriched@annotation@annotation_features[tmp_stats$id],
636+
\(all_features) {
637+
base::intersect(all_features, in_enriched@features)
638+
}
639+
)
640+
tmp_stats$significant_features = significant_features
641+
} else if ("posfc" %in% slotNames(in_enriched)) {
642+
posfc_features = lapply(
643+
in_enriched@annotation@annotation_features[tmp_stats$id],
644+
\(all_features) {
645+
base::intersect(all_features, in_enriched@posfc)
646+
}
647+
)
648+
negfc_features = lapply(
649+
in_enriched@annotation@annotation_features[tmp_stats$id],
650+
\(all_features) {
651+
base::intersect(all_features, in_enriched@negfc)
652+
}
653+
)
654+
tmp_stats$posfc_features = posfc_features
655+
tmp_stats$negfc_features = negfc_features
656+
}
657+
658+
tmp_stats
659+
}
660+
615661
#' combined_statistics
616662
#'
617663
#' constructor function for the combined_statistics object, makes sure that
1.87 MB
Binary file not shown.

inst/extdata/test_data/bp_annotations.json

Lines changed: 29399 additions & 0 deletions
Large diffs are not rendered by default.

man/extract_statistics-enriched_result-method.Rd

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)