structure(list(ref = c("A", "C", "A", "G", "C"), alt = c("T,TAA,TAAAA,TAAAAA",
"G,GC,GCCG", "T", "A G", "G"), chr = c("chr1", "chr1",
"chr1", "chr1", "chr2"), pos_s = c(2313007, 2456780, 2578901,
2689511, 18907652), pos_e = c(2313009, 2456784, 2578903, 2689513,
18907654), format = c("GT:AD", "GT:AD", "GT:AD", "GT:AD", "GT:AD"
), info = c("0/1/2/3/4:296,5,33,29,55", "0/1/2/3:376,22,13,7",
"0/1:323,24", "0/1:288,21", "0/1:3342,25")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -5L))
Here is a dataframe, in which the alt and info column contain the characters separated by different symbol, like comma, slash and colon. I want to move these characters into different rows and keep the rest columns. The difficult thing is that the info column contains a variety of data and different kinds of symbol.
Here is an example, which is the output that I expect.
structure(list(ref = c("A", "A", "A", "A", "C", "C", "C", "A",
"G", "C"), alt = c("T", "TAA", "TAAAA", "TAAAAA", "G", "GC",
"GCCG", "T", "A G", "G"), chr = c("chr1", "chr1", "chr1", "chr1",
"chr1", "chr1", "chr1", "chr1", "chr1", "chr2"), pos_s = c(2313007,
2313007, 2313007, 2313007, 2456780, 2456780, 2456780, 2578901,
2689511, 18907652), pos_e = c(2313009, 2313009, 2313009, 2313009,
2456784, 2456784, 2456784, 2578903, 2689513, 18907654), format = c("GT:AD",
"GT:AD", "GT:AD", "GT:AD", "GT:AD", "GT:AD", "GT:AD", "GT:AD",
"GT:AD", "GT:AD"), info = c("0/1:296,5", "0/2:296,33", "0/3:296,29",
"0/4:296,55", "0/1:376,22", "0/2:376,13", "0/3:376,7", "0/1:323,24",
"0/1:288,21", "0/1:3342,25")), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -10L))
I've tried multiple variations of this, but none of them seem to work. Any ideas?