Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IntegrateGQ.sh errors due to presence of variants of just one type #760

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 51 additions & 33 deletions src/sv-pipeline/04_variant_resolution/scripts/IntegrateGQ.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,41 +30,60 @@ zcat $RD_melted_genotypes \
|gzip \
>rd_indiv_geno.txt.gz

##Deletions, need to PE-SR genotypes to match RD format (2==ref)##
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should keep this comment in and the one about duplications below

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated accordingly.

##PE##
zcat $pegeno_indiv_file \
| { fgrep -wf <(awk '{if ($5=="DEL") print $4}' int.bed) || true; } \
|awk '{if ($4>1) print $1"@"$2,$1,$2,$4,0,$5;else if ($4==1) print $1"@"$2,$1,$2,$4,1,$5 ;else print $1"@"$2,$1,$2,$4,2,$5}' OFS='\t' \
|awk '!seen[$1"@"$2]++' \
>pe_indiv_geno.txt

##Duplications and other events, need to PE-SR genotypes to match RD (2==ref)##
zcat $pegeno_indiv_file \
| { fgrep -wf <(awk '{if ($5!="DEL") print $4}' int.bed) || true; } \
|awk '{if ($4>0) print $1"@"$2,$1,$2,$4,$4+2,$5 ;else print $1"@"$2,$1,$2,$4,2,$5}' OFS='\t' \
|awk '!seen[$1"@"$2]++' \
>>pe_indiv_geno.txt
sort -k1,1 pe_indiv_geno.txt|gzip>pe_indiv_geno.txt.gz

rm pe_indiv_geno.txt
zcat "$pegeno_indiv_file" | \
awk -v OFS="\t" '
ARGIND==1 {
if ($5 == "DEL") {
del[$4]
} else {
nodel[$4]
}
next
}
ARGIND==2 {
if ($1 in del) {
##Deletions, need to PE-SR genotypes to match RD format (2==ref)##
final_gt = ($4>1 ? 0 : ($4==1 ? 1 : 2))
print $1"@"$2, $1, $2, $4, final_gt, $5
} else if ($1 in nodel) {
##Duplications and other events, need to PE-SR genotypes to match RD (2==ref)##
final_gt = ($4>0 ? $4+2 : 2)
print $1"@"$2, $1, $2, $4, final_gt, $5
}
}
' int.bed - \
| awk '!seen[$1]++' \
| sort -k1,1 \
| gzip > pe_indiv_geno.txt.gz

##SR##
zcat $srgeno_indiv_file \
| { fgrep -wf <(awk '{if ($5=="DEL") print $4}' int.bed) || true; } \
|awk '{if ($4>1) print $1"@"$2,$1,$2,$4,0,$5;else if ($4==1) print $1"@"$2,$1,$2,$4,1,$5 ;else print $1"@"$2,$1,$2,$4,2,$5}' OFS='\t' \
|awk '!seen[$1"@"$2]++' \
>sr_indiv_geno.txt

##Duplications and other events, need to PE-SR genotysrs to match RD (2==ref)##
zcat $srgeno_indiv_file \
| { fgrep -wf <(awk '{if ($5!="DEL") print $4}' int.bed) || true; } \
|awk '{if ($4>0) print $1"@"$2,$1,$2,$4,$4+2,$5 ;else print $1"@"$2,$1,$2,$4,2,$5}' OFS='\t' \
|awk '!seen[$1"@"$2]++' \
>>sr_indiv_geno.txt

sort -k1,1 sr_indiv_geno.txt|gzip>sr_indiv_geno.txt.gz

rm sr_indiv_geno.txt
zcat "$srgeno_indiv_file" | \
awk -v OFS="\t" '
ARGIND==1 {
if ($5 == "DEL") {
del[$4]
} else {
nodel[$4]
}
next
}
ARGIND==2 {
if ($1 in del) {
##Deletions, need to PE-SR genotypes to match RD format (2==ref)##
final_gt = ($4>1 ? 0 : ($4==1 ? 1 : 2))
print $1"@"$2, $1, $2, $4, final_gt, $5
} else if ($1 in nodel) {
##Duplications and other events, need to PE-SR genotysrs to match RD (2==ref)##
final_gt = ($4>0 ? $4+2 : 2)
print $1"@"$2, $1, $2, $4, final_gt, $5
}
}
' int.bed - \
| awk '!seen[$1]++' \
| sort -k1,1 \
| gzip > sr_indiv_geno.txt.gz


##check to make sure PE and SR are same size which they should be##

Expand Down Expand Up @@ -377,4 +396,3 @@ cat genotype.variant.txt \
|awk '{if ($2==0) $2=1;if ($3==0) $3=1; if ($4==0) $4=1; if ($5==0) $5=1; print}' OFS="\t" \
|gzip \
>genotype.variant.txt.gz