From 681e974a8601a62fb411f967b0b262424155aad6 Mon Sep 17 00:00:00 2001 From: John Elizarraras Date: Tue, 31 Oct 2023 14:18:46 -0500 Subject: [PATCH] add multiomics ORA --- webgestalt_lib/src/methods/multiomics.rs | 55 +++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/webgestalt_lib/src/methods/multiomics.rs b/webgestalt_lib/src/methods/multiomics.rs index 1de5a47..208a9ca 100644 --- a/webgestalt_lib/src/methods/multiomics.rs +++ b/webgestalt_lib/src/methods/multiomics.rs @@ -3,7 +3,7 @@ use statrs::distribution::{Continuous, ContinuousCDF, Normal}; use super::{ gsea::{FullGSEAResult, GSEAConfig, RankListItem}, - ora::ORAConfig, + ora::{get_ora, ORAConfig, ORAResult}, }; use crate::{methods::gsea::gsea, readers::utils::Item}; @@ -119,6 +119,59 @@ pub fn multiomic_gsea(jobs: Vec, method: MultiOmicsMethod) -> Vec, method: MultiOmicsMethod) { + match method { + MultiOmicsMethod::Meta(meta_method) => { + let mut phash: AHashMap> = AHashMap::default(); + let mut results: Vec> = Vec::new(); + for job in jobs { + let res = get_ora( + job.interest_list, + job.reference_list, + job.gmt.to_vec(), + job.config, + ); + for row in res.iter() { + let set = row.set.clone(); + phash.entry(set).or_default().push(row.p); + } + results.push(res); + } + let mut final_result: Vec = Vec::new(); + match meta_method { + MetaAnalysisMethod::Stouffer => { + let normal = Normal::new(0.0, 1.0).unwrap(); + for set in phash.keys() { + final_result.push(ORAResult { + set: set.clone(), + p: stouffer_with_normal(&phash[set], &normal), + fdr: 0.0, + overlap: 0, + expected: 0.0, + enrichment_ratio: 0.0, + }); + } + } + MetaAnalysisMethod::Fisher => { + for set in phash.keys() { + final_result.push(ORAResult { + set: set.clone(), + p: fisher(&phash[set]), + fdr: 0.0, + overlap: 0, + expected: 0.0, + enrichment_ratio: 0.0, + }); + } + } + } + } + _ => { + panic!("Multi-Omics ORA can only be run with meta-analysis"); + } + } +} + pub fn combine_lists( lists: Vec>, combination_method: MultiOmicsMethod,