GWAS Pipeline.
Given genome files and phenotypic file, matches them, filters, makes kinship matrix and covariate file, runs linear mixed model(by EMMAX)
and builds Manhattan and QQ plots for each trait. Makes a summary file for most significant SNPs with allele effect.

System requirements:
       OS:
		- Linux
       Software installed:
       		- Python v2.6-v2.7 (https://www.python.org/downloads/)
		- Numerical Python (NumPy) (http://sourceforge.net/projects/numpy/)
		- Plink v1.9 (https://www.cog-genomics.org/plink2)
		- R (http://cran.r-project.org/doc/manuals/r-release/R-admin.html)
Configuration:
      After files copied to desired location, text configuration file (appconfig.ini) needs to be changed to reflect all settings. 
      It consists of the following sections:

      - GenomeData
		GLOC: location of the genome formatted plink files (*.map & *.ped ,thin_cut_set - in the sample data)
		GFILE: the name of the genome formatted plink files (no extensions)
		GT_VER: HDRA files version ( current G6.4)
		POPFILE: Populations division file name (lines_info_G6_4.tsv)
		SNPsDATA: SNPs mapping file (HDRA-G6-4-snp-map.tsv)

      - PhenoData
		PLOC: phenotypic file location
		PHENO_FILE: phenotypic file name (testData.txt in the sample data)
		
      - ProjectLocation
		PROJ: place where the results will be collected
      - Software
		PLINK: plink installation location
		RScript4PC: r-script ( support_gwa.R )
		EMM_LOC:emmax installation location
      - RunParameters
		MAF_FILTER: Minor allele frequeny filter (0.1)
		MAC_FILTER: Minor allele count filter (1)
		GENO_FILTER: Genetic missingness filter (0.3)
		GROUPS: RDP1, RDP2 or RDP12 - in case of processing them together
			For processing several groups independently place all desired separated by space 
		POPS: Sub population (ALL - for processing altogether)
		      AUS, IND, TRJ, TEJ, AROM and ALL - are available options.
		      For processing several sub pop independently place all desired separated by space 
		MATRIX: IBS or BN type of the kinkship matrix
		PC : Number of principal components for additional co-variate file 0 for none. Maximum - 4.
  	    	OVERWRITE:  Set to True to overwrite the existing results 
  	      	BEST_SNP_LIMIT: The p-Value threshold to include SNPs into the best_SNPs_summary file (0.2)
		FDR_LIMIT: FDR threshold for MP
		mkQQplot: 1 to produce QQ plot, 0 otherwise
		mkMPlot: 1 to produce MP, 0 otherwise
		QQplotLambda: 1 to include lambda on QQ plot, 0 otherwise
		QQplotStdError: 1 to include a standard error on QQ plot, 0 otherwise

Data requirements.
     - Genome files for the processing needs to be in plink format *.map (http://pngu.mgh.harvard.edu/~purcell/plink/data.shtml#ped) and  *.ped (http://pngu.mgh.harvard.edu/~purcell/plink/data.shtml#ped)
     - Phenotypic files are to be in plink alternate phenotype file format (http://pngu.mgh.harvard.edu/~purcell/plink/data.shtml#pheno)

Pipeline run.
     After configuration file set, call: python gwas_lib.py in command line.

Output files:
     best_SNPs_summary_list*.csv - summary file for all significant SNPs including following columns:  (located in the results directory of the project location)
     	-TRAIT	
	-GROUP\SUB_POP	
	-COV_PC	
	-FILTER	
	-SNP-NAME	
	-CHROMOSOME	
	-POSITION	
	-pVALUE	
	-MajorAllele	
	-MinorAllele	
	-MajorAllele_Count	
	-MajorAllele_%%	
	-MajorAllele_Trait_Average	
	-Getero_Count	
	-Getero%%	
	-GeteroTrait_Average	
	-MinorAllele_Count	
	-MinorAllele%%	
	-MinorAllele_Trait_Average	
	-Allele_Effect  
     *.ps - EMMAX results files with SNP name, beta and p-Value for all SNPs (located in the results directory of the project location)
     *.log and *.reml - EMMAX log files (located in the results directory of the project location)
     results_summary.txt - summary file with most significant SNP for each trait
     MP_*.png - Manhattan plots for each trait. (located in the plots directory of the project location)
     QQ_*.png - QQ plots for each trait. (located in the plots directory of the project location)
     
     
