Entering edit mode
9.5 years ago
MAPK
★
2.1k
Hi guys,
I have a dataframe(mydf) like this below:
mydf
chr start end REF ALT TYPE
1 chr11 163082 163082 T C snp
2 chr21 999282 999282 G A snp
3 chr16 7447514 7447514 T C snp
4 chr10 10310574 10310574 C A snp
5 chrX 13961560 13961560 C G snp
6 chr3 7590814 7590814 C T snp
7 chr3 7590811 7590811 G T snp
I have made a key from this like this:
key.genom <- paste(paste("chr",mydf[,"start"],sep=""),mydf[,"end"],mydf[,"REF"],mydf[,"ALT"],sep=":")
which gives me keys like these:
"chr163082:163082:T:C" "chr999282:999282:G:A"
now I want to search the key.genom
items in the table (lookupdf
) also matching the nucleotides in the columns and get the values for those nucleotides. I want to match the nucleotides in the column names and get the result as shown in the result below. Could you guys please help me . Thank you.
lookupdf
chr start end A C G T N = -
[1,] "chr11" "163082" "163082" NA "1" NA "17" NA NA NA
[2,] "chr21" "999282" "999282" "3" NA "24" NA NA NA NA
[3,] "chr16" "7447514" "7447514" NA "5" NA "91" NA NA NA
[4,] "chr10" "1010574" "1010574" "2" "22" NA NA NA NA NA
result:
chr11:163082:163082 T(17) C(1)
chr21:999282:999282 G(24) A(3)
Thank you so much, it works!