Entering edit mode
4.2 years ago
AP
▴
80
Hello everyone,
I have a tab delimitted file like this with three columns,
FUN_004018-T1 359 GO:0016491|GO:0046872|GO:0055114
FUN_003797-T1 570 GO:0000287|GO:0030976
FUN_003797-T1 570 GO:0030976
FUN_003797-T1 570 GO:0016831
I want to arrange this file for further analysis like below:
FUN_004018-T1 359 GO:0016491
FUN_004018-T1 359 GO:0046872
FUN_004018-T1 359 GO:0055114
FUN_003797-T1 570 GO:0000287
FUN_003797-T1 570 GO:0030976
FUN_003797-T1 570 GO:0030976
FUN_003797-T1 570 GO:0016831
Could you please help on how I can achieve this. Thank you
Use awk. Split $3 by
|
and print$1 $2 $3_split[i]
for each component of $3.Please use the above outline to write code yourself.
Or use R and
tidyr::separate_rows
- that would be a lot easier. See: https://tidyr.tidyverse.org/reference/separate_rows.html