Пример #1
0
/*This basically means choosing alpha and beta from random values */
void RandoStartClineVars(hyb_chain *C, cline_struct *L)
{
	int l;
	locline_struct *Loc;
	int N,lo,hi;
	
	if(L->NumLocales==0) {
		return;
	}
	
	N = L->NumClineXs;
	lo = (int)(.15 * N);
	hi = (int)(.85 * N);
	
	
	CYCLE_l(C->Dat)   /* cycle over loci */
		/* define this pointer to the current locline struct */
		Loc = L->Locs[l];
		

		Loc->alpha->v = L->ClineX[UniformRV(lo,hi)];
		Loc->beta->v = ranf() * .1;
		
		Loc->LogLike->v = LogistLogL(Loc->alpha->v,Loc->beta->v,Loc->N,Loc->Y,L->x,L->HasLocale,L->MaxLocaleIndex);

			
	END1CYCLE
}	
Пример #2
0
/* here we accumulate the averages of these cline vars */
void IncrementClineVars(hyb_chain *C, cline_struct *L)
{
	int p,l,x;
	
	if(L->NumLocales==0) {
		return;
	}
	
	/* get the averages for Y and N and alpha and beta */
	for(p=0;p<=L->MaxLocaleIndex;p++) {
		if(L->HasLocale[p]) {
			CYCLE_l(C->Dat)
				IncrementIval(L->Locs[l]->Y[p]);
				IncrementIval(L->Locs[l]->N[p]);
				
			END1CYCLE
		}
	}
Пример #3
0
void gfnhDrawKullbLeib(void)
{
	int l;
	GLfloat x=0.0f,y,h=.7f,w,max=0.0f;
	char S[100];
	FILE *out;
	gsSettings gsCS gsWoH;
	
	
	CYCLE_l(gC->Dat)
		/* set the height and the width */
		y = (GLfloat)(gC->Dat->L - l);
		
		if(Settings->GFNH_CURRENT_OR_AVES == GFNH_AVES)
			w = (GLfloat)gC->Lat->Locus_KB[l]->Ave;
		else if(Settings->GFNH_CURRENT_OR_AVES == GFNH_CURRENT)
			w = (GLfloat)gC->Lat->Locus_KB[l]->v;
		else {
			out = fopen(gERROR_FILE,"a");
			fprintf(out,"\nGFNH_CURRENT_OR_AVES set to neither GFNH_AVES or");
			fprintf(out,"\nGFNH_CURRENT in gfnhDrawKullbLeib!! \n\n");
			fclose(out);
		}
		if(w>max)
			max = w;
		
		/*  set the string of the locus and print it */
		sprintf(S,"%s ",gC->Dat->LocNames[l]);
		glColor3fv(CS->Text);
		gfmStrokeString(S, h*.85f ,x, y-h, 4, 0.0f, WoH);
		
		/*  then print the rectangle in the 3rd color of the series */
		glColor3fv(CS->Series[5]);
		glRectf(x,y,x+w,y-h);
	END1CYCLE
	
	gsHANDLE_EXTREMA(0,max,0,gC->Dat->L);
	
	gfmDrawXYAxes();
}
Пример #4
0
void gfnhDrawAlleleFreqs(void)
{
	int k,l;
	GLfloat xs = 1.0f, ys = .5f;
	int n;
	GLfloat w,h,halfh;
	GLfloat x, y;
	int Aves = 0;
	GLfloat cum0,cum1;
	int CW = glutGetWindow();
	char temp[200];
	GLfloat WoH = gfmWoH();
	int MC;

	if(gWindowsSettings[CW]->GFNH_CURRENT_OR_AVES==GFNH_AVES)
		Aves = 1;
		
	/* record the max number of colors in the color scheme */
	MC = gWindowsSettings[CW]->ColorScheme->N;
	
	gfmSetParsForBarGraphs(gC->Dat->L, gWindowsSettings[CW]->NumCols, xs, ys, &n, &w, &h);
	
	halfh = .5f * h;
	
	gWindowsSettings[CW]->SelectedElement = gfmBarGraphIdxFromXY(n, gC->Dat->L,  w,  h,  xs,  ys,
					 gWindowsSettings[CW]->XCoord,  gWindowsSettings[CW]->YCoord);
	
	CYCLE_l(gC->Dat)
		cum0 = 0.0f;
		cum1 = 0.0f;
		
		x = gfmBarGraphXCoord(n,w,xs,l);
		y = gfmBarGraphYCoord(n,h,ys,l);
		
		/*  draw the locus name to the left of the locus */
		sprintf(temp,"%s ",gC->Dat->LocNames[l]);
		glColor3fv(gWindowsSettings[CW]->ColorScheme->Text);
		if(l == gWindowsSettings[CW]->SelectedElement)
			glColor3fv(gWindowsSettings[CW]->ColorScheme->Series[0]);  /*  make the selected one a different color */
		gfmStrokeString(temp,h,x,y-h,3,0.0f,WoH);
		
		
		CYCLE_k(gC->Dat)
			
			gfmDrawRectLeaf6f(x,y,w,halfh, cum0, 1.0f, gWindowsSettings[CW]->ColorScheme->Series[k%MC]);
			gfmDrawRectLeaf6f(x,y-halfh,w,halfh, cum1, 1.0f, gWindowsSettings[CW]->ColorScheme->Series[k%MC]);
			
			if(Aves)  {
				cum0 += gC->Lat->Theta[0][l][k]->Ave;
				cum1 += gC->Lat->Theta[1][l][k]->Ave;
			}
			else  {
				cum0 += gC->Lat->Theta[0][l][k]->v;
				cum1 += gC->Lat->Theta[1][l][k]->v;
			}
			
			
		
		END1CYCLE
	END1CYCLE
	
	if(gWindowsSettings[CW]->SelectedElement >= 0) {
		sprintf(temp,"Selected Locus = %s", gC->Dat->LocNames[gWindowsSettings[CW]->SelectedElement]);
		glColor3fv(gWindowsSettings[CW]->ColorScheme->Text);
		gfmRenderBitmapString(-.05f,1.1f,GLUT_BITMAP_HELVETICA_12,temp);
	}
}
Пример #5
0
/*  Horizontal lines between the individuals are toggled using the Xaxis DrawIt variable */
void gfnhDrawW_Aves(void)
{
	int i,l,c;
	GLfloat xs = .8f, ys = .8f;
	GLfloat x,y, yy;
	ColorScheme3f *CS = gWindowsSettings[glutGetWindow()]->ColorScheme;
	XY_axis_struct *XA = gWindowsSettings[glutGetWindow()]->Xaxis;
	clipping_struct *C = gWindowsSettings[glutGetWindow()]->Clips;
	GLfloat WoH = gfmWoH();
	char temp[100];
	GLfloat texth;
	
	/*  lay down the locus names as rotated text at the top of each column */
	/*  set the top height of the bars */
	y = 3.0f * (GLfloat)gC->Dat->M;
	texth = xs * (C->yhi - C->ylo) / (C->xhi - C->xlo) ;  /*  for textheight */
	CYCLE_l(gC->Dat)  /*  cycle over the loci */
		x = (GLfloat)l;  /*  set the "cursor" to the left edge of each locus rectangle */
		
		sprintf(temp," %s",gC->Dat->LocNames[l]);
		glColor3fv(CS->Text);
		gfmStrokeString(temp,texth,x+.5f*xs,y,1,-45.0f,WoH);
	END1CYCLE
	
	
	CYCLE_i(gC->Dat)
		y = 3.0f * (GLfloat)gC->Dat->M - (3.0f * (GLfloat)i);
		
		/*  draw text telling the individual's number */
		glColor3fv(CS->Text);
		sprintf(temp,"%d",i+1);
		
		gfmStrokeString(temp, 1.9f ,-.1f, y-1.8f, 4, 0.0f,WoH);
		CYCLE_l(gC->Dat)
			x = (GLfloat)l;
			yy = y;
			if(1) { /*  draw alleles if they are codominant OR if they are AFLP */
				
				for(c=0;c<2;c++)  {
					if(gC->Dat->Yobs[i][l][c]->v >= 0)  {  /*  if it is not missing draw the square */
						glColor3fv(CS->Series[0]);  /*  set the color for the whole underlying rectangle */
						glRectf(x,yy,x+xs,yy-ys);
						glColor3fv(CS->Series[1]);  /* then set the color for the Species=1 part. */
						glRectf(x+xs*(1.0-gC->Lat->Ind[i]->W[l][c]->Ave),yy,x+xs,yy-ys);

					}
					if(gC->Dat->Yobs[i][l][c]->v == -1) {  /*  if it is missing, then draw an empty box in axis color, slightly larger than the allele box */
						glColor3fv(CS->Axes);  /*  set the color */
						glBegin(GL_LINE_LOOP);
							glVertex2f(x,yy);
							glVertex2f(x+xs,yy);
							glVertex2f(x+xs,yy-ys);
							glVertex2f(x,yy-ys);
						glEnd();
					}
					/*  move the second allele down one unit: */
					yy -= 1.0f;
				}
			}
			
		END1CYCLE
		
		/*  draw a separating line  */
		if(XA->DrawIt==1)  {
			glColor3fv(CS->Axes);
			glBegin(GL_LINES);
				glVertex2f(0.0f,y-2.5f);
				glVertex2f((GLfloat)gC->Dat->L-(1.0f-xs),y-2.5f);
			glEnd();
		}
			
	END1CYCLE
	
	gsHANDLE_EXTREMA(0.0f,(GLfloat)gC->Dat->L,0.0f, 3.0f * (GLfloat)gC->Dat->M);
	
	
}
Пример #6
0
/*  Horizontal lines between the individuals are toggled using the Xaxis DrawIt variable */
void gfnhDrawObservedData(void)
{
	int i,l,c;
	GLfloat xs = .8f, ys = .8f;
	GLfloat x,y, yy;
	ColorScheme3f *CS = gWindowsSettings[glutGetWindow()]->ColorScheme;
	XY_axis_struct *XA = gWindowsSettings[glutGetWindow()]->Xaxis;
	clipping_struct *C = gWindowsSettings[glutGetWindow()]->Clips;
	GLfloat WoH = gfmWoH();
	char temp[100];
	GLfloat texth;
	
	/*  lay down the locus names as rotated text at the top of each column */
	/*  set the top height of the bars */
	y = 3.0f * (GLfloat)gC->Dat->M;
	texth = xs * (C->yhi - C->ylo) / (C->xhi - C->xlo) ;  /*  for textheight */
	CYCLE_l(gC->Dat)  /*  cycle over the loci */
		x = (GLfloat)l;  /*  set the "cursor" to the left edge of each locus rectangle */
		
		sprintf(temp," %s",gC->Dat->LocNames[l]);
		glColor3fv(CS->Text);
		gfmStrokeString(temp,texth,x+.5f*xs,y,1,-45.0f,WoH);
	END1CYCLE
	
	
	CYCLE_i(gC->Dat)
		y = 3.0f * (GLfloat)gC->Dat->M - (3.0f * (GLfloat)i);
		
		/*  draw text telling the individual's number */
		glColor3fv(CS->Text);
		sprintf(temp,"%d",i+1);
		
		gfmStrokeString(temp, 1.9f ,-.1f, y-1.8f, 4, 0.0f,WoH);
		CYCLE_l(gC->Dat)
			x = (GLfloat)l;
			yy = y;
			if(gC->Dat->LocTypes[l] == CODOM) { /*  draw alleles if they are codominant */
				for(c=0;c<2;c++)  {
					if(gC->Dat->Yobs[i][l][c]->v >= 0)  {  /*  if it is not missing data draw the square */
						glColor3fv(CS->Series[gC->Dat->Yobs[i][l][c]->v % CS->N]);  /*  set the color */
						glRectf(x,yy,x+xs,yy-ys);
					}
					else {  /*  if it is missing, then draw an empty box in axis color */
						glColor3fv(CS->Axes);  /*  set the color */
						glBegin(GL_LINE_LOOP);
							glVertex2f(x,yy);
							glVertex2f(x+xs,yy);
							glVertex2f(x+xs,yy-ys);
							glVertex2f(x,yy-ys);
						glEnd();
					}
					/*  move the second allele down one unit: */
					yy -= 1.0f;
				}
			}
			/*  now, if the locus is an AFLP locus, we draw a plus or a zero */
			if(gC->Dat->LocTypes[l] == AFLP) {
				if(gC->Dat->Yobs[i][l][0]->v == 1)  {
					sprintf(temp,"+");
					glColor3fv(CS->Series[0]);
					gfmStrokeString(temp,3.0f,x + (.5f * xs),y-2.4f + .3f * ys, 2,0.0f,WoH);
				}
				else if(gC->Dat->Yobs[i][l][0]->v == 0) {
					sprintf(temp,"-");
					glColor3fv(CS->Series[1]);
					gfmStrokeString(temp,2.2f,x + (.5f * xs),y-2.2f + .3f * ys, 2,0.0f,WoH);
				}
				else if(gC->Dat->Yobs[i][l][0]->v == -1) {  /* draw an axis-colored, solid rectangle if it is missing */
					glColor3fv(CS->Axes);  /*  set the color */
					glRectf(x,yy,x+xs,yy-1.0-ys);
				}
					
				
				
			}
		END1CYCLE
		
		/*  draw a separating line  */
		if(XA->DrawIt==1)  {
			glColor3fv(CS->Axes);
			glBegin(GL_LINES);
				glVertex2f(0.0f,y-2.5f);
				glVertex2f((GLfloat)gC->Dat->L-(1.0f-xs),y-2.5f);
			glEnd();
		}
			
	END1CYCLE
	
	gsHANDLE_EXTREMA(0.0f,(GLfloat)gC->Dat->L,0.0f, 3.0f * (GLfloat)gC->Dat->M);
	
	
}