diff --git a/Cargo.toml b/Cargo.toml index d6d48a2..f1acf0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [package] name = "gseapy" -version = "1.1.0" +version = "1.1.4" authors = ["Zhuoqing Fang "] description = "Gene Set Enrichment Analysis in Rust." license-file = "LICENSE.md" @@ -25,7 +25,7 @@ extension-module = ["pyo3"] [dependencies] -pyo3 = { version = "0.16.5", features = ["extension-module"], optional = true } +pyo3 = { version = "0.23.2", features = ["extension-module"], optional = true } rand = {version = "*", features = ['small_rng']} rayon = "*" csv = "*" diff --git a/src/lib.rs b/src/lib.rs index c573f65..724a795 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -141,7 +141,9 @@ fn gsea_rs( /// - nperm: number of permutation /// - threads: number of threads /// - seed: random seed +/// #[pyo3(signature)] #[pyfunction] +#[pyo3(signature = (gene_name, gene_exp, gene_sets, weight = 1.0, min_size = 5, max_size = 500, nperm = None, ctype = CorrelType::Rank, threads = 4,seed = 0))] fn ssgsea_rs( gene_name: Vec, gene_exp: Vec>, @@ -173,6 +175,39 @@ fn ssgsea_rs( } Ok(gsea) } +/// Run GSVA (Gene Set Variation Analysis) +/// +/// Compute gene set variation scores from the input gene expression data +/// +/// Parameters +/// ---------- +/// gene_name: list-like of str +/// Gene names +/// gene_expr: array-like of float +/// Gene expression data +/// gene_sets: dict-like of str : list-like of str +/// Gene sets +/// kcdf: bool +/// Use kernel density estimation +/// rnaseq: bool +/// Use RNA-seq data +/// mx_diff: bool +/// Use maximum difference between genes +/// abs_rnk: bool +/// Use absolute rank +/// tau: float +/// Weight for pathway score +/// min_size: int +/// Minimum number of genes in a gene set +/// max_size: int +/// Maximum number of genes in a gene set +/// threads: int +/// Number of threads +/// +/// Returns +/// ------- +/// GSEAResult +/// A GSEAResult object containing the GSVA results #[pyfunction] fn gsva_rs( gene_name: Vec, @@ -194,8 +229,17 @@ fn gsva_rs( Ok(gs) } +/// Python module for GSEA (Gene Set Enrichment Analysis) and ssGSEA +/// +/// This module provides four functions: +/// +/// - `gsea_rs`: performs GSEA +/// - `prerank_rs`: performs GSEA preranking +/// - `prerank2d_rs`: performs GSEA preranking with multiple input datasets +/// - `ssgsea_rs`: performs ssGSEA +/// - `gsva_rs`: performs GSVA #[pymodule] -fn gse(_py: Python<'_>, m: &PyModule) -> PyResult<()> { +fn gse(_py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> { // m.add_class::()?; m.add_class::()?; m.add_class::()?; diff --git a/src/utils.rs b/src/utils.rs index 834dd32..bece3c7 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -12,8 +12,8 @@ use rand::Rng; use std::collections::HashMap; use std::hash::Hash; -#[pyclass] -#[derive(Copy, Clone)] +#[pyclass(eq, eq_int)] +#[derive(Copy, Clone, PartialEq)] pub enum Metric { Signal2Noise = 0, AbsSignal2Noise = 1, @@ -23,8 +23,8 @@ pub enum Metric { DiffOfClasses = 5, } -#[pyclass] -#[derive(Copy, Clone)] +#[pyclass(eq, eq_int)] +#[derive(Copy, Clone, PartialEq)] pub enum CorrelType { Rank = 0, SymRank = 1,