Last updated: 2020-03-12

Checks: 2 0

Knit directory: misc/analysis/

This reproducible R Markdown analysis was created with workflowr (version 1.6.0.9000). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version fbcb572. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .DS_Store
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/.RData
    Ignored:    analysis/.Rhistory
    Ignored:    analysis/ALStruct_cache/
    Ignored:    data/.Rhistory
    Ignored:    data/pbmc/

Untracked files:
    Untracked:  .dropbox
    Untracked:  Icon
    Untracked:  analysis/GHstan.Rmd
    Untracked:  analysis/GTEX-cogaps.Rmd
    Untracked:  analysis/PACS.Rmd
    Untracked:  analysis/SPCAvRP.rmd
    Untracked:  analysis/compare-transformed-models.Rmd
    Untracked:  analysis/cormotif.Rmd
    Untracked:  analysis/cp_ash.Rmd
    Untracked:  analysis/eQTL.perm.rand.pdf
    Untracked:  analysis/eb_prepilot.Rmd
    Untracked:  analysis/ebpmf1.Rmd
    Untracked:  analysis/flash_test_tree.Rmd
    Untracked:  analysis/ieQTL.perm.rand.pdf
    Untracked:  analysis/m6amash.Rmd
    Untracked:  analysis/mash_bhat_z.Rmd
    Untracked:  analysis/mash_ieqtl_permutations.Rmd
    Untracked:  analysis/mixsqp.Rmd
    Untracked:  analysis/mr_ash_modular.Rmd
    Untracked:  analysis/mr_ash_parameterization.Rmd
    Untracked:  analysis/nejm.Rmd
    Untracked:  analysis/normalize.Rmd
    Untracked:  analysis/pbmc.Rmd
    Untracked:  analysis/poisson_transform.Rmd
    Untracked:  analysis/pseudodata.Rmd
    Untracked:  analysis/qrnotes.txt
    Untracked:  analysis/ridge_iterative_splitting.Rmd
    Untracked:  analysis/sc_bimodal.Rmd
    Untracked:  analysis/shrinkage_comparisons_changepoints.Rmd
    Untracked:  analysis/susie_en.Rmd
    Untracked:  analysis/susie_z_investigate.Rmd
    Untracked:  analysis/svd-timing.Rmd
    Untracked:  analysis/temp.Rmd
    Untracked:  analysis/test-figure/
    Untracked:  analysis/test.Rmd
    Untracked:  analysis/test.Rpres
    Untracked:  analysis/test.md
    Untracked:  analysis/test_qr.R
    Untracked:  analysis/test_sparse.Rmd
    Untracked:  analysis/z.txt
    Untracked:  code/multivariate_testfuncs.R
    Untracked:  code/rqb.hacked.R
    Untracked:  data/4matthew/
    Untracked:  data/4matthew2/
    Untracked:  data/E-MTAB-2805.processed.1/
    Untracked:  data/ENSG00000156738.Sim_Y2.RDS
    Untracked:  data/GDS5363_full.soft.gz
    Untracked:  data/GSE41265_allGenesTPM.txt
    Untracked:  data/Muscle_Skeletal.ACTN3.pm1Mb.RDS
    Untracked:  data/Thyroid.FMO2.pm1Mb.RDS
    Untracked:  data/bmass.HaemgenRBC2016.MAF01.Vs2.MergedDataSources.200kRanSubset.ChrBPMAFMarkerZScores.vs1.txt.gz
    Untracked:  data/bmass.HaemgenRBC2016.Vs2.NewSNPs.ZScores.hclust.vs1.txt
    Untracked:  data/bmass.HaemgenRBC2016.Vs2.PreviousSNPs.ZScores.hclust.vs1.txt
    Untracked:  data/eb_prepilot/
    Untracked:  data/finemap_data/fmo2.sim/b.txt
    Untracked:  data/finemap_data/fmo2.sim/dap_out.txt
    Untracked:  data/finemap_data/fmo2.sim/dap_out2.txt
    Untracked:  data/finemap_data/fmo2.sim/dap_out2_snp.txt
    Untracked:  data/finemap_data/fmo2.sim/dap_out_snp.txt
    Untracked:  data/finemap_data/fmo2.sim/data
    Untracked:  data/finemap_data/fmo2.sim/fmo2.sim.config
    Untracked:  data/finemap_data/fmo2.sim/fmo2.sim.k
    Untracked:  data/finemap_data/fmo2.sim/fmo2.sim.k4.config
    Untracked:  data/finemap_data/fmo2.sim/fmo2.sim.k4.snp
    Untracked:  data/finemap_data/fmo2.sim/fmo2.sim.ld
    Untracked:  data/finemap_data/fmo2.sim/fmo2.sim.snp
    Untracked:  data/finemap_data/fmo2.sim/fmo2.sim.z
    Untracked:  data/finemap_data/fmo2.sim/pos.txt
    Untracked:  data/logm.csv
    Untracked:  data/m.cd.RDS
    Untracked:  data/m.cdu.old.RDS
    Untracked:  data/m.new.cd.RDS
    Untracked:  data/m.old.cd.RDS
    Untracked:  data/mainbib.bib.old
    Untracked:  data/mat.csv
    Untracked:  data/mat.txt
    Untracked:  data/mat_new.csv
    Untracked:  data/matrix_lik.rds
    Untracked:  data/paintor_data/
    Untracked:  data/temp.txt
    Untracked:  data/y.txt
    Untracked:  data/y_f.txt
    Untracked:  data/zscore_jointLCLs_m6AQTLs_susie_eQTLpruned.rds
    Untracked:  data/zscore_jointLCLs_random.rds
    Untracked:  explore_udi.R
    Untracked:  output/fit.k10.rds
    Untracked:  output/fit.varbvs.RDS
    Untracked:  output/glmnet.fit.RDS
    Untracked:  output/test.bv.txt
    Untracked:  output/test.gamma.txt
    Untracked:  output/test.hyp.txt
    Untracked:  output/test.log.txt
    Untracked:  output/test.param.txt
    Untracked:  output/test2.bv.txt
    Untracked:  output/test2.gamma.txt
    Untracked:  output/test2.hyp.txt
    Untracked:  output/test2.log.txt
    Untracked:  output/test2.param.txt
    Untracked:  output/test3.bv.txt
    Untracked:  output/test3.gamma.txt
    Untracked:  output/test3.hyp.txt
    Untracked:  output/test3.log.txt
    Untracked:  output/test3.param.txt
    Untracked:  output/test4.bv.txt
    Untracked:  output/test4.gamma.txt
    Untracked:  output/test4.hyp.txt
    Untracked:  output/test4.log.txt
    Untracked:  output/test4.param.txt
    Untracked:  output/test5.bv.txt
    Untracked:  output/test5.gamma.txt
    Untracked:  output/test5.hyp.txt
    Untracked:  output/test5.log.txt
    Untracked:  output/test5.param.txt

