Skip to content

BioinfOMICS/ImmiR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

ImmiR

An R package for correlation analysis with support for both standard and partial correlations using Spearman's rank method.

Overview

ImmiR provides easy-to-use functions for conducting correlation analyses in R. The package includes:

  • Normal Correlation Test: Bivariate correlation analysis between two variables
  • Partial Correlation Test: Correlation analysis while controlling for confounding variables

Both functions use Spearman's rank correlation method, making them suitable for non-parametric data and robust to outliers.

Dependencies

ImmiR requires the following packages:

  • ppcor - For partial correlation analysis
  • dplyr - For data manipulation
  • data.table - For data.table support

Functions

normal_cor_test()

Performs bivariate correlation analysis between two variables using Spearman's rank correlation.

Usage:

normal_cor_test(data, var_names)

Arguments:

  • data: A data.frame or data.table containing your variables
  • var_names: A character vector of length 2 with the names of variables to correlate

Returns: A data.frame with two columns:

  • spearman_cor: Spearman's correlation coefficient (rho)
  • spearman_pv: P-value of the correlation test

Example:

library(ImmiR)

# Create sample data
data <- data.frame(
    gene_expression = rnorm(100),
    mir_expression = rnorm(100)
)

# Perform correlation test
result <- normal_cor_test(data, c("gene_expression", "mir_expression"))
print(result)

partial_cor_test()

Performs partial correlation analysis between two variables while controlling for a third variable.

Usage:

partial_cor_test(data, var_names)

Arguments:

  • data: A data.frame or data.table containing your variables
  • var_names: A character vector of length 3:
    • First element: primary variable
    • Second element: secondary variable
    • Third element: control variable

Returns: A data.frame with two columns:

  • spearman_cor: Partial correlation coefficient
  • spearman_pv: P-value of the partial correlation test

Example:

library(ImmiR)

# Create sample data
data <- data.frame(
    gene_expression = rnorm(100),
    mir_expression = rnorm(100),
    age = rnorm(100)
)

# Perform partial correlation test controlling for age
result <- partial_cor_test(
    data, 
    c("gene_expression", "mir_expression", "age")
)
print(result)

Use Cases

Normal Correlation Analysis

Use normal_cor_test() when you want to:

  • Examine the direct relationship between two variables
  • Identify monotonic relationships in your data
  • Work with non-parametric data or data with outliers

Partial Correlation Analysis

Use partial_cor_test() when you want to:

  • Control for confounding variables
  • Examine the relationship between two variables while removing the effect of a third variable
  • Conduct more sophisticated correlation analyses in multivariate datasets

Features

  • Robust error handling: Returns NA values when computation fails
  • Missing data handling: Automatically handles missing values
  • Non-parametric method: Uses Spearman's rank correlation, suitable for non-normal distributions
  • Flexible input: Works with both data.frame and data.table objects
  • Input validation: Checks for valid inputs before computation

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages