I have taxonomic assignment data from the metagenomic sample. How to merge data as described below?
The data >
Name Group-1 Name Group-2 Name Group-3
A 2 A 1 A 4
B 4 B 2 B 7
C 7 C 4 I 6
D 6 D 7 D 4
E 4 F 6 M 9
H 4
The output should be >
Name Group-1 Group-2 Group-3
A 2 1 4
B 4 2 7
C 7 4 0
D 6 7 4
E 4 0 0
F 0 6 0
H 0 4 0
I 0 0 6
M 0 0 9
Any python or other coding or any other tools available to convert such kind of data? (Group number may vary like 4/5/6...) Thanks in advance.
Interesting problem. I'm trying to use dplyr to solve this but it's turning to be pretty challenging.
Wouldn't full join do the trick here? (iteratively)
Yes, but you'd need to split the df into tables with 2 cols each and do an iterative full join with a manual stop. Plus, it is not a generalized solution that would work across any number of 2n cols so I'm curious if any sort of pivot can do it.