Last active
April 25, 2025 15:23
-
-
Save cmdcolin/053b46493eb6066ac64e19ae43093456 to your computer and use it in GitHub Desktop.
hap-ibd to bed file (not plink bed, just normal genome track bed)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# create a bed file from hap-ibd output with columns "chr, start, end, sample_name1 hap1 sample_name2 hap2" | |
# add this config to jbrowse get(feature,'sample1')+':HP'+get(feature,'hap1')+' '+get(feature,'sample2')+':HP'+get(feature,'hap2') | |
# Process file in a fully streaming fashion and pipe directly to bgzip | |
# Combine header and data in a single stream | |
( | |
echo -e "#chr\tstart\tend\tsample1\thap1\tsample2\thap2" | |
zcat "$1" | awk -F'\t' '{print $5"\t"$6"\t"$7"\t"$1"\t"$2"\t"$3"\t"$4}' | |
) | bgzip -@8 >out.bed.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment