vcfR icon indicating copy to clipboard operation
vcfR copied to clipboard

plans for helper functions?

Open romunov opened this issue 6 years ago • 3 comments

Are there any plans for getting/setting of META, INFO and FORMAT (sub)fields?

Use cases:

  • [ ] extract AF field from INFO
  • [ ] add genotype to FORMAT field
  • [ ] add AF to a fresh or already existing FORMAT field
  • [ ] add meta field for .e.g. FORMAT:AF

Helper functions would be beneficial because some extra checking could be implemented to avoid potential breaking of VCF file definitions.

romunov avatar Sep 11 '18 19:09 romunov

Hi Roman,

For your first bullet we have the following.

library(vcfR)
data("vcfR_test")
extract.info(vcfR_test, element = "AF")

In regards to adding the GT, my understanding of the specification is that if there is anything in the GT section it must include GT. So if you're adding GT I would think that the gt slot is empty.

I do not have anything or any plans for the last two. Although, the meta slot is simply a vector. But I can see an argument in creating helper functions to provide some checking. And that goes for your first two as well.

Are you offering to put together a PR? Or shall we just leave this open until I or someone else gets to it?

Thanks!

knausb avatar Sep 11 '18 21:09 knausb

For manipulating the gt slot I've also created this.

https://knausb.github.io/vcfR_documentation/dip_to_hap.html

Which, again, an argument could be made that I'm asking a bit from the user.

knausb avatar Sep 11 '18 21:09 knausb

Those extract functions are indeed handy. Thank you for pointing them out. I'll think about how to best implement this and get back in a while.

romunov avatar Sep 12 '18 06:09 romunov