xpclr icon indicating copy to clipboard operation
xpclr copied to clipboard

add functionality to estimate genetic pos from coordinate pos given a map

Open mihuzx opened this issue 6 years ago • 1 comments

Hi hardingnj,

Thank you for your exellent work.

But I wonder if I can use the vcf file as input and use the genetic map at the same time. So that I can sliding window based on genetic map to calculate XP-CLR.

Thank you for your time.

mihuzx avatar Sep 27 '19 01:09 mihuzx

Currently- this is not possible as things stand. This functionality could certainly be added- but unsure when I can dedicate some time to it. PRs are welcome.

In the meantime- I would suggest:

  • converting your VCF to zarr format
  • taking the positions and using your map to derive a genomic positions array. Then saving the array in the same zarr archive. Then you can use the gdistkey argument.

Something like this should get you started:

import allel
import zarr

for chrom in chroms:
  allel.vcf_to_zarr("my.vcf.gz", "out.zarr", region=chrom, group=chrom, fields="*")

callset = zarr.open_group("out.zarr")
for chrom in chroms:
  pos = callset[chrom]["variants/POS"]
  genetic_pos = some_function(pos, map)
  callset[chrom]["variants"].create_dataset("genetic_position", data=genetic_pos)

hardingnj avatar Sep 27 '19 10:09 hardingnj