@@ -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
0 commit comments