Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
shashank-KU committed Mar 6, 2023
0 parents commit 1850598
Show file tree
Hide file tree
Showing 22 changed files with 490 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
^OmicsIntegrator\.Rproj$
^\.Rproj\.user$
^data-raw$
^LICENSE\.md$
^CODE_OF_CONDUCT\.md$
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.Rproj.user
inst/doc
.Rhistory
.Rdata
.httr-oauth
.DS_Store
126 changes: 126 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at [email protected].
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of
actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the
community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
<https://www.contributor-covenant.org/version/2/1/code_of_conduct.html>.

Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][https://github.com/mozilla/inclusion].

For answers to common questions about this code of conduct, see the FAQ at
<https://www.contributor-covenant.org/faq>. Translations are available at <https://www.contributor-covenant.org/translations>.

[homepage]: https://www.contributor-covenant.org
29 changes: 29 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Package: OmicsIntegrator
Title: Calculate correlation between two data frame
Version: 0.1
Authors@R:
person("Shashank", "Gupta", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-8839-7003"))
Description: This function takes in two data frames df1 and df2, and calculates the correlation matrix between the columns of both data frames. The user can specify the correlation method to be used by passing the method parameter. By default, the function uses Pearson correlation.
The function calculates the p-values for the correlation tests and adjusts them for multiple testing using the specified adjustment method (default method is False Discovery Rate adjustment). The function returns a list of the correlation results including the correlation matrix, the p-value matrix, the adjusted p-value matrix, and the significance matrix indicating the significance level of the correlations.
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
Suggests:
knitr,
rmarkdown,
testthat (>= 3.0.0)
VignetteBuilder: knitr
Imports:
cowplot,
dplyr,
ggplot2,
magrittr,
pheatmap,
RColorBrewer,
WGCNA
Depends:
R (>= 2.10)
LazyData: true
Config/testthat/edition: 3
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2023
COPYRIGHT HOLDER: OmicsIntegrator authors
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2023 OmicsIntegrator authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Generated by roxygen2: do not edit by hand

export(calculate_correlations)
22 changes: 22 additions & 0 deletions OmicsIntegrator.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Version: 1.0

RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
LineEndingConversion: Posix

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
6 changes: 6 additions & 0 deletions R/OmicsIntegrator-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#' @keywords internal
"_PACKAGE"

## usethis namespace: start
## usethis namespace: end
NULL
67 changes: 67 additions & 0 deletions R/calculate_correlations.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#' Calculate correlation between two data frames
#'
#' @description
#' This function calculates the correlation matrix between the columns of two data frames.
#'
#' @param df1 A data frame containing the first set of variables to be correlated. The samples should be in the rows and the MEs in the columns.
#' @param df2 A data frame containing the second set of variables to be correlated. The samples should be in the rows and the MEs in the columns.
#' @param method (optional) The correlation method to be used. Default is "pearson".
#' @param adjust_method (optional) The method for adjusting the p-values for multiple testing. Default is "fdr".
#'
#' @return A list containing the correlation results
#' @return$correlation Matrix of correlation coefficients.
#' @return$p_value Matrix of p-values for the correlation coefficients.
#' @return$p_value_adj Matrix of adjusted p-values for the correlation coefficients.
#' @return$signif_matrix Matrix indicating the significance level of the correlations.
#'
#' @examples
#' # Calculate correlation between two data frames using default parameters
#' result_list <- calculate_correlations(df1 = transcriptomics_data, df2 = metagenomics_data)
#'
#' # Calculate correlation between two data frames using Kendall correlation and Bonferroni adjustment
#' result_list <- calculate_correlations(df1, df2, method = "kendall", adjust_method = "bonferroni")
#'
#' @export
calculate_correlations <- function(df1, df2, method="pearson", adjust_method="fdr") {
# Calculate correlation matrix
cor_mat <- cor(df1, df2, method=method)

# Calculate p-values and adjust for multiple testing
p_val_mat <- matrix(ncol=ncol(df2), nrow=ncol(df1),
dimnames=list(colnames(df1), colnames(df2)))
corr_val_mat <- p_val_mat

for (i in 1:ncol(df1)) {
for (j in 1:ncol(df2)) {
cor_res <- cor.test(df1[,i], df2[,j], method=method)
p_val_mat[i,j] <- cor_res$p.value
corr_val_mat[i,j] <- cor_res$estimate
}
}

p_val_adj_mat <- p.adjust(p_val_mat, method=adjust_method)

# Add significance level.
# One star means a p-value of less than 0.05;
# Two stars is less than 0.01, and three, is less than 0.001.
signif_matrix <- rep("", length(p_val_mat))
three_star <- which(p_val_mat <= 0.001)
signif_matrix[three_star] <- "***"
two_star <- which((p_val_mat <= 0.01) & (p_val_mat > 0.001))
signif_matrix[two_star] <- "**"
one_star <- which((p_val_mat <= 0.05) & (p_val_mat > 0.01))
signif_matrix[one_star] <- "*"
dim(signif_matrix) <- dim(p_val_mat) # Give textMatrix the correct dimensions

# Collect all results into a list
results <- list(p_value=p_val_mat,
p_value_adj=p_val_adj_mat,
signif_matrix=signif_matrix,
correlation=corr_val_mat)

return(results)
}




Loading

0 comments on commit 1850598

Please sign in to comment.