[英]Find genes with good correlation from a correlation matrix
我有一個矩陣文件,它基本上是跨各種細胞類型的基因之間的Spearman相關矩陣。 因此,現在我試圖找出相關值等於或大於0.6的一組基因或一組基因(如果我將其設置為閾值)。 我怎樣才能做到這一點? 我正在發布數據的一部分。 這是502 x 502的矩陣。
ACTL6B ACTR5 ACTR6
ACTL6B 1 0.6 -0.4
ACTR5 0.4 1 -0.3
ACTR6 -0.4 -0.3 1
因此,我不希望同一組基因之間的相關性為1。我想要另一個比較。 像,讓說, ACTL6B
和ACTR5
之間的相關度為0.6。 我想保留這些價值觀和基因。
這是一個例子:
mat <- cor(longley) # example 7 x 7 correlation matrix
# Find indices of correlations greater than 0.6
idx <- which(mat > 0.6 & lower.tri(mat), arr.ind = TRUE)
# names of the resulting variables
cbind(rownames(idx), colnames(mat)[idx[, 2]])
由於lower.tri
,對角線和較高矩陣中的所有值都將被忽略。
結果:
[,1] [,2]
[1,] "GNP" "GNP.deflator"
[2,] "Unemployed" "GNP.deflator"
[3,] "Population" "GNP.deflator"
[4,] "Year" "GNP.deflator"
[5,] "Employed" "GNP.deflator"
[6,] "Unemployed" "GNP"
[7,] "Population" "GNP"
[8,] "Year" "GNP"
[9,] "Employed" "GNP"
[10,] "Population" "Unemployed"
[11,] "Year" "Unemployed"
[12,] "Year" "Population"
[13,] "Employed" "Population"
[14,] "Employed" "Year"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.