replace value of each rows with value of column?
0
0
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
R statistic • 2.4k views
ADD COMMENT
0
Entering edit mode

How many columns do you have? A correlation analysis between single values does not work.

ADD REPLY
0
Entering edit mode

Actually I have two columns but, I can get mean from those and make 1 column?

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

Did I miss something? Why do you refer to correlation analysis? Has the question been changed?

ADD REPLY
0
Entering edit mode

Yes, the OP changed the original question completely.

ADD REPLY
0
Entering edit mode

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.

ADD REPLY

Login before adding your answer.

Traffic: 1619 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6