# Hail curious potential user Q

**URL:** <https://discuss.hail.is/t/hail-curious-potential-user-q/153>\
**Category:** Help \[0.1\]\
**Created:** [March 6, 2017, 1:27pm UTC](https://discuss.hail.is/t/hail-curious-potential-user-q/153 "2017-03-06T13:27:23Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michel\_Nivard](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/michel_nivard/32/500_2.png) [@Michel\_Nivard](https://discuss.hail.is/u/Michel_Nivard)\
**Post date:** [March 6, 2017, 1:27pm UTC](https://discuss.hail.is/t/hail-curious-potential-user-q/153/1 "2017-03-06T13:27:23Z")

</div>

Hi,

Hail sounds like a very pleasant way to work with large sequence data sets. I however intent to work on a large N common variant data sets (UKB).

So can I expect simular speed gains over existing software as is the case for rare variant analysis?

Is there a tutorial on getting Hail to work on the LISA/Surfsara/Cartesius cluster (I ask because I know a lot of PGC work is done on Lisa and someone may already have installed HAIL there)?

Best  
Michel Nivard

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [March 6, 2017, 2:44pm UTC](https://discuss.hail.is/t/hail-curious-potential-user-q/153/2 "2017-03-06T14:44:48Z")

</div>

Hi Michel,  
In its current state, Hail is actually far more useful for common variant association than rare variant association. We currently have no formal RVAS methods implemented (though these will come soon), but for GWAS, we have linear regression, logistic regression, and linear mixed regression. Not only can Hail easily scale to large clusters to increase speed, but on a single core Hail is actually faster than PLINK for linear regression with covariates:

 ![](https://canada1.discourse-cdn.com/flex036/uploads/hail/original/1X/f26b64346eef89a2cba630c62c8299f861b6c639.png)  
This plot was produced in October, so Hail is probably even faster now!

In response to your question about setting up Hail, the proper question is whether Spark is configured to run on LISA. I think the IT department managing the cluster would be the best place to look for answers.

---

<div class="post-metadata">

**Author:** ![Michel\_Nivard](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/michel_nivard/32/500_2.png) [@Michel\_Nivard](https://discuss.hail.is/u/Michel_Nivard)\
**Post date:** [March 6, 2017, 4:29pm UTC](https://discuss.hail.is/t/hail-curious-potential-user-q/153/3 "2017-03-06T16:29:08Z")

</div>

Yeah Spark is configured, Ill talk to them about installing Hail, thanks.

Is that PLINK 1.90 or 1.07 you benchmarked against though?

Best,  
Michel

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [March 6, 2017, 4:49pm UTC](https://discuss.hail.is/t/hail-curious-potential-user-q/153/4 "2017-03-06T16:49:55Z")

</div>

It was PLINK 1.9, we tested against the latest versions of PLINK and EPACTS

---

<div class="post-metadata">

**Author:** ![jbloom](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/jbloom/32/109_2.png) [@jbloom](https://discuss.hail.is/u/jbloom)\
**Post date:** [March 6, 2017, 5:14pm UTC](https://discuss.hail.is/t/hail-curious-potential-user-q/153/5 "2017-03-06T17:14:46Z")

</div>

Michel, a bit more detail:

Linear and logistic regression should scale well even for UKBB. However, linear mixed regression is currently optimzed to handle, say, 10k whole genomes, 100K variants (or more) in kinship, and association on 20M (or more) variants. It won’t run on UKBB due to limitations of current implementation as discussed in the [docs](https://hail.is/hail/hail.VariantDataset.html?highlight=lmmreg#hail.VariantDataset.lmmreg) (the kinship matrix is calculated in parallel, collected to master, and then eigen-decomposed as a local matrix, with the result broadcast to workers). We have plans for implementations that should scale lmmreg to UKBB scale sample sizes in the future.

Hail’s linear regression with several covariates is faster than PLINK 1.9 on one core due to a trick which effectively projects out sample covariates from the genotype vector per variant via a dense-matrix / sparse-vector multiply, reducing the per-variant computation to a simple correlation. If you’re interested, the code is [here](https://github.com/hail-is/hail/blob/master/src/main/scala/is/hail/methods/LinearRegression.scala).

---

<div class="post-metadata">

**Author:** ![Michel\_Nivard](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/michel_nivard/32/500_2.png) [@Michel\_Nivard](https://discuss.hail.is/u/Michel_Nivard)\
**Post date:** [March 7, 2017, 11:13am UTC](https://discuss.hail.is/t/hail-curious-potential-user-q/153/6 "2017-03-07T11:13:12Z")

</div>

The code is hard to follow given I am not familiar with Python (or ithis might be writen in a language other than python, idk). The math seems like a variation on linear regression trough QR decomposition? Where does the variable xx in line 65 come from and what is its value?

Michel

---

<div class="post-metadata">

**Author:** ![jbloom](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/jbloom/32/109_2.png) [@jbloom](https://discuss.hail.is/u/jbloom)\
**Post date:** [March 7, 2017, 3:03pm UTC](https://discuss.hail.is/t/hail-curious-potential-user-q/153/7 "2017-03-07T15:03:24Z")

</div>

The language is Scala (plus Breeze and Spark) and that’s right, QR decomposition is used to find the projection matrix Q transpose from n-dim space (with n samples) onto the k-dimensional vector space spanned by the k sample covariate vectors. xx is shorthand for the dot product of x and x, xxp is the dot project of x and its projection xp, etc. Why this math works is not transparent, so I should really write up a mathematical description as well. I’ll let you know here when I do!

---

<div class="post-metadata">

**Author:** ![Michel\_Nivard](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/michel_nivard/32/500_2.png) [@Michel\_Nivard](https://discuss.hail.is/u/Michel_Nivard)\
**Post date:** [March 7, 2017, 6:46pm UTC](https://discuss.hail.is/t/hail-curious-potential-user-q/153/8 "2017-03-07T18:46:58Z")

</div>

No it’s not apparent, but your comments give me a basis to rewrite this in R, compare to basic OLS matrix algebra and begin too mess around to enhance my understanding, thanks.

Could you point me to the place in the code where you run logistic regression, any speed ups there would be most relevant to me.

---

<div class="post-metadata">

**Author:** ![jbloom](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/jbloom/32/109_2.png) [@jbloom](https://discuss.hail.is/u/jbloom)\
**Post date:** [March 7, 2017, 7:05pm UTC](https://discuss.hail.is/t/hail-curious-potential-user-q/153/9 "2017-03-07T19:05:05Z")

</div>

The internals of all four logistic models are [here](https://github.com/hail-is/hail/blob/master/src/main/scala/is/hail/stats/LogisticRegressionModel.scala), with some performance comparison at the end of this [post](http://discuss.hail.is/t/added-firth-logistic-regression/127). The projection trick does not extend to logistic and genotype sparsity doesn’t help much as the sample covariates are dense and used alongside in each iteration. We’ve also tried using QR and triangular solve in Newton iteration to avoid direct inversion of the Hessian (Fisher info), but found this does worse, likely because the number of covariates is tiny compared to the number of samples. If you really want to optimize single-core performance, check out the vectorization tricks in [TopCoder competition](https://community.topcoder.com/longcontest/?module=ViewProblemStatement&rd=15637&pm=12525). In the end, logistic regression is per variant and scales beautifully with cores, so does not seem to be a pressing computational bottleneck for Hail (though we may circle back to make it more efficient in the future).
