================ famQBL INSTRUCTIONS ===============
An R function famQBL can be used for detecting association of rare and common haplotypes with a quantitative trait using family data. The method is described in Datta et al. (2018).
This document contains instructions for unzipping and using the famQBL R function on a linux machine. The folder contains the following files:
(a) famQBL.R  --> R function file.
(d) famQBL.so  --> C dynamic library file.
(c) famQBL.c  --> C source file. (Provided in case the dynamic library does not work in the user’s linux system and the user intends to create the library file according to his/her system requirements)
(d) ped_geno_pheno.txt  --> First input file.
(e) haplore_input.txt  --> Second input file.
(f) haplore_output.txt  --> Third input file.
Download and Install:
1. For Linux users, download the zipped folder famQBL_1.0.tar.gz.
2. Untar the folder with the command "tar xvzf famQBL_1.0.tar.gz". 
Usage:
Note: An R package, kinship2 is required for running famQBL. You need to download it from CRAN and install it. Also, the raw data must be run in software HAPLORE (Zhang et al., 2005) before running famQBL. HAPLORE’s input and output files are needed by famQBL.
Presently the famQBL function takes in the pedigree + genotype + phenotype information as an R data frame with no header along with two files that are input and output files from HAPLORE. The Haplore output file contains information about all possible haplotype combinations for every member for each pedigree. These files must be present in the same folder as the R function and C library files. The default name for HAPLORE input file is "haplore_input.dat" and for HAPLORE output file is "haplore_output.dat". They are passed as arguments to the R function. 
To run the function, keep the R file, dynamic library .so file, and the three input files in one folder and then do the following two steps to get the output:
a.	Read in the pedigree + geno + pheno file. Here is it ped_geno_pheno.txt. The R command is
data = read.table("ped_geno_pheno.txt",h=F)
b.	Call the R function with the above read in data, number of haplotypes, haplore input and haplore output file names. Default number of iterations is 70000 with burn in 20000. These can be changed during function call. The R function call is (with n replaced by # haplotypes) is
famQBL(data=data, num_haplotypes=n, file1="haplore_input.dat", file2="haplore_output.dat")                
Note: file1 is the filename of the HAPLORE input file and file2 is the filename of the HAPLORE output file. 
Example:
We are now ready to run famQBL using the example data provided in the folder.                                                                        
#Note: The default settings are burn.in = 20000 and num.it = 70000 in the famQBL function. However for a quick check to make sure that the package is working properly, the example below uses much smaller numbers.
> data = read.table("ped_geno_pheno.txt", h=F)                                            
> famQBL(data, num_haplotype=6, file1 = "haplore_input.dat", file2 = "haplore_output.dat", burn.in=10, num.it=100)
If the function run is successful then the following will be printed on command prompt.             "Analysis Output is stored in file famQBL_analysis.csv"
The user can check the famQBL_analysis.csv file for output. A sample output with the example input file for 10000 iterations and 2000 burn in is shown below. Note that the results indicate that two rare haplotypes (h11011 and h10100) are associated with the disease because the Bayes Factor (BF) values are large and also the 95% credible sets do not contain zero. 
Haplotype	Freq	BF	Beta	Low_CS	Up_CS	
h10011	0.4285	0.0036	-0.0503	-0.1038	0.0155	
h01100	0.2885	0	0.0326	-0.0261	0.0956	
h11100	0.167	0.0036	0.0444	-0.0234	0.1051	
h11111	0.103	0.0062	-0.0015	-0.1208	0.0883	
h11011	0.009	>100	0.4176	0.1796	0.6984	
h10100	0.004	>100	0.7761	0.5823	1.0905	
						
NOTE: As famQBL is MCMC-based, the results may slightly vary in different runs. With large enough iterations to ensure convergence, the results should be similar though.

References:
Datta, A.S., Lin, S., and Biswas, S. (2018) A Family-Based Rare Haplotype Association Method for Quantitative Traits. Manuscript
Zhang, K., Sun, F., Zhao, H. (2005) HAPLORE: a program for haplotype reconstruction in general pedigrees without recombination. Bioinformatics 21(1):90-103.
-----------------------------------------------------------------
If you have any questions, please email Ananda Datta at asd107020@utdallas.edu or Swati Biswas at swati.biswas@utdallas.edu