Skip to main content

有效计算来自两个数据集的所有对之间的相关性(Pearson、Spearman 或 Kendall)和 p 值(双边)

项目描述

基因 GEM 相关分析 (GGCA)

CI

有效计算来自两个数据集的所有对之间的相关性(Pearson、Spearman 或 Kendall)和 p 值(双边)。它还支持CpG 站点 ID

重要提示:GGCA 是名为 Multiomix 的平台的核心。在官方网站上,您将能够通过友好的图形界面(以及许多额外的功能!)以快速灵活的方式使用这个库。立即前往https://multiomix.org/开始吧!

Python 派皮| 锈箱

指数

要求

您需要在系统中安装GSL >= 2.6 才能使用此库。

用法

examples两种语言的文件夹中都有一些示例。

Python

  1. 安装:pip install ggca
  2. 配置并调用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)

  1. 将板条箱添加到Cargo.tomlggca = "0.4.0"
  2. 创建分析并运行它:
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=w​​arn 添加到您的命令中,以在标准错误中产生警告。例如:

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):
    1. 首先,删除target/wheels文件夹:rm -rf ./target/wheels
    2. 造轮子:docker run --rm -v $(pwd):/io jwaresolutions/ggca-build:0.2.3 maturin build --release --skip-auditwheel --manylinux=2014
    3. 修复轮子以包含一些丢失的.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
  • 在 PyPi 中发布:
    1. 安装麻绳:pip install twine
    2. 上传:twine upload ./target/wheels/wheelhouse/*

测试

所有相关性、p 值和调整后的 p 值均取自R 编程语言和Python 语言的statsmodels包中的cor.testp.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}
}

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

内置发行版