Entering edit mode
Dren Scott
▴
10
@dren-scott-1208
Last seen 10.2 years ago
Hi All,
I was trying to calculate the pearson correlation (and p-value) for a
gene dataset ( 6000 rows x 10 columns). For each row vector, I wanted
to calculate the p-value with respect to the other row vectors. My
resulting p-value matrix should be of size 6000 x 6000.
I tried the iterative approach:
for(i in 1:nrow(data)){
for(j in i:nrow(data)){
p_value <- cor.test(data[i,],data[j,])$p.value
pmatrix[j,i] <- pmatrix[i,j] <- p_value
}
}
But this will take too long for nrow(data) = 6000. Is there some
method by which I can pass the matrix into a function to get the
p-values? The dataset would also have some/many NA's.
thanks,
Dren
---------------------------------
[[alternative HTML version deleted]]