Unstaged changes:
    Modified:   analysis/ash_delta_operator.Rmd
    Modified:   analysis/ash_pois_bcell.Rmd
    Modified:   analysis/minque.Rmd
    Modified:   analysis/mr_missing_data.Rmd

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/sparse_structure.Rmd) and HTML (docs/sparse_structure.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd fbcb572 Matthew Stephens 2020-03-12 workflowr::wflow_publish(“sparse_structure.Rmd”)

Introduction

The structure/admixture model is a model for multinomial genotype data, originally introduced and fit by MCMC in the “Structure” paper (Pritchard, Stephens and Donnelly; 2000), and subsequently fit by maximum likelihood in the “Admixture” paper (Alexander et al).

The basic idea of the model is to model each sample \(i\) as having some degree of membership \(q_{i1},\dots,q_{iK}\) in each of \(K\) populations, with allele frequencies \(p_k\).

Here we explore the possibility to regularize this model by introducing the idea that the allele frequencies \(p_k\) are similar – or even identical – for most populations \(k\) at most sites \(l\).

Model

We consider the haploid version of the model, where each indidividual \(i\) has one observation at each locus \(l\).

Notationally, it is helpful to represent the data in each individual at each locus as indicator vectors: \(X_{il\cdot}= X_{il1},\dots,X_{ilJ}\) where \(X_{ilj}=1\) if individual \(i\) is of type \(j\) at locus \(l\), and \(X_{ilj}=0\) otherwise.

Then the admixture model is \[X_{ilj} \sim \text{Mult}(1;\pi_{il\cdot})\] \[\pi_{ilj} = \sum_k q_{ik} p_{klj}\]

where Mult(n,\(\pi\)) denotes a (discrete) categorical distribution on \(1,...,J\) with probabilities \(\pi=(\pi_1,\dots,\pi_J)\), \(i\) indexes individuals, \(l\) indexes sites (loci), and \(j\) indexes alleles.

Writing it this way, one can see the connection with factor models, or ``low-rank" models, which sum over a small number of factors \(k=1,\dots,K\). The model for \(\pi_{ilj}\) is “low rank”.

For computation it is helpful to introduce latent variables to indicate the population of origin of each individual at each locus. Let \[Z_{il\cdot} \sim \text{Mult}(1; q_{i1},\dots,q_{iK}).\] So \(Z_{il\cdot}\) is a binary indicator vector (length \(K\)), with \(Z_{ilk}=1\) indicating that the population of origin of individual \(i\) at locus \(l\) is \(k\). We can then write \[X_{il\cdot} | p \sim \sum_k Z_{ilk} \text{Mult}(1; p_{kl\cdot})\]

Modification

Now we introduce a prior to allow that the \(p_k\) may be similar to one another at many loci/sites. This is similar to the idea of the ``correlated allele frequencies model" in Pritchard et al, but with more of a focus on sparsity (meaning exact or almost-exact equality of the allele frequencies for different \(k\)) and an eye on potential maximimum likelihood approach.

The proposed prior is: \[p_{kl\cdot} | \alpha, \mu \sim \text{Dir}(\alpha_{kl} \mu_{l\cdot})\] where \(\alpha_{kl}\) is a scalar that controls how similar \(p_k\) is to the mean \(\mu_{l\cdot}\) at locus \(l\), and \(\mu_{l\cdot}\) is the mean of the Dirichlet prior. Intuitively \(\mu_{l\cdot}\) represents the allele frequencies at locus \(l\), that are shared across populations. The idea of a separate \(\alpha\) for each \(k,l\) seems related to the so-called “automatic relevance determination prior”, and also the Sparse Factor Analysis method of Engelhardt and Stephens.

In the limit \(\alpha_{kl} \rightarrow \infty\) the \(p_{kl\cdot} = \mu_{kl\cdot}\) with probability 1.

Under this prior the distribution on the \(X\)s becomes a mixture of Dirichlet-Multinomials: \[X_{il\cdot} | \alpha, \mu \sim \sum_k Z_{ilk} \text{Dir-Mult}(1; \alpha_{kl}\mu_{kl\cdot}).\]

I suspect there is an EM algorithm for fitting this model, which here means estimating \(\alpha,\mu,q\). The estimated \(\mu\) should be approximately the site-specific marginal frequencies, and \(alpha_{kl}\) will be small when the factors \(k\) deviate from this mean at locus \(l\). I found this paper on fitting mixtures of Dirichlet multinomials by EM, which seems relevant here. Indeed, the above is basically extending theis mixture model to the “grade of membership” idea, but with the addition of more parameters \(\alpha\).

We may want to put a hyper-prior on \(\alpha\) that encourages it to be big at most loci in most factors…