I performed pearson correlations between peptides and blood pressure. I am trying to extract/ retrieve only the significant correlations (only retrieve correlations with a p-value <0.05). I can go through the correlations manually find the significant correlations, but it would take very long since there are about 6000 correlations.
I do not know just what your data look like so I took the problem to be finding the row/column labels of matrix elements that are <= 0.05. I labeled the rows and columns with letters but you would want to use whatever works for your data. My invented matrix of p values has three values that are less then 0.05 and the code identifies their locations.
#Fake some p values
set.seed(1)
MyMat <- matrix(runif(25, min = 0, max = 0.25), nrow = 5)
dimnames(MyMat) <- list(LETTERS[1:5], LETTERS[11:15])
MyMat
#> K L M N O
#> A 0.06637717 0.22459742 0.05149364 0.12442481 0.23367631
#> B 0.09303097 0.23616882 0.04413919 0.17940463 0.05303563
#> C 0.14321334 0.16519945 0.17175571 0.24797652 0.16291844
#> D 0.22705195 0.15727851 0.09602593 0.09500879 0.03138877
#> E 0.05042048 0.01544657 0.19246035 0.19436131 0.06680517
#Make a matrix or Row Column labels
NameGrid <- expand.grid(LETTERS[1:5], LETTERS[11:15])
NameGrid$Row_Col <- paste(NameGrid$Var1, NameGrid$Var2, sep="_")
NameMat <- matrix(NameGrid$Row_Col, nrow = 5)
#Names are Row_Col
NameMat
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] "A_K" "A_L" "A_M" "A_N" "A_O"
#> [2,] "B_K" "B_L" "B_M" "B_N" "B_O"
#> [3,] "C_K" "C_L" "C_M" "C_N" "C_O"
#> [4,] "D_K" "D_L" "D_M" "D_N" "D_O"
#> [5,] "E_K" "E_L" "E_M" "E_N" "E_O"
NameMat[MyMat <= 0.05]
#> [1] "E_L" "B_M" "D_O"