Entering edit mode
9.7 years ago
writersblog02
▴
70
I want to correlate the expression of gene-setA with SetB using Pearson's correlation in R. Can someone help with the script?
Yes, but that correlated values of each row. e.g.: SetA-row1 vs SetB-row1..and so on...It did not create a matrix with each gene of set A correlation with all genes of SetB
not sure what you are trying to achieve, do you want to correlate the same gene in two conditions? one gene against all the others in the other conditions? everything against everything? how do your data look? could you post a sample of the data so we can better help you out?
e.g.:
SetA
SetB
I want to create a aXb correlation matrix
Also, What if the 2 gene sets are of unequal sizes
You can't take the correlation of a pair of samples where there is only one observation, because the two samples you are comparing have no standard deviation, and the definition of the Pearson's correlation coefficient requires the calculation of a standard deviation or distance from the mean, which has no meaning for one observation: http://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient
You need at least three observations of your two variables a and b, and both vectors usually need to be of same size to do a Pearson correlation test with
cor.test()
. You can tell the correlation test how to handleNA
values withna.action = "na.exclude"
(i.e., where you don't have a matching observation in one of the two paired samples, you exclude data from both vectors).I suggest reading about correlation and reading the relevant R documentation. What you're asking for doesn't seem to make much sense as described.
I got an error when running this function:
TriS wrote a pseudo code, which could be functional or just the guideline.
You should read a short tutorial to get yourself acquainted to the loops in R
A Tutorial on Loops in R - Usage and Alternatives
# this is the syntax for R
for(i in 1:100 ){print (i)}