This function compares two sets of parental populations to identify loci that exhibit a fixed difference, returns an genlight object with the reduced data, and creates an input file for the program NewHybrids using the top 200 loci. In the absence of two identified parental populations, the script will select a random set 200 loci only (method=random) or the first 200 loci ranked on information content (AvgPIC).
gl.nhybrids(gl, outfile = "nhyb.txt", outpath = tempdir(), p0 = NULL,
p1 = NULL, t = 0, method = "random", nhyb.directory = NULL,
BurnIn = 10000, sweeps = 10000, GtypFile = "TwoGensGtypFreq.txt",
AFPriorFile = NULL, PiPrior = "Jeffreys", ThetaPrior = "Jeffreys",
v = 2)
-- name of the genlight object containing the SNP data [required]
-- name of the file that will be the input file for NewHybrids [default nhyb.txt]
-- path where to save the output file (set to tempdir by default)
-- list of populations to be regarded as parental population 0 [default NULL]
-- list of populations to be regarded as parental population 1 [default NULL]
-- sets the level at which a gene frequency difference is considered to be fixed [default 0]
-- specifies the method (random or AvgPIC) to select 200 loci for NewHybrids [default random]
-- directory that holds the NewHybrids executable file e.g. C:/NewHybsPC [default NULL]
-- number of sweeps to use in the burn in [default 10000]
-- number of sweeps to use in computing the actual Monte Carlo averages [default 10000]
-- name of a file containing the genotype frequency classes [default TwoGensGtypFreq.txt]
-- name of the file containing prior allele frequency information [default NULL]
-- Jeffreys-like priors or Uniform priors for the parameter pi [default Jeffreys]
-- Jeffreys-like priors or Uniform priors for the parameter theta [default Jeffreys]
-- verbosity: 0, silent or fatal errors; 1, begin and end; 2, progress log ; 3, progress and results summary; 5, full report [default 2]
The reduced genlight object, if parentals are provided; output of NewHybrids to disk
A fixed difference occurs when a SNP allele is present in all individuals of one population and absent in the other. There is provision for setting a level of tollerance, e.g. t = 0.05 which considers alleles present at greater than 95 a fixed difference. Only the 200 loci are retained, because of limitations of NewHybids.
If you specify a directory for the NewHybrids executable file, then the script will create the input file from the snp data then run NewHybrids. If the directory is set to NULL, the exectution will stop once the input file (nhyb.txt) has been written to disk.
Refer to the New Hybrids manual for further information on the parameters to set -- http://ib.berkeley.edu/labs/slatkin/eriq/software/new_hybs_doc1_1Beta3.pdf
It is important to stringently filter the data on RepAvg and CallRate if using the random option. One might elect to repeat the analysis (method=random) and combine the resultant posterior probabilites should 200 loci be considered insufficient.
# NOT RUN {
m <- gl.nhybrids(testset.gl, c("Pop1", "Pop4"), c("Pop7", "Pop9"), t=0, method="random")
m <- gl.nhybrids(testset.gl, outfile="nhyb.txt",
p0=NULL, p1=NULL,
nhyb.directory="C:/workspace/R_analysis/NewHybsPC",
BurnIn=100,
sweeps=1000,
v=3)
# }
Run the code above in your browser using DataLab