1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
//! # Gene GEM Correlation Analysis (GGCA)
//!
//! Computes efficiently the correlation (Pearson, Spearman or Kendall) and the p-value (two-sided) between all the pairs from two datasets. It also supports [CpG Site IDs][cpg-site].
//!
//! ## Installation
//!
//! 1. Add crate to `Cargo.toml`: `ggca = "1.0.0"`
//!
//!
//! ## Usage
//!
//! **Basic example**:
//!
//! ```ignore
//! use ggca::adjustment::AdjustmentMethod;
//! use ggca::analysis::Analysis;
//! use ggca::correlation::CorrelationMethod;
//!
//! // File's paths
//! let gene_file_path = "mrna.csv".to_string();
//! let gem_file_path = "mirna.csv".to_string();
//!
//! // Some parameters
//! let gem_contains_cpg = false;
//! let is_all_vs_all = true;
//! let keep_top_n = Some(10); // Keeps the top 10 of correlation (sorting by abs values)
//! let collect_gem_dataset = None; // Better performance. Keep small GEM files in memory
//!
//! // Creates and run an analysis
//! let analysis = Analysis {
//! gene_file_path,
//! gem_file_path,
//! gem_contains_cpg: false,
//! correlation_method: CorrelationMethod::Pearson,
//! correlation_threshold: 0.7,
//! sort_buf_size: 2_000_000,
//! adjustment_method: AdjustmentMethod::BenjaminiHochberg,
//! is_all_vs_all,
//! collect_gem_dataset,
//! keep_top_n,
//! };
//!
//! let (result, _total_combinations_count, number_of_elements_evaluated) = analysis.compute().unwrap();
//!
//! println!(
//! "Number of elements -> {} of {} combinations evaluated",
//! result.len(),
//! number_of_elements_evaluated
//! );
//!
//! for cor_p_value in result.iter() {
//! println!("{}", cor_p_value);
//! }
//! ```
//!
//! **With CpG Site IDs**:
//!
//! ```ignore
//! use ggca::adjustment::AdjustmentMethod;
//! use ggca::analysis::Analysis;
//! use ggca::correlation::CorrelationMethod;
//!
//! // Datasets's paths
//! let gene_file_path = "mrna.csv".to_string();
//! let gem_file_path = "methylation_with_cpgs.csv".to_string();
//!
//! // Some parameters
//! let gem_contains_cpg = true; // Second column in df2 contains CpG Site IDs
//! let is_all_vs_all = false; // Only matching genes
//! let keep_top_n = Some(10); // Keeps the top 10 of correlation (sorting by abs values)
//! let collect_gem_dataset = None;
//!
//! let analysis = Analysis {
//! gene_file_path,
//! gem_file_path,
//! gem_contains_cpg,
//! correlation_method: CorrelationMethod::Pearson,
//! correlation_threshold: 0.8,
//! sort_buf_size: 2_000_000,
//! adjustment_method: AdjustmentMethod::Bonferroni,
//! is_all_vs_all,
//! collect_gem_dataset,
//! keep_top_n,
//!
//! };
//!
//! let (result, _total_combinations_count, number_of_elements_evaluated) = analysis.compute().unwrap();
//!
//! println!(
//! "Number of elements -> {} of {} combinations evaluated",
//! result.len(),
//! number_of_elements_evaluated
//! );
//!
//! for cor_p_value in result.iter() {
//! println!("{}", cor_p_value);
//! }
//! ```
//!
//!
//! ## More examples
//!
//! You can check the [examples][examples-folder] folder for more types of analysis!
//!
//!
//! [cpg-site]: https://en.wikipedia.org/wiki/CpG_site
//! [examples-folder]: https://github.com/jware-solutions/ggca/tree/master/examples
use AdjustmentMethod;
use ;
use ;
use GGCAError;
use wrap_pyfunction;
use ;
use VecOfResults;
// Errors
create_exception!;
create_exception!;
// NOTE: Python has named arguments, so this linting warning can be disabled without sacrificing maintainability
/// A Python module implemented in Rust.