Skip to content

Commit

Permalink
Add region and buffer region
Browse files Browse the repository at this point in the history
  • Loading branch information
LindoNkambule committed Jun 6, 2024
1 parent 622ad7f commit 8038eb3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gwaspy/imputation/impute5_impute.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def imputation(
vcf: hb.ResourceGroup = None,
reference_vcf: hb.ResourceGroup = None,
region: str = None,
buffer_region: str = None,
ncpu: int = 8,
memory: str = 'highmem',
storage: int = None,
Expand Down Expand Up @@ -60,6 +61,7 @@ def imputation(
--m /root/gwaspy/resources/maps/b38/{chrom}.b38.gmap.gz \
--g {vcf['vcf']} \
--r {region} \
--buffer-region {buffer_region} \
--out-gp-field \
--o {j.imputed_chunk['chunk.bcf']} \
--threads {ncpu}
Expand Down Expand Up @@ -142,17 +144,21 @@ def concatenate_imputed_chunks(
f'https://raw.githubusercontent.com/odelaneau/shapeit5/main/resources/chunks/b38/4cM/chunks_chr{i}.txt',
sep='\t', header=None,
names=['index', 'chrom', 'irg', 'org', 'col5', 'col6', 'col7', 'col8'])
imp_chunks_no_buffer = imputation_chunks['org'].tolist() # 4th column (with no buffer between chunks)
imputation_chunks = imputation_chunks[['irg', 'org']]
imp_chunks = list(imputation_chunks.itertuples(index=False, name=None))
# imp_chunks_no_buffer = imputation_chunks['org'].tolist() # 4th column (with no buffer between chunks)

# Impute genotypes
imputed_chunks = [
imputation(
b=batch,
vcf=chrom_vcf,
reference_vcf=ref_vcf,
region=imp_chunks[i][1],
buffer_region=imp_chunks[i][0],
storage=round(vcf_size + ref_size + 5)
).imputed_chunk
for i in range(len(imp_chunks_no_buffer))
for i in range(len(imp_chunks))
]

# Concatenate imputed chunks
Expand Down

0 comments on commit 8038eb3

Please sign in to comment.