There are many ways to go about this. Here’s something I wrote up quick and dirty. I separated out mashr into two new data-frames based upon their columns.
mashr_one <- tibble(CHROM_POS = mashr$RSID1,
Group = "RSID1")
mashr_two <- tibble(CHROM_POS = mashr$RSID2_,
Group = "RSID2")
result <- full_join(vcf, mashr_one)
result2 <- full_join(vcf, mashr_two)
Read more here: Source link