有效计算来自两个数据集的所有对之间的相关性(Pearson、Spearman 或 Kendall)和 p 值(双边)
项目描述
基因 GEM 相关分析 (GGCA)
有效计算来自两个数据集的所有对之间的相关性(Pearson、Spearman 或 Kendall)和 p 值(双边)。它还支持CpG 站点 ID。
重要提示:GGCA 是名为 Multiomix 的平台的核心。在官方网站上,您将能够通过友好的图形界面(以及许多额外的功能!)以快速灵活的方式使用这个库。立即前往https://multiomix.org/开始吧!
指数
要求
您需要在系统中安装GSL >= 2.6 才能使用此库。
用法
examples两种语言的文件夹中都有一些示例。
Python
- 安装:
pip install ggca - 配置并调用
correlate方法:
import ggca
# Possible Correlation methods
SPEARMAN = 1
KENDALL = 2
PEARSON = 3
# Possible P-values adjustment methods
BENJAMINI_HOCHBERG = 1
BENJAMINI_YEKUTIELI = 2
BONFERRONI = 3
mrna_file_path = "mrna.csv"
gem_file_path = "mirna.csv"
try:
(result_combinations, evaluated_combinations) = ggca.correlate(
mrna_file_path,
gem_file_path,
correlation_method=PEARSON,
correlation_threshold=0.5,
sort_buf_size=2_000_000,
adjustment_method=BENJAMINI_HOCHBERG,
all_vs_all=True,
gem_contains_cpg=False,
collect_gem_dataset=None,
keep_top_n=2 # Keeps only top 2 elements
)
print(f'Number of resulting combinations: {len(result_combinations)} of {evaluated_combinations} evaluated combinations')
for combination in result_combinations:
print(
combination.gene,
combination.gem,
combination.correlation,
combination.p_value,
combination.adjusted_p_value
)
except ggca.GGCADiffSamplesLength as ex:
print('Raised GGCADiffSamplesLength:', ex)
except ggca.GGCADiffSamples as ex:
print('Raised GGCADiffSamples:', ex)
except ggca.InvalidCorrelationMethod as ex:
print('Raised InvalidCorrelationMethod:', ex)
except ggca.InvalidAdjustmentMethod as ex:
print('Raised InvalidAdjustmentMethod:', ex)
except ggca.GGCAError as ex:
print('Raised GGCAError:', ex)
锈
- 将板条箱添加到
Cargo.toml:ggca = "0.4.0" - 创建分析并运行它:
use ggca::adjustment::AdjustmentMethod;
use ggca::analysis::Analysis;
use ggca::correlation::CorrelationMethod;
// File's paths
let df1_path = "mrna.csv";
let df2_path = "mirna.csv";
// 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
let analysis = Analysis::new_from_files(df1_path.to_string(), df2_path.to_string(), false);
let (result, number_of_elements_evaluated) = analysis.compute(
CorrelationMethod::Pearson,
0.7,
2_000_000,
AdjustmentMethod::BenjaminiHochberg,
is_all_vs_all,
collect_gem_dataset,
keep_top_n,
)?;
println!("Number of elements -> {} of {} combinations evaluated", result.len(), number_of_elements_evaluated);
for cor_p_value in result.iter() {
println!("{}", cor_p_value);
}
请注意,env_logger crate 用于在某些 mRNA/GEM 组合产生 NaN 值的情况下提供一些警告(例如,因为输入数组的标准为 0)。在这种情况下,您可以将 RUST_LOG=warn 添加到您的命令中,以在标准错误中产生警告。例如:
RUST_LOG=warn cargo test --no-default-features --tests
或者
RUST_LOG=warn cargo run --example basic --no-default-features
贡献
欢迎各种帮助!随时提交问题或 PR。下面列出了一些 TODO:
- 并行化迭代器以提高性能
- 让 Python 可以访问 Rust 枚举
- 添加对 Windows 操作系统的支持
- 添加 Rust 文档
- 添加测试
- 添加 MyPy 支持
发展
我们提供了一个 Docker 镜像来执行下面列出的所有命令:
- 为 rust 构建:cargo build [--release]
- 为 Python 构建(使用 Maturin):
- 首先,删除
target/wheels文件夹:rm -rf ./target/wheels - 造轮子:
docker run --rm -v $(pwd):/io jwaresolutions/ggca-build:0.2.3 maturin build --release --skip-auditwheel --manylinux=2014 - 修复轮子以包含一些丢失的
.so文件:docker run --rm -v $(pwd):/io jwaresolutions/ggca-build:0.2.3 ./repair-wheels.sh
- 首先,删除
- 仅用于开发:
- 由于Pyo3存在问题,要运行示例,您必须使用此命令运行:
cargo run [--release] --no-default-features --example <example> - 在 Python 中,您可以使用 Maturin 进行测试:
- Maturin 开发(在您当前的 virtualenv 中安装软件包):
maturin develop - Maturin build(只是为您当前的 Python 版本构建轮子):
maturin build --manylinux=1-unchecked
- Maturin 开发(在您当前的 virtualenv 中安装软件包):
- 由于Pyo3存在问题,要运行示例,您必须使用此命令运行:
- 在 PyPi 中发布:
- 安装麻绳:
pip install twine - 上传:
twine upload ./target/wheels/wheelhouse/*
- 安装麻绳:
测试
所有相关性、p 值和调整后的 p 值均取自R 编程语言和Python 语言的statsmodels包中的cor.test和p.adjust函数。
文件夹中的数据是通过从结肠直肠腺癌 (TCGA, Nature 2012)small_files数据集中随机抽样检索的。该数据集可以从cBioPortal 数据集页面或此直接链接下载。
所有相关结果都直接与 R-Multiomics 输出进行比较(旧版本的multiomix.org仅适用于 R 语言)。
表现
我们使用criteria.rs来执行基准测试。如果您做出了贡献,您可以检查项目中是否添加了回归。只需cargo bench --no-default-features在更改前后运行,即可对性能进行统计分析。
注意事项
如果您使用我们代码的任何部分,或者该工具本身对您的研究有用,请考虑引用:
@article{camele2022multiomix,
title={Multiomix: a cloud-based platform to infer cancer genomic and epigenomic events associated with gene expression modulation},
author={Camele, Genaro and Menazzi, Sebastian and Chanfreau, Hern{\'a}n and Marraco, Agustin and Hasperu{\'e}, Waldo and Butti, Matias D and Abba, Martin C},
journal={Bioinformatics},
volume={38},
number={3},
pages={866--868},
year={2022},
publisher={Oxford University Press}
}
项目详情
ggca -0.4.1-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | f24b2f45a5107c106b79b35b82c74d2a827a5bb1340d9d10087979af581de233 |
|
| MD5 | ef50aab9529a7205605954313ac72781 |
|
| 布莱克2-256 | 14c03265e30f289c52e78e0efdf701da6fd17fc29e8166a8f9e823e5a8f3c088 |
ggca -0.4.1-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 3308e1a6ca5003af72aaedaa547e2d280b1b0bb59b80d54ff9f51762ed268178 |
|
| MD5 | 6afd234f35b3daf106331221ca8dd5e5 |
|
| 布莱克2-256 | 5ac0e899f9d126f7fe2bebc23d92a98fb3e067b3b9c683c98d8286b0940f5373 |
ggca -0.4.1-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | f635b2dd5865f4fd05d0ce737394534ca7069e9d5b1b58b8bfe03c36600da843 |
|
| MD5 | 42f8a0017786da94a35e262ad0e59d8f |
|
| 布莱克2-256 | 4371ad9c2185ee8762a3b99ce5486b0d26c2fa55bb5684039d3e6bf795bd18f5 |
ggca -0.4.1-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 75ea26dadf6ddc5ad04944f521ddff7cb5eff77565db4f02473cd0eb95294b5f |
|
| MD5 | d303fcfa177a8a578bdbf8efd0150cbc |
|
| 布莱克2-256 | 9f3f409d112d0f143ec1bcb70c62b528508b23df3c30676acd079902c62168bc |
ggca -0.4.1-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 3537b7a8aaf13cec46d27ee521c543fdfef1cdbc3df7249319a47ff729fcebab |
|
| MD5 | 335a848451c5ea334785276b073dbd53 |
|
| 布莱克2-256 | 1116e9dfe663842096c1f447ca796f500f3caa1fc368f4a0a540dbb85c8b599d |
ggca -0.4.1-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | dc61b8a8786b8b54ce6a5b2e5b071e0f282878a14dd0d373bf2c40d6d4871d17 |
|
| MD5 | 981f74c7d74a34d9299475fa21c31fda |
|
| 布莱克2-256 | bc0eecebb95bd7809eb25ba523e1257531d8f3232f15dd1ec9a40741fe4bb40b |