Skip to content

Commit 6e960cd

Browse files
committed
rename multiomic to multilist
1 parent ee61f63 commit 6e960cd

File tree

6 files changed

+59
-42
lines changed

6 files changed

+59
-42
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[package]
44
name = "webgestalt"
5-
version = "0.1.1"
5+
version = "0.2.0"
66
authors = ["John Elizarraras"]
77
edition = "2021"
88
rust-version = "1.63.0"

src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use owo_colors::{OwoColorize, Stream::Stdout, Style};
55
use std::io::{BufReader, Write};
66
use std::{fs::File, time::Instant};
77
use webgestalt_lib::methods::gsea::GSEAConfig;
8-
use webgestalt_lib::methods::multiomics::{combine_gmts, MultiOmicsMethod, NormalizationMethod};
8+
use webgestalt_lib::methods::multilist::{combine_gmts, MultiListMethod, NormalizationMethod};
99
use webgestalt_lib::methods::ora::ORAConfig;
1010
use webgestalt_lib::readers::utils::Item;
1111
use webgestalt_lib::readers::{read_gmt_file, read_rank_file};
@@ -126,7 +126,7 @@ fn main() {
126126
"webgestalt_lib/data/ktest.gmt".to_owned(),
127127
);
128128
let start = Instant::now();
129-
let res = webgestalt_lib::methods::gsea::gsea(
129+
let _res = webgestalt_lib::methods::gsea::gsea(
130130
gene_list.unwrap(),
131131
gmt.unwrap(),
132132
GSEAConfig::default(),
@@ -280,13 +280,13 @@ fn main() {
280280
Some(NormMethods::MedianValue) => NormalizationMethod::MedianValue,
281281
None => panic!("No normalization method chosen."),
282282
};
283-
let method: MultiOmicsMethod = match ora_args.combination {
284-
Some(CombinationMethods::Mean) => MultiOmicsMethod::Mean(norm_method),
285-
Some(CombinationMethods::Max) => MultiOmicsMethod::Max(norm_method),
283+
let method: MultiListMethod = match ora_args.combination {
284+
Some(CombinationMethods::Mean) => MultiListMethod::Mean(norm_method),
285+
Some(CombinationMethods::Max) => MultiListMethod::Max(norm_method),
286286
None => panic!("No combination method chosen."),
287287
};
288288
let mut combined_list =
289-
webgestalt_lib::methods::multiomics::combine_lists(lists, method);
289+
webgestalt_lib::methods::multilist::combine_lists(lists, method);
290290
combined_list.sort_by(|a, b| b.rank.partial_cmp(&a.rank).unwrap());
291291
let mut file = File::create(ora_args.out.clone().unwrap()).unwrap();
292292
println!(

webgestalt_lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "webgestalt_lib"
3-
version = "0.1.1"
3+
version = "0.2.0"
44
authors = ["John Elizarraras"]
55
edition = "2021"
66
rust-version = "1.63.0"

webgestalt_lib/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ Library for performing different types of enrichment analyses. Serves as the und
66

77
Supported methods include:
88

9-
- Over-representation analysis (ORA)
9+
- Over-Representation Analysis (ORA)
1010
- Gene Set Enrichment Analysis (GSEA)
1111

1212
## Installation
1313

1414
To use webgestalt_lib in your Rust project, add the following line to your `Cargo.toml`.
1515

1616
```toml
17-
webgestalt_lib = "0.1.0" # change to wanted version
17+
webgestalt_lib = "0.1.1" # change to wanted version
1818
```
1919

20-
If you are just interested in running an analysis, rather than develop new tools, please use on of the packages mentioned at the beginning of the README.
20+
If you are just interested in running an analysis, rather than develop new tools, please use one of the packages mentioned at the beginning of the README.
2121

2222
## Development Priorities
2323

@@ -27,7 +27,7 @@ If you are just interested in running an analysis, rather than develop new tools
2727
3. Fast compilation times
2828
- Every package install has to build the library from scratch, so the lower number of dependencies, the better
2929

30-
This crate does not provide any data formatting, or charts to display the results of the analysis. This work has already been done by the [R package](https://github.com/bzhanglab/webgestaltr), and a limited implementation is provided by the Rust CLI. The focus for this library is purely computational.
30+
This crate does not provide any data formatting or charts to display the results of the analysis. This work has already been done by the [R package](https://github.com/bzhanglab/webgestaltr), and a limited implementation is provided by the Rust CLI. The focus for this library is purely computational.
3131

3232
## License
3333

webgestalt_lib/src/methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
pub mod gsea;
2-
pub mod multiomics;
2+
pub mod multilist;
33
pub mod ora;

webgestalt_lib/src/methods/multiomics.rs renamed to webgestalt_lib/src/methods/multilist.rs

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ use super::{
55
gsea::{GSEAConfig, GSEAResult, RankListItem},
66
ora::{get_ora, ORAConfig, ORAResult},
77
};
8-
use crate::{methods::gsea::gsea, readers::utils::Item};
8+
use crate::{
9+
methods::gsea::gsea,
10+
readers::utils::Item,
11+
stat::{adjust, AdjustmentMethod},
12+
};
913

10-
pub enum MultiOmicsMethod {
14+
pub enum MultiListMethod {
1115
/// Get the max median ratio of the analyte from any list
1216
Max(NormalizationMethod),
1317
/// Get the average median ratio of analyte from all the lists
@@ -49,7 +53,7 @@ pub enum NormalizationMethod {
4953
None,
5054
}
5155

52-
/// Run a multiomics analysis, using either the max/mean median ratio or a typical meta analysis
56+
/// Run a multilist analysis, using either the max/mean median ratio or a typical meta analysis
5357
/// method
5458
///
5559
/// # Parameters
@@ -61,8 +65,8 @@ pub enum NormalizationMethod {
6165
///
6266
/// Returns a [`Vec<Vec<FullGSEAResult>>`] containing the results of each analysis. If the method was not meta-analysis, then the outer vector will only have one element.
6367
/// If the method was meta-analysis, then the first element will be the results of the meta-analysis, and the rest of the elements will be the results of each analysis run individually.
64-
pub fn multiomic_gsea(jobs: Vec<GSEAJob>, method: MultiOmicsMethod) -> Vec<Vec<GSEAResult>> {
65-
if let MultiOmicsMethod::Meta(meta_method) = method {
68+
pub fn multilist_gsea(jobs: Vec<GSEAJob>, method: MultiListMethod) -> Vec<Vec<GSEAResult>> {
69+
if let MultiListMethod::Meta(meta_method) = method {
6670
let mut phash: AHashMap<String, Vec<f64>> = AHashMap::default();
6771
let mut results: Vec<Vec<GSEAResult>> = Vec::new();
6872
for job in jobs {
@@ -119,9 +123,24 @@ pub fn multiomic_gsea(jobs: Vec<GSEAJob>, method: MultiOmicsMethod) -> Vec<Vec<G
119123
}
120124
}
121125

122-
pub fn multiomic_ora(jobs: Vec<ORAJob>, method: MultiOmicsMethod) -> Vec<Vec<ORAResult>> {
126+
/// Perform multi-list over-representation analysis
127+
///
128+
/// # Parameters
129+
///
130+
/// - `jobs` - [`Vec<ORAJob>`] containing [`ORAJob`] for each list
131+
/// - `method` - [`MultiListMethod`] detailing how to combine the different lists (i.e. meta-analysis)
132+
/// - `fdr_method` - [`AdjustmentMethod`] of what FDR method to use to adjust p-values
133+
///
134+
/// # Panics
135+
///
136+
/// Panics if there is a arithmetic error.
137+
pub fn multilist_ora(
138+
jobs: Vec<ORAJob>,
139+
method: MultiListMethod,
140+
fdr_method: AdjustmentMethod,
141+
) -> Vec<Vec<ORAResult>> {
123142
match method {
124-
MultiOmicsMethod::Meta(meta_method) => {
143+
MultiListMethod::Meta(meta_method) => {
125144
let mut phash: AHashMap<String, Vec<f64>> = AHashMap::default();
126145
let mut results: Vec<Vec<ORAResult>> = Vec::new();
127146
for job in jobs {
@@ -133,33 +152,31 @@ pub fn multiomic_ora(jobs: Vec<ORAJob>, method: MultiOmicsMethod) -> Vec<Vec<ORA
133152
results.push(res);
134153
}
135154
let mut final_result: Vec<ORAResult> = Vec::new();
155+
let mut meta_p = Vec::new();
136156
match meta_method {
137157
MetaAnalysisMethod::Stouffer => {
138158
let normal = Normal::new(0.0, 1.0).unwrap();
139159
for set in phash.keys() {
140-
final_result.push(ORAResult {
141-
set: set.clone(),
142-
p: stouffer_with_normal(&phash[set], &normal),
143-
fdr: 0.0,
144-
overlap: 0,
145-
expected: 0.0,
146-
enrichment_ratio: 0.0,
147-
});
160+
meta_p.push(stouffer_with_normal(&phash[set], &normal))
148161
}
149162
}
150163
MetaAnalysisMethod::Fisher => {
151164
for set in phash.keys() {
152-
final_result.push(ORAResult {
153-
set: set.clone(),
154-
p: fisher(&phash[set]),
155-
fdr: 0.0,
156-
overlap: 0,
157-
expected: 0.0,
158-
enrichment_ratio: 0.0,
159-
});
165+
meta_p.push(fisher(&phash[set]));
160166
}
161167
}
162168
}
169+
let meta_fdr = adjust(&meta_p, fdr_method);
170+
for (i, set) in phash.keys().enumerate() {
171+
final_result.push(ORAResult {
172+
set: set.clone(),
173+
p: meta_p[i],
174+
fdr: meta_fdr[i],
175+
overlap: 0,
176+
expected: 0.0,
177+
enrichment_ratio: 0.0,
178+
})
179+
}
163180
results.insert(0, final_result);
164181
results
165182
}
@@ -171,12 +188,12 @@ pub fn multiomic_ora(jobs: Vec<ORAJob>, method: MultiOmicsMethod) -> Vec<Vec<ORA
171188

172189
pub fn combine_lists(
173190
lists: Vec<Vec<RankListItem>>,
174-
combination_method: MultiOmicsMethod,
191+
combination_method: MultiListMethod,
175192
) -> Vec<RankListItem> {
176193
match combination_method {
177-
MultiOmicsMethod::Max(normalization_method) => max_combine(lists, normalization_method),
178-
MultiOmicsMethod::Mean(normalization_method) => mean_combine(lists, normalization_method),
179-
MultiOmicsMethod::Meta(_) => panic!("Lists can not be combined for meta-analysis"),
194+
MultiListMethod::Max(normalization_method) => max_combine(lists, normalization_method),
195+
MultiListMethod::Mean(normalization_method) => mean_combine(lists, normalization_method),
196+
MultiListMethod::Meta(_) => panic!("Lists can not be combined for meta-analysis"),
180197
}
181198
}
182199

@@ -333,7 +350,7 @@ pub fn combine_gmts(gmts: &Vec<Vec<Item>>) -> Vec<Item> {
333350
/// # Examples
334351
///
335352
/// ```rust
336-
/// use webgestalt_lib::methods::multiomics::stouffer;
353+
/// use webgestalt_lib::methods::multilist::stouffer;
337354
/// let vals: Vec<f64> = vec![0.1, 0.01, 0.11, 0.23];
338355
/// let metap: f64 = stouffer(&vals);
339356
/// ```
@@ -363,7 +380,7 @@ pub fn fisher(vals: &Vec<f64>) -> f64 {
363380
/// # Examples
364381
///
365382
/// ```rust
366-
/// use webgestalt_lib::methods::multiomics::stouffer_weighted;
383+
/// use webgestalt_lib::methods::multilist::stouffer_weighted;
367384
/// let vals: Vec<f64> = vec![0.1, 0.01, 0.11, 0.23];
368385
/// let weights: Vec<f64> = vec![0.1, 0.2, 0.3, 0.4];
369386
/// let metap: f64 = stouffer_weighted(vals, weights);

0 commit comments

Comments
 (0)