does it work with data frames? My output is empty...
I have three gene expression matrices, one from blood one from tumor and one from normal adjacent tissue. I would like to correlate the expression of all rows (genes) in blood and tumor. The matrices are ordered so that they contain the same samples (colnames) and same genes (rownames). What is the best way to do this in R?
My aim is to to check of some of the genes that are highly expressed in blood are also up-regulated in the tumor samples. Since I only have one data set from blood I cannot make a differentially expression analysis on blood alone.
2 answers
Quick answer, there's probably a better way without a loop:
for(i in 1:nrow(blood)){
cor(blood[i,], tumor[i,])
}
You can just correlate everything with:
m = cor(cbind(blood, tumor))
That makes a nice matrix that you could also make a heatmap out of.
I have have performed log2 cpm normalization on the two matrices before correlating them. Shoul I perform scaling as well?
Did you normalize the values before getting the log2(cpm)? log2(cpm) itself is not a robust normalization. I would suggest that you use edgeR/DESeq2/etc. to get properly normalized values to make the CPMs out of (edgeR has a cpm() function, I think).
Log in to answer this question.