Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add multiomics ORA #10

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 54 additions & 1 deletion webgestalt_lib/src/methods/multiomics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -119,6 +119,59 @@ pub fn multiomic_gsea(jobs: Vec<GSEAJob>, method: MultiOmicsMethod) -> Vec<Vec<F
}
}

pub fn multiomics_ora(jobs: Vec<ORAJob>, method: MultiOmicsMethod) {
match method {
MultiOmicsMethod::Meta(meta_method) => {
let mut phash: AHashMap<String, Vec<f64>> = AHashMap::default();
let mut results: Vec<Vec<ORAResult>> = 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<ORAResult> = 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<Vec<RankListItem>>,
combination_method: MultiOmicsMethod,
Expand Down