I have a 120 by 120 correlation matrix (Correlation_mat) obtained by comparing FPKM gene expression data of 120 genes at different time-series with cor test of R. I want to visualize the correlation results in histogram and then want to filter the top 1% correlations from the matrix. Then I want to divide the top 1% correlations into cluster based on mutual correlations. Can anybody help me with the R script?
EDIT: Moved additional information provided by OP from a comment
1. I have generated correlation matrix with the below scripts
#Data import
Rdata <- read.table(file.choose(), header=TRUE, sep=",")
#Generating correlation matrix with the 'Rdata'
cor(Rdata, method="pearson")
Correlation_mat <- cor(Rdata)
2. Then I have filtered the correlations based on a cutoff correlation coefficient (r) value
#Filtering based on Correlation value
n <- ncol(Correlation_mat)
cmat <- col(Correlation_mat)
ind <- order(-cmat, Correlation_mat, decreasing = TRUE) - (n * cmat - n)
dim(ind) <- dim(Correlation_mat)
colnames(ind) <- colnames(Correlation_mat)
out <- cbind(ID = c(col(ind)), ID2 = c(ind))
as.data.frame(cbind(out, cor = Correlation_mat[out]))
Final<- as.data.frame(cbind(out, cor = Correlation_mat[out]))
f=Final
for (i in 1:81) {
for (j in 1:2){f[i,j]=row.names(Correlation_mat)[Final[i,j]] }
}
f[f[,3]>.8,]
a=f[f[,3]>.8,]
Therefore, in the file 'a' I have filtered correlation value like this
row.names ID ID2 cor
1 ENSGALG00000001744 ENSGALG00000001744 1
10 ENSGALG00000028599 ENSGALG00000028599 1
19 ENSGALG00000024138 ENSGALG00000024138 1
20 ENSGALG00000024138 Chr25_Ktn4 0.9668402
21 ENSGALG00000024138 ENSGALG00000016507 0.8607992
28 ENSGALG00000024029 ENSGALG00000024029 1
37 ENSGALG00000016507 ENSGALG00000016507 1
38 ENSGALG00000016507 ENSGALG00000024138 0.8607992
46 ENSGALG00000026609 ENSGALG00000026609 1
55 ENSGALG00000022277 ENSGALG00000022277 1
64 ENSGALG00000027059 ENSGALG00000027059 1
73 Chr25_Ktn4 Chr25_Ktn4 1
74 Chr25_Ktn4 ENSGALG00000024138 0.96684
I want to generate cluster with the above correlations. Actually my idea is pairs which are mutually correlated will be in the same cluster. Next I want to do GO enrichment analysis. Is there any suggestion for cluster generalization (visualization) and then GO enrichment analysis on the clusters
What have you tried? It unlikely that we'll just supply you with the R code if you can't demonstrate having actually made an attempt yourself.