Returns every statistic for each SNP location, given the appropriate parameters. See Details for more information.

Zalpha_all(
  pos,
  ws,
  x = NULL,
  dist = NULL,
  LDprofile_bins = NULL,
  LDprofile_rsq = NULL,
  LDprofile_sd = NULL,
  LDprofile_Beta_a = NULL,
  LDprofile_Beta_b = NULL,
  minRandL = 4,
  minRL = 25,
  X = NULL
)

Arguments

pos

A numeric vector of SNP locations

ws

The window size which the statistics will be calculated over. This should be on the same scale as the pos vector.

x

Optional. A matrix of SNP values. Columns represent chromosomes; rows are SNP locations. Hence, the number of rows should equal the length of the pos vector. SNPs should all be biallelic.

dist

Optional. A numeric vector of genetic distances (e.g. cM, LDU). This should be the same length as pos.

LDprofile_bins

Optional. A numeric vector containing the lower bound of the bins used in the LD profile. These should be of equal size.

LDprofile_rsq

Optional. A numeric vector containing the expected \(r^2\) values for the corresponding bin in the LD profile. Must be between 0 and 1.

LDprofile_sd

Optional. A numeric vector containing the standard deviation of the \(r^2\) values for the corresponding bin in the LD profile.

LDprofile_Beta_a

Optional. A numeric vector containing the first estimated Beta parameter for the corresponding bin in the LD profile.

LDprofile_Beta_b

Optional. A numeric vector containing the second estimated Beta parameter for the corresponding bin in the LD profile.

minRandL

Minimum number of SNPs in each set R and L for the statistics to be calculated. L is the set of SNPs to the left of the target SNP and R to the right, within the given window size ws. Default is 4.

minRL

Minimum value for the product of the set sizes for R and L. Default is 25.

X

Optional. Specify a region of the chromosome to calculate the statistics for in the format c(startposition, endposition). The start position and the end position should be within the extremes of the positions given in the pos vector. If not supplied, the function will calculate the statistics for every SNP in the pos vector.

Value

A list containing the SNP positions and the statistics for those SNPs

Details

Not all statistics will be returned, depending on the parameters supplied to the function.
If x is not supplied, only Zalpha_expected, Zbeta_expected, LR and L_plus_R will be calculated.
For any of the statistics which use an expected \(r^2\) value, the parameters dist, LDprofile_bins and LDprofile_rsq must be supplied. This includes the statistics: Zalpha_expected, Zalpha_rsq_over_expected, Zalpha_log_rsq_over_expected, Zalpha_Zscore, Zalpha_BetaCDF, Zbeta_expected, Zbeta_rsq_over_expected, Zbeta_log_rsq_over_expected, Zbeta_Zscore and Zbeta_BetaCDF.

The LD profile describes the expected correlation between SNPs at a given genetic distance, generated using simulations or real data. Care should be taken to utilise an LD profile that is representative of the population in question. The LD profile should consist of evenly sized bins of distances (for example 0.0001 cM per bin), where the value given is the (inclusive) lower bound of the bin. Ideally, an LD profile would be generated using data from a null population with no selection, however one can be generated using this data. See the create_LDprofile function for more information on how to create an LD profile. For more information about the statistics, please see Jacobs (2016).

References

Jacobs, G.S., T.J. Sluckin, and T. Kivisild, Refining the Use of Linkage Disequilibrium as a Robust Signature of Selective Sweeps. Genetics, 2016. 203(4): p. 1807

See also

Examples

