hardingnj / xpclr

Code to compute the XP-CLR statistic to infer natural selection
MIT License
85 stars 26 forks source link

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

Open mihuzx opened 4 years ago

mihuzx commented 4 years ago

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.

hardingnj commented 4 years ago

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:

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)