This notebook contains scripts to create mixture prior for use with simulations in DSC.
Canonical patterns of sharing:
R=50
prior = mvsusieR:::create_cov_canonical(R)
Paired sharing:
paired = matrix(0,R,R)
paired[1:2,1:2] = 1
prior[['paired_1']] = paired
Block sharing:
block = matrix(0,R,R)
block[1:R/2, 1:R/2] = 1
block[(R/2+1):R, (R/2+1):R] = 1
prior[['blocked_1']] = block
names(prior)
Now assign some weights:
w = c(0.1, rep(0.01,25), rep(0, 24), rep(0.25/5,5), 0.2, 0.2)
prior = prior[which(w>0)]
names(prior)
w = w[which(w>0)]
sum(w)
length(w)
artificial_mixture_50 = list(U=prior,w=w)
R=6
prior = mvsusieR:::create_cov_canonical(R)
paired = matrix(0,R,R)
paired[1:2,1:2] = 1
prior[['paired_1']] = paired
block = matrix(0,R,R)
block[1:R/2, 1:R/2] = 1
block[(R/2+1):R, (R/2+1):R] = 1
prior[['blocked_1']] = block
names(prior)
Now assign some weights:
w = c(0.1, 0, 0.1, 0, 0.1, 0, rep(0.3/5, 5), 0.2, 0.2)
prior = prior[which(w>0)]
names(prior)
w = w[which(w>0)]
sum(w)
length(w)
artificial_mixture_6 = list(U=prior,w=w)
Using this workflow,
sos run ~/GIT/gtexresults/workflows/mashr_flashr_workflow.ipynb flash \
--cwd /project2/compbio/GTEx_eQTL/mashr_flashr_workflow_output \
--data /project2/compbio/GTEx_eQTL/mashr_flashr_workflow_output/FastQTLSumStats.mash.rds \
--effect-model EE -c midway2.yml -q midway2
sos run analysis/20200502_Prepare_ED_prior.ipynb ed \
--cwd /project2/compbio/GTEx_eQTL/mashr_flashr_workflow_output \
--model FastQTLSumStats.mash -c midway2.yml -q midway2
prior = readRDS('../data/FastQTLSumStats.mash.FL_PC3.ED.rds')
names(prior$U)
length(prior$U)
Most weighths are in tFLASH
and XX
,
names(prior$U)[prior$w>0.1]
But many other weights are also non-trivial
names(prior$U)[prior$w>0.001]
tol = 1E-12
U = prior$U[which(prior$w>tol)]
w = prior$w[which(prior$w>tol)]
names(U)
gtex_mixture = list(U=U,w=w)
saveRDS(list(gtex_mixture=gtex_mixture, artificial_mixture_50=artificial_mixture_50, artificial_mixture_6=artificial_mixture_6), '../data/prior_simulation.rds')
Workflow see this notebook.
dat = readRDS('../data/prior_simulation.rds')
names(dat$gtex_mixture)
Load ED mixture,
gtex_ed_mixture = readRDS('~/GIT/mvarbvs/dsc/mnm_prototype/mnm_sumstats/gtex_mixture_identity.FL_PC3.ED.rds')
names(gtex_ed_mixture)
artificial_ed_mixture_50 = readRDS('~/GIT/mvarbvs/dsc/mnm_prototype/mnm_sumstats/artificial_mixture_identity.FL_PC3.ED.rds')
names(artificial_ed_mixture_50)
Filter the components by weight cutoff 1E-15
,
tol = 1E-15
artificial_ed_mixture_50$U = artificial_ed_mixture_50$U[which(artificial_ed_mixture_50$w > tol)]
artificial_ed_mixture_50$w = artificial_ed_mixture_50$w[which(artificial_ed_mixture_50$w > tol)]
gtex_ed_mixture$U = gtex_ed_mixture$U[which(gtex_ed_mixture$w > tol)]
gtex_ed_mixture$w = gtex_ed_mixture$w[which(gtex_ed_mixture$w > tol)]
names(artificial_ed_mixture_50$U)
artificial_ed_mixture_50$w
names(gtex_ed_mixture$U)
gtex_ed_mixture$w
dat$artificial_mixture_50$ED = artificial_ed_mixture_50
dat$gtex_mixture$ED = gtex_ed_mixture
saveRDS(dat, '../data/prior_simulation.rds')