Skip to content

Commit

Permalink
Merge pull request #389 from ANGSD/mcall
Browse files Browse the repository at this point in the history
Merging the multiallelic caller. This is for internal testing and comparison and is not finalized yet.
  • Loading branch information
ANGSD authored Mar 31, 2021
2 parents fe3546f + 2f43516 commit ee80e6e
Show file tree
Hide file tree
Showing 20 changed files with 813 additions and 53 deletions.
28 changes: 15 additions & 13 deletions abc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "abcPSMC.h"
#include "abcScounts.h"
#include "abcWriteBcf.h"
#include "abcMcall.h"
//below we set some variables that are shared between all the analysis classes
#define MAX_CLASS 35

Expand All @@ -54,33 +55,34 @@ abc **extra(int &nItem,const char *outfiles,int inputtype,argStruct *arguments){
tskStuff[nit++] = new abcCounts(outfiles,arguments,inputtype);//2
tskStuff[nit++] = new abcError(outfiles,arguments,inputtype);//3
tskStuff[nit++] = new abcGL(outfiles,arguments,inputtype);//4
tskStuff[nit++] = new abcMajorMinor(outfiles,arguments,inputtype);//5
tskStuff[nit++] = new abcFreq(outfiles,arguments,inputtype);//6
tskStuff[nit++] = new abcAsso(outfiles,arguments,inputtype);//7
tskStuff[nit++] = new abcHWE(outfiles,arguments,inputtype); // 8
tskStuff[nit++] = new abcAncError(outfiles,arguments,inputtype);//9
tskStuff[nit++] = new abcCallGenotypes(outfiles,arguments,inputtype);//10
tskStuff[nit++] = new abcMcall(outfiles,arguments,inputtype);//5
tskStuff[nit++] = new abcMajorMinor(outfiles,arguments,inputtype);//6
tskStuff[nit++] = new abcFreq(outfiles,arguments,inputtype);//7
tskStuff[nit++] = new abcAsso(outfiles,arguments,inputtype);//8
tskStuff[nit++] = new abcHWE(outfiles,arguments,inputtype); // 9
tskStuff[nit++] = new abcAncError(outfiles,arguments,inputtype);//10
tskStuff[nit++] = new abcCallGenotypes(outfiles,arguments,inputtype);//11
tskStuff[nit++] = new abcSaf(outfiles,arguments,inputtype);
tskStuff[nit++] = new abcCovar(outfiles,arguments);
tskStuff[nit++] = new abcTsk(outfiles,arguments,inputtype);
tskStuff[nit++] = new abcFilterSNP(outfiles,arguments,inputtype);//14
tskStuff[nit++] = new abcFilterSNP(outfiles,arguments,inputtype);//15
tskStuff[nit++] = new abcSnpTools(outfiles,arguments,inputtype);
tskStuff[nit++] = new abcHetPlas(outfiles,arguments,inputtype);
tskStuff[nit++] = new abcWritePlink(outfiles,arguments,inputtype);
tskStuff[nit++] = new abcDstat(outfiles,arguments,inputtype);//18
tskStuff[nit++] = new abcDstat(outfiles,arguments,inputtype);//19
tskStuff[nit++] = new abcWriteFasta(outfiles,arguments,inputtype);
tskStuff[nit++] = new abcSmartCounts(outfiles,arguments,inputtype);
tskStuff[nit++] = new abcTemplate(outfiles,arguments,inputtype);
tskStuff[nit++] = new abcWriteVcf(outfiles,arguments,inputtype);//22
tskStuff[nit++] = new abcWriteVcf(outfiles,arguments,inputtype);//23
tskStuff[nit++] = new abcHaploCall(outfiles,arguments,inputtype);
tskStuff[nit++] = new abcDstat2(outfiles,arguments,inputtype);
tskStuff[nit++] = new abcHWE_F(outfiles,arguments,inputtype); // 25
tskStuff[nit++] = new abcHWE_F(outfiles,arguments,inputtype); // 26
tskStuff[nit++] = new abcIBS(outfiles,arguments,inputtype); //
tskStuff[nit++] = new abcPSMC(outfiles,arguments,inputtype); //
tskStuff[nit++] = new abcScounts(outfiles,arguments,inputtype); //
tskStuff[nit++] = new abcWriteBcf(outfiles,arguments,inputtype); // 29
tskStuff[nit++] = new abcRAD(outfiles,arguments,inputtype); // 30

tskStuff[nit++] = new abcWriteBcf(outfiles,arguments,inputtype); // 30
tskStuff[nit++] = new abcRAD(outfiles,arguments,inputtype); // 31
//remember to update changeChr in shared.cpp if order gets changed
nItem = nit;
return tskStuff;
}
12 changes: 6 additions & 6 deletions abcAsso.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ void abcAsso::scoreAsso(funkyPars *pars,assoStruct *assoc){
for(int i=0 ; i<pars->nInd ;i++)
y[i]=ymat.matrix[i][yi];

freqStruct *freq = (freqStruct *) pars->extras[6];
freqStruct *freq = (freqStruct *) pars->extras[7];
stat[yi][s]=doAssociation(pars,pars->post[s],y,keepInd[yi][s],keepList,freq->freq[s],s,assoc);

//cleanup
Expand Down Expand Up @@ -1239,7 +1239,7 @@ void abcAsso::dosageAsso(funkyPars *pars,assoStruct *assoc){
for(int i=0 ; i<pars->nInd ;i++)
y[i]=ymat.matrix[i][yi];

freqStruct *freq = (freqStruct *) pars->extras[6];
freqStruct *freq = (freqStruct *) pars->extras[7];

stat[yi][s]=dosageAssoc(pars,&design,&designNull,pars->post[s],y,keepInd[yi][s],keepList,freq->freq[s],s,assoc,model,isBinary,isCount,start,1);

Expand Down Expand Up @@ -2259,7 +2259,7 @@ void abcAsso::emAsso(funkyPars *pars,assoStruct *assoc){
for(int i=0 ; i<pars->nInd ;i++)
y[i]=ymat.matrix[i][yi];

freqStruct *freq = (freqStruct *) pars->extras[6];
freqStruct *freq = (freqStruct *) pars->extras[7];

stat[yi][s]=doEMasso(pars,&design,&designNull,&postAll,pars->post[s],y,keepInd[yi][s],keepList,freq->freq[s],s,assoc,model,isBinary,isCount,start,1);

Expand Down Expand Up @@ -2560,7 +2560,7 @@ void abcAsso::emAssoWald(funkyPars *pars,assoStruct *assoc){
for(int i=0 ; i<pars->nInd ;i++)
y[i]=ymat.matrix[i][yi];

freqStruct *freq = (freqStruct *) pars->extras[6];
freqStruct *freq = (freqStruct *) pars->extras[7];

tmp=doEMassoWald(pars,&design,&postAll,pars->post[s],y,keepInd[yi][s],keepList,freq->freq[s],s,assoc,model,isBinary,isCount,start,1);
//if not enough, WT, HE or HO or ind to run test
Expand Down Expand Up @@ -2675,7 +2675,7 @@ void abcAsso::hybridAsso(funkyPars *pars,assoStruct *assoc){
for(int i=0 ; i<pars->nInd ;i++)
y[i]=ymat.matrix[i][yi];

freqStruct *freq = (freqStruct *) pars->extras[6];
freqStruct *freq = (freqStruct *) pars->extras[7];
stat[yi][s]=doAssociation(pars,pars->post[s],y,keepInd[yi][s],keepList,freq->freq[s],s,assoc);

// cutoff has been changed to p-value
Expand Down Expand Up @@ -3589,7 +3589,7 @@ void abcAsso::printDoAsso(funkyPars *pars){
if(doPrint)
fprintf(stderr,"staring [%s]\t[%s]\n",__FILE__,__FUNCTION__);

freqStruct *freq = (freqStruct *) pars->extras[6];
freqStruct *freq = (freqStruct *) pars->extras[7];
assoStruct *assoc= (assoStruct *) pars->extras[index];

//chisq distribution with df=1
Expand Down
2 changes: 1 addition & 1 deletion abcCovar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void abcCovar::run(funkyPars *pars){
for(int s=0;s<pars->numSites;s++)
Egeno[s] = new double[pars->nInd];

freqStruct *freq = (freqStruct *) pars->extras[6];
freqStruct *freq = (freqStruct *) pars->extras[7];
//maybe change to posterior based on frequency
for(int s=0;s<pars->numSites;s++){
keepSNP[s]=0;
Expand Down
4 changes: 2 additions & 2 deletions abcFilterSNP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ void abcFilterSNP::run(funkyPars *pars){
if(sb_pval!=-1 && sb3(cnts)<sb_pval)
pars->keepSites[s] = 0;

funkyHWE *hweStruct = (funkyHWE *) pars->extras[8];//THIS IS VERY NASTY! the ordering within general.cpp is now important
funkyHWE *hweStruct = (funkyHWE *) pars->extras[9];//THIS IS VERY NASTY! the ordering within general.cpp is now important
double lrt = 2*hweStruct->like0[s]-2*hweStruct->likeF[s];
double pval;
if(std::isnan(lrt))
Expand Down Expand Up @@ -263,7 +263,7 @@ void abcFilterSNP::run(funkyPars *pars){
if(2*phi(Z)<edge_pval)
pars->keepSites[s] = 0;

genoCalls *gcw =(genoCalls *) pars->extras[10];
genoCalls *gcw =(genoCalls *) pars->extras[11];
int **gc=NULL;
if(gcw)
gc = gcw->dat;
Expand Down
5 changes: 3 additions & 2 deletions abcGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ void abcGL::run(funkyPars *pars){
if(soap.doRecal!=1 || ancestral_lik.doRecal!=1)
likes = new double*[pars->chk->nSites];
if(GL==1)
call_bam(pars->chk,likes,trim);
call_bam(pars->chk,likes,trim,pars->keepSites);
else if(GL==2)
call_gatk(pars->chk,likes,trim);
else if(GL==3){
Expand Down Expand Up @@ -497,7 +497,8 @@ void abcGL::printLike(funkyPars *pars) {
//beagle format
bufstr.l = 0; //set tmpbuf beginning to zero
for(int s=0;s<pars->numSites;s++) {
lh3struct *lh3 = (lh3struct*) pars->extras[index+1];
lh3struct *lh3 = (lh3struct*) pars->extras[index+2];
assert(lh3);
if(pars->keepSites[s]==0||lh3->hasAlloced[s]==0)
continue;

Expand Down
4 changes: 2 additions & 2 deletions abcHWE_F.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void abcHWE_F::print(funkyPars *pars){
for(int s=0;s<pars->numSites;s++){
if(pars->keepSites[s]==0)
continue;
freqStruct *freq = (freqStruct *) pars->extras[6];
freqStruct *freq = (freqStruct *) pars->extras[7];
float lrt= 2*hweStruct->like0[s]-2*hweStruct->likeF[s];
//DRAGON lrt is sometimes nan
float pval;
Expand Down Expand Up @@ -147,7 +147,7 @@ void abcHWE_F::run(funkyPars *pars){
double *F = new double[pars->numSites];
double *like0 = new double[pars->numSites];
double *likeF = new double[pars->numSites];
freqStruct *freqS = (freqStruct *) pars->extras[6];
freqStruct *freqS = (freqStruct *) pars->extras[7];

double **loglike3;
loglike3=angsd::get3likesRescale(pars);
Expand Down
Loading

0 comments on commit ee80e6e

Please sign in to comment.