[R] comparing and changing(swaping) the value of columns from two diffrent data farmes
anteneh asmare
h@n@tezer@ @end|ng |rom gm@||@com
Sun Jun 12 16:07:37 CEST 2022
I have the following two data frames
Data frame 1
"SNPID" "OA" "EA"
"snp001" "C" "A"
"snp002" "G" "A"
"snp003" "C" "A"
"snp004" "G" "A"
"snp005" "C" "T"
Data frame 2
SNPID OA EA id00001 id00002 id00003 id00004 id00005
snp001 A C 1.01 2 0.97
1.97 1.99
snp002 A G 1.02 2 1
2 2
snp003 C A 1 1.03 2
0 1
snp004 A G 1.02 1.99 2
1.02 1.98
snp005 C T 1 0 1.01
1 1
I want to if OA s and EAs in data frame 2 is the same as OAs and EAs
data frame 1 in such case I want to keep all information in data
fram2 as it is . However if OA s and EAs in data frame 2 is
different from OAs and EAs data frame 1, I want to change OA s and
EAs in data frame 2 to OAs and EAs data frame 1 and I want to
redefine the values of the dosages (ids) of the variant (the dosage d
for the i-th individual and the j-th variant would become d_ij
new=2-dij.
Dosage [j,]=2-dosage[j,]
My desire data frame looks like
Dataframe new
SNPID" "OA" "EA" id00001 id00002 id00003 id00004 id00005
"snp001" "C" "A" 2-1.01 2- 2 2- 0.97 2-1.97
2-1.99
"snp002" "G" "A" 2- 1.02 2- 2 2-1
2-2 2- 2
"snp003" "C" "A" 1 1.03 2
0 1
"snp004" "G" "A" 2-1.02 2-1.99
2-2 2-1.02 2-1.98
"snp005" "C" "T" 1 0
1.01 1 1
Dose any one can help me the r code for the above.
Kind regards,
Hana
More information about the R-help
mailing list