Entering edit mode
9.0 years ago
star
▴
350
I have a table like as below. I like to replace each sample value base on comparing with third first columns and code each value with(0,1,2,3). For example, if sample value in each row = REF_REF -> 1 ; if sample value in each row = REF_ALT -> 2 ; if sample value in each row = ALT_ALT -> 3 and for 0/0 -> 0. REF_REF REF_ALT ALT_ALT sample1 sample2 sample3 A/A A/G G/G 0/0 A/G G/G T/T T/C C/C T/T T/C T/C C/C C/G G/G 0/0 C/G C/G I like to make a table like as: REF_REF REF_ALT ALT_ALT sample1 sample2 sample3 A/A A/G G/G 0 2 3 T/T T/C C/C 1 2 2 C/C C/G G/G 0 2 2
How many columns do you have? A correlation analysis between single values does not work.
Actually I have two columns but, I can get mean from those and make 1 column?
No, as already said a correlation analysis between single values does not work. I suggest that you read tutorials about the principles of correlation analysis (pearson, spearman) or learning by doing in R.
Did I miss something? Why do you refer to correlation analysis? Has the question been changed?
Yes, the OP changed the original question completely.
The way to do it is cor(t(mydataframe)). However as Jimbou correctly says, it doesn't make any sense for only one or two values.