-
Notifications
You must be signed in to change notification settings - Fork 2
/
.Rhistory
53 lines (53 loc) · 2.87 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
library(flashfm)
# two traits were simulated with two causal variants each, of which one is shared; covariance between traits is 0.4
# causal variants are in the cvs vector within flashfm
# trait 1 has cvs[1:2], trait 2 has cvs[-2]
# PREPARE SINGLE-TRAIT FINE-MAPPING RESULTS FOR FLASHFM
# beta and FMconfig are each a list of two components provided in the flashfm package;
# beta[[i]] (i=1,2) is a vector of GWAS single-SNP effect estimates for each trait, at each SNP
# FMconfig[[i]] (i=1,2) is a data.frame of the contents of the *.config file from single-trait fine-mapping for trait i using FINEMAP
# create a list modPP.list with only the SNP models and their PPs from single-trait fine-mapping for each trait
modPP.list <- vector("list",2)
for(i in 1:2) {modPP.list[[i]] <- data.frame(FMconfig[[i]][,c("config","prob")]); colnames(modPP.list[[i]]) <- c("snps","PP")}
names(modPP.list) <- names(beta)
lapply(modPP.list,head)
# REFERENCE PANEL INPUT FOR FLASHFM
# raf is a named vector of SNP reference allele frequencies filtered on MAF 0.005
msnps <- names(raf) # ids of SNPs filtered on maf 0.005
covX = cov(X[,msnps]) # genotype covariance matrix for SNPs with MAF > 0.005
# PRE-FLASHFM PROCESSING
# N is a vector of sample size for each trait; if related samples then N is effective sample size (use Neff function for each trait)
# ybar is a vector of mean trait values
# related=FALSE since unrelated individuals in sample
# is.snpmat=FALSE since this example uses the genotype covariance matrix and raf; set to TRUE if use genotype matrix and set Gmat=X
FMmain.input <- flashfm.input(modPP.list,beta1.list=beta,Gmat=covX,Nall=N,ybar.all=ybar,related=FALSE,is.snpmat=FALSE,raf=raf)
# Xmat=FALSE since this example uses the genotype covariance matrix and raf; set to TRUE if use genotype matrix
ss.stats <- summaryStats(Xmat=FALSE,ybar.all=ybar,main.input=FMmain.input)
# RUN FLASHFM
# covY is trait covariance matrix
# TOdds=1 is default and gives a 50/50 prior that traits do not share a causal variant vs sharing a causal variant
fm.multi <- flashfm(FMmain.input, TOdds=1,covY,ss.stats)
# CONSTRUCT SNP GROUPS BASED ON EACH METHOD
snpGroups <- makeSNPgroups2(FMmain.input,fm.multi,is.snpmat=FALSE,r2.minmerge=0.7)
# SUMMARISE FINE-MAPPING RESULTS
mpp.pp <- PPsummarise(fm.multi, snpGroups, minPP=0.05)
# CHECK IF CAUSAL VARIANTS BELONG TO SNP GROUPS CONSTRUCTED BY FINEMAP
flashfm:::groupIDs.fn(snpGroups[[1]],cvs)
# CHECK IF CAUSAL VARIANTS BELONG TO SNP GROUPS CONSTRUCTED BY FLASHFM
flashfm:::groupIDs.fn(snpGroups[[2]],cvs)
# CHECK WHAT TOP SNP GROUP MODELS ARE AND IF THEY INCLUDE SNP GROUPS THAT CONTAIN CAUSAL VARIANTS
mpp.pp$PPg
#CHECK SNP GROUP SIZES FROM EACH METHOD
snpGroups$group.sizes
setwd("~/Rpackages/flashfm")
library(devtools)
document()
check()
build()
build_vignettes()
pkgdown::build_articles()
install_github("jennasimit/flashfm")
library(flashfm)
pkgdown::clean_site()
pkgdown::build_site()
q()