Hi everyone, I might be not really good with R but I really don't get this thing : I have a matrix of 2590 x 2590 genes (correlation matrix) with values between -1.0 and 1.0 and with a diagonal of all 1.0s , easily obtained with the following function (that returns 2590) :
sum(diag(cor.matrix))
Now when I do further analysis such as ( Fisher transformation ) I get 1640 infinite (Because of the division on zero) but this means that he only see 1640 1.0s instead of 2590, in fact if I do the following :
sum(cor.matrix==1)
It instead gets wrong telling me they are only 1640, and thats a huge problem, how is possible that I get 2590 1.0s but it sees only 1640 with another function?.
I add that with :
table(unlist(cor.matrix))
I get actually that 2572 are 1.0s and 12 are 0.99999, but still I don't get why 1640.
Please show the output of
str(cor.matrix)
. Also, how did you producecor.matrix
?cor.matrix
was generated by the functioncor(t(data))
where data has genes as rows and samples as columns. And below is the output of str(cor.matrix) :I think you should explain your "Fisher transformation", which code did you use ?
The Fisher transformation is applied after so it has nothing to do with it ( my bad I mentioned it ). My concern is why and how is possible that when I type
table(unlist(cor.matrix))
It returns me that I have 2572 "1" and 12 "0.99" (that are those in the Diagonal) and when I typesum(cor.matrix==1)
instead it gives me 1640?Give us an example subset,
dput(cor.matrix[1:10, 1:10])
, ensure this includes both 1s and 0.99s rows/cols. By the wayunlist
does nothing on matrix, matrix is not a list.Thank you for your reply , actually there are no 0.99 in the diagonal as I checked with diag(), so here is a subset of 10x10 :
Diagonal for easier visualization :
Here are instead the info about the full matrix :
sum(diag(cor.matrix))
says2590
that means that all the diagonal present the number1.000000
, so I dont get how is possible I retrive 1640 from the functionsum(cor.matrix==1)
.Please provide the output of
dput(df)
instead of printing the data frame, it is difficult to recreate your object for us otherwiseThis example data give the 10 for both, provide bigger example data where this is not true. Or upload the full file somewhere and share the link: