Skip to content

Commit

Permalink
Merge pull request #131 from IARCbioinfo/dev
Browse files Browse the repository at this point in the history
manage the three genotypes
  • Loading branch information
tdelhomme authored Jun 23, 2016
2 parents aeea283 + dcb848f commit 68ea621
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
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

0 comments on commit 68ea621

Please sign in to comment.