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

Manage the three possible genotypes in vcf #131

Merged
merged 2 commits into from
Jun 23, 2016
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Change Log

## [v1.0](https://github.com/IARCbioinfo/needlestack/tree/v1.0) (2016-06-03)
## [v1.0](https://github.com/IARCbioinfo/needlestack/tree/v1.0) (2016-06-23)
[Full Changelog](https://github.com/IARCbioinfo/needlestack/compare/v0.3...v1.0)

**Implemented enhancements:**
Expand Down
20 changes: 13 additions & 7 deletions bin/needlestack.r
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ plot_rob_nb <- function(rob_nb_res,qthreshold=0.01,plot_title=NULL,sbs,SB_thresh
qlevels = c(10,30,50,70,100)
# following function returns a qvalue for a new point by adding it in the set of observations, recomputing all qvalues and taking its corresponding value.
toQvalue <- function(x,y){
unlist(-10*log10(p.adjust((dnbinom(c(rob_nb_res$ma_count,y),size=1/rob_nb_res$coef[[1]],mu=rob_nb_res$coef[[2]]*c(rob_nb_res$coverage,x)) +
unlist(-10*log10(p.adjust((dnbinom(c(rob_nb_res$ma_count,y),size=1/rob_nb_res$coef[[1]],mu=rob_nb_res$coef[[2]]*c(rob_nb_res$coverage,x)) +
pnbinom(c(rob_nb_res$ma_count,y),size=1/rob_nb_res$coef[[1]],mu=rob_nb_res$coef[[2]]*c(rob_nb_res$coverage,x),lower.tail = F)),method="BH")
[length(rob_nb_res$coverage)+1]))
}
Expand Down Expand Up @@ -574,8 +574,10 @@ for (i in 1:npos) {
cat("\t","GT:QVAL:DP:RO:AO:AF:SB:SOR:RVSB",sep = "",file=out_file,append=T)
# all samples
genotype=rep("0/0",l=nindiv)
variants=which(reg_res$GQ>=GQ_threshold & sbs<=SB_threshold_SNV)
genotype[variants]="0/1"
heterozygotes=which(reg_res$GQ>=GQ_threshold & sbs<=SB_threshold_SNV & reg_res$ma_count/reg_res$coverage < 0.75)
genotype[heterozygotes]="0/1"
homozygotes=which(reg_res$GQ>=GQ_threshold & sbs<=SB_threshold_SNV & reg_res$ma_count/reg_res$coverage >= 0.75)
genotype[homozygotes]="1/1"
for (cur_sample in 1:nindiv) {
cat("\t",genotype[cur_sample],":",reg_res$GQ[cur_sample],":",DP[cur_sample],":",(Rp+Rm)[cur_sample],":",ma_count[cur_sample],":",(ma_count/DP)[cur_sample],":",Rp[cur_sample],",",Rm[cur_sample],",",Vp[cur_sample],",",Vm[cur_sample],":",sors[cur_sample],":",rvsbs[cur_sample],sep = "",file=out_file,append=T)
}
Expand Down Expand Up @@ -631,8 +633,10 @@ for (i in 1:npos) {
cat("\t","GT:QVAL:DP:RO:AO:AF:SB:SOR:RVSB",sep = "",file=out_file,append=T)
# all samples
genotype=rep("0/0",l=nindiv)
variants=which(reg_res$GQ>=GQ_threshold & sbs<=SB_threshold_indel)
genotype[variants]="0/1"
heterozygotes=which(reg_res$GQ>=GQ_threshold & sbs<=SB_threshold_indel & reg_res$ma_count/reg_res$coverage < 0.75)
genotype[heterozygotes]="0/1"
homozygotes=which(reg_res$GQ>=GQ_threshold & sbs<=SB_threshold_indel & reg_res$ma_count/reg_res$coverage >= 0.75)
genotype[homozygotes]="1/1"
for (cur_sample in 1:nindiv) {
cat("\t",genotype[cur_sample],":",reg_res$GQ[cur_sample],":",DP[cur_sample],":",(Rp+Rm)[cur_sample],":",ma_count[cur_sample],":",(ma_count/DP)[cur_sample],":",Rp[cur_sample],",",Rm[cur_sample],",",Vp[cur_sample],",",Vm[cur_sample],":",sors[cur_sample],":",rvsbs[cur_sample],sep = "",file=out_file,append=T)
}
Expand Down Expand Up @@ -689,8 +693,10 @@ for (i in 1:npos) {
cat("\t","GT:QVAL:DP:RO:AO:AF:SB:SOR:RVSB",sep = "",file=out_file,append=T)
# all samples
genotype=rep("0/0",l=nindiv)
variants=which(reg_res$GQ>=GQ_threshold & sbs<=SB_threshold_indel)
genotype[variants]="0/1"
heterozygotes=which(reg_res$GQ>=GQ_threshold & sbs<=SB_threshold_indel & reg_res$ma_count/reg_res$coverage < 0.75)
genotype[heterozygotes]="0/1"
homozygotes=which(reg_res$GQ>=GQ_threshold & sbs<=SB_threshold_indel & reg_res$ma_count/reg_res$coverage >= 0.75)
genotype[homozygotes]="1/1"
for (cur_sample in 1:nindiv) {
cat("\t",genotype[cur_sample],":",reg_res$GQ[cur_sample],":",DP[cur_sample],":",(Rp+Rm)[cur_sample],":",ma_count[cur_sample],":",(ma_count/DP)[cur_sample],":",Rp[cur_sample],",",Rm[cur_sample],",",Vp[cur_sample],",",Vm[cur_sample],":",sors[cur_sample],":",rvsbs[cur_sample],sep = "",file=out_file,append=T)
}
Expand Down