Crate ggca

source ·
Expand description

§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.

§Installation

  1. Add crate to Cargo.toml: ggca = "1.0.0"

§Usage

Basic example:

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:

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 folder for more types of analysis!

Modules§

Structs§