## load the snps and LDprofile example datasets data(snps) data(LDprofile) ## run Zalpha_all over all the SNPs with a window size of 3000 bp ## will return all 15 statistics Zalpha_all(snps$bp_positions,3000,as.matrix(snps[,3:12]),snps$cM_distances, LDprofile$bin,LDprofile$rsq,LDprofile$sd,LDprofile$Beta_a,LDprofile$Beta_b)
#> $position #> [1] 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 #> [16] 1600 1700 1800 1900 2000 #> #> $LR #> [1] 0 15 30 45 60 70 78 84 88 90 90 88 84 78 70 60 45 30 15 0 #> #> $L_plus_R #> [1] 105 105 106 108 111 101 93 87 83 81 81 83 87 93 101 111 108 106 105 #> [20] 105 #> #> $Zalpha_expected #> [1] NA NA NA NA 0.08633502 0.08169169 #> [7] 0.07981817 0.08104324 0.08134506 0.08015626 0.07984135 0.08082988 #> [13] 0.08263229 0.08040794 0.07822704 0.08289555 NA NA #> [19] NA NA #> #> $Zbeta_expected #> [1] NA NA NA NA 0.07935940 0.07840546 #> [7] 0.07845889 0.07726474 0.07734390 0.07801402 0.07743300 0.07714027 #> [13] 0.07798668 0.07880907 0.08001374 0.08138610 NA NA #> [19] NA NA #> #> $Zalpha #> [1] NA NA NA NA 0.09893585 0.10944106 #> [7] 0.11602964 0.11215782 0.12419556 0.12962040 0.12583275 0.11980489 #> [13] 0.10802033 0.12064462 0.10873917 0.10267168 NA NA #> [19] NA NA #> #> $Zbeta #> [1] NA NA NA NA 0.1280042 0.1298619 0.1219965 #> [8] 0.1071535 0.1124896 0.1121871 0.1033178 0.1185118 0.1212802 0.1281512 #> [15] 0.1275420 0.1442328 NA NA NA NA #> #> $Zalpha_rsq_over_expected #> [1] NA NA NA NA 1.229709 1.455017 1.557973 1.473750 #> [9] 1.663279 1.748810 1.655937 1.560111 1.348384 1.540937 1.403390 1.302492 #> [17] NA NA NA NA #> #> $Zalpha_log_rsq_over_expected #> [1] NA NA NA NA -2.80109183 -2.52953641 #> [7] -2.89862430 -0.06997296 -0.04968498 -0.05720747 -0.09096136 -0.14235949 #> [13] -0.18846597 -0.11839984 -0.18570016 -3.28861224 NA NA #> [19] NA NA #> #> $Zbeta_rsq_over_expected #> [1] NA NA NA NA 1.662441 1.753478 1.628663 1.463948 #> [9] 1.543292 1.559820 1.468623 1.689309 1.687198 1.759164 1.737935 1.934010 #> [17] NA NA NA NA #> #> $Zbeta_log_rsq_over_expected #> [1] NA NA NA NA -5.81626185 -6.65751023 #> [7] -7.49094344 -6.58013806 -6.69181952 -6.54908550 -7.83646879 -6.18038047 #> [13] -7.39743178 -6.45648923 -6.00894964 0.09510038 NA NA #> [19] NA NA #> #> $Zalpha_Zscore #> [1] NA NA NA NA 0.08320337 0.17092137 #> [7] 0.21026515 0.17941815 0.24933136 0.28017067 0.25141352 0.21744923 #> [13] 0.13918111 0.21735113 0.16446541 0.12300862 NA NA #> [19] NA NA #> #> $Zbeta_Zscore #> [1] NA NA NA NA 0.2644152 0.2959959 0.2473133 #> [8] 0.1761311 0.2115564 0.2148552 0.1755580 0.2596216 0.2590911 0.2916302 #> [15] 0.2848765 0.3617791 NA NA NA NA #> #> $Zalpha_BetaCDF #> [1] NA NA NA NA 0.5553324 0.6013140 0.6135663 #> [8] 0.6114601 0.6153488 0.6073154 0.5895785 0.6060782 0.5871007 0.6161310 #> [15] 0.5889128 0.5730982 NA NA NA NA #> #> $Zbeta_BetaCDF #> [1] NA NA NA NA 0.5904780 0.5810107 0.5627583 #> [8] 0.5507821 0.5595338 0.5637204 0.5466796 0.5865750 0.5672179 0.5854016 #> [15] 0.5899818 0.6315494 NA NA NA NA #>
## only return results for SNPs between locations 600 and 1500 bp Zalpha_all(snps$bp_positions,3000,as.matrix(snps[,3:12]),snps$cM_distances, LDprofile$bin,LDprofile$rsq,LDprofile$sd,LDprofile$Beta_a,LDprofile$Beta_b,X=c(600,1500))
#> $position #> [1] 600 700 800 900 1000 1100 1200 1300 1400 1500 #> #> $LR #> [1] 70 78 84 88 90 90 88 84 78 70 #> #> $L_plus_R #> [1] 101 93 87 83 81 81 83 87 93 101 #> #> $Zalpha_expected #> [1] 0.08169169 0.07981817 0.08104324 0.08134506 0.08015626 0.07984135 #> [7] 0.08082988 0.08263229 0.08040794 0.07822704 #> #> $Zbeta_expected #> [1] 0.07840546 0.07845889 0.07726474 0.07734390 0.07801402 0.07743300 #> [7] 0.07714027 0.07798668 0.07880907 0.08001374 #> #> $Zalpha #> [1] 0.1094411 0.1160296 0.1121578 0.1241956 0.1296204 0.1258327 0.1198049 #> [8] 0.1080203 0.1206446 0.1087392 #> #> $Zbeta #> [1] 0.1298619 0.1219965 0.1071535 0.1124896 0.1121871 0.1033178 0.1185118 #> [8] 0.1212802 0.1281512 0.1275420 #> #> $Zalpha_rsq_over_expected #> [1] 1.455017 1.557973 1.473750 1.663279 1.748810 1.655937 1.560111 1.348384 #> [9] 1.540937 1.403390 #> #> $Zalpha_log_rsq_over_expected #> [1] -2.52953641 -2.89862430 -0.06997296 -0.04968498 -0.05720747 -0.09096136 #> [7] -0.14235949 -0.18846597 -0.11839984 -0.18570016 #> #> $Zbeta_rsq_over_expected #> [1] 1.753478 1.628663 1.463948 1.543292 1.559820 1.468623 1.689309 1.687198 #> [9] 1.759164 1.737935 #> #> $Zbeta_log_rsq_over_expected #> [1] -6.657510 -7.490943 -6.580138 -6.691820 -6.549085 -7.836469 -6.180380 #> [8] -7.397432 -6.456489 -6.008950 #> #> $Zalpha_Zscore #> [1] 0.1709214 0.2102652 0.1794181 0.2493314 0.2801707 0.2514135 0.2174492 #> [8] 0.1391811 0.2173511 0.1644654 #> #> $Zbeta_Zscore #> [1] 0.2959959 0.2473133 0.1761311 0.2115564 0.2148552 0.1755580 0.2596216 #> [8] 0.2590911 0.2916302 0.2848765 #> #> $Zalpha_BetaCDF #> [1] 0.6013140 0.6135663 0.6114601 0.6153488 0.6073154 0.5895785 0.6060782 #> [8] 0.5871007 0.6161310 0.5889128 #> #> $Zbeta_BetaCDF #> [1] 0.5810107 0.5627583 0.5507821 0.5595338 0.5637204 0.5466796 0.5865750 #> [8] 0.5672179 0.5854016 0.5899818 #>
## will only return statistics not requiring an LD profile Zalpha_all(snps$bp_positions,3000,as.matrix(snps[,3:12]))
#> $position #> [1] 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 #> [16] 1600 1700 1800 1900 2000 #> #> $LR #> [1] 0 15 30 45 60 70 78 84 88 90 90 88 84 78 70 60 45 30 15 0 #> #> $L_plus_R #> [1] 105 105 106 108 111 101 93 87 83 81 81 83 87 93 101 111 108 106 105 #> [20] 105 #> #> $Zalpha #> [1] NA NA NA NA 0.09893585 0.10944106 #> [7] 0.11602964 0.11215782 0.12419556 0.12962040 0.12583275 0.11980489 #> [13] 0.10802033 0.12064462 0.10873917 0.10267168 NA NA #> [19] NA NA #> #> $Zbeta #> [1] NA NA NA NA 0.1280042 0.1298619 0.1219965 #> [8] 0.1071535 0.1124896 0.1121871 0.1033178 0.1185118 0.1212802 0.1281512 #> [15] 0.1275420 0.1442328 NA NA NA NA #>