1
$\begingroup$

I have gene expression datasets A and B that contain as many rows as genes and as many columns as samples. The rows in A and B represent a common set of genes measured in different tissues of the same 5 patients. My objective is to do a correlation between the set of genes in A and B to infer whether genes in both tissues are co-expressed based on the given condition or not?

Here are sample and patients IDs information with their Expression profile

Patient_ID <- as.character(quote(c(p_1, p_2,p_3, p_4, p_5)))[-1] 
SampleA <- as.character(quote(c(A_1, A_2, A_3, A_4, A_5)))[-1]
SampleB <- as.character(quote(c(B_1, B_2, B_3, B_4, B_5)))[-1]

Expression profile of the two tissues

set.seed(1)
A <- matrix(rnorm(250), nrow = 50)
set.seed(2)
B <- matrix(rnorm(250), nrow = 50)

I have tried two approaches

first approach

library(tidyverse)
rownames(A) <- paste0("g_",1:50) ## genes 
colnames(A) <- Patient_ID # patient IDs 

prefix "b." is added to every gene in Tissue B to identify that they are from tissue B.

rownames(B) <- paste0("b.g_",1:50) ## genes 
colnames(B) <- Patient_ID  ## patient IDs 

Since both have the same column IDs, I used rbind function to join the two datasets. Then I did correlation as a transposed matrix and extracted the top right bock of the matrix where I can get correlation values between Tissue A and Tissue B

bind <- Hmisc::rcorr(t(rbind(A,B)))
n = nrow(A)
final <- bind$r[1:n, (n+1):(2*n)]

Second approach

rownames(A) <- paste0("g_",1:50) ## genes 
colnames(A) <- SampleA ## Sample IDs in A

rownames(B) <- paste0("g_",1:50) ## genes in B tissue  
colnames(B) <- SampleB  ## Sample IDs in B 
bind.col <- Hmisc::rcorr(t(cbind(A,B)))
bind.col <- bind.col$r

Therefore, I would like to ask which approach is correct to determine if genes of Tissue A and Tissue B are co-expressed based on the given condition? If both are incorrect I wish to get feedback on how to proceed? Thank you!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.