Last updated: 2020-08-30
Checks: 7 0
Knit directory: myproject/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). 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 job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20200813)
was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
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 6ab347a. 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: analysis/.DS_Store
Ignored: genotype/
Untracked files:
Untracked: ALL.chr1.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz
Untracked: ALL.chr2.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz
Untracked: getfastqtest2.csv
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/correl.Rmd
) and HTML (docs/correl.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 |
---|---|---|---|---|
html | 70f8755 | mariesaitou | 2020-08-30 | Build site. |
html | 147ba3e | mariesaitou | 2020-08-30 | Build site. |
html | b1b285d | mariesaitou | 2020-08-30 | Build site. |
html | 2ba9baf | mariesaitou | 2020-08-30 | Build site. |
html | 31bf3fa | mariesaitou | 2020-08-30 | Build site. |
html | d55436d | mariesaitou | 2020-08-30 | Build site. |
html | d81e9a3 | mariesaitou | 2020-08-30 | Build site. |
html | 7c2b7b4 | mariesaitou | 2020-08-30 | Build site. |
html | 898542f | mariesaitou | 2020-08-30 | Build site. |
html | 1c78096 | mariesaitou | 2020-08-30 | Build site. |
html | 3a2eead | mariesaitou | 2020-08-16 | Build site. |
Rmd | 8a5d7d1 | mariesaitou | 2020-08-16 | wflow_publish(c(“analysis/index.Rmd”, “analysis/correl.Rmd”, |
mashR
## install mashR on RCC
pip install --user sos
/project2/xuanyao/marie/E-GEUV-1/mashr
module load python/3.7.0
pip install --user sos sos-notebook
/home/maries1/.local/bin/sos run fastqtl_to_mash.ipynb -h
# Run fastQTL without filterin (see page1)
# Merge the fastQTL nominal outputs
# Separate the fastQTL output into gene categories
cat Yoruba.chr{1..22}.nominals.txt > Yoruba.auto.nominals.txt
cat EUR.chr{1..22}.nominals.txt > EUR.auto.nominals.txt
csvfile=susieR.gene.both.csv
for line in `cat ${csvfile} | grep -v ^#`
do
gene=`echo ${line} |cut -d ',' -f 1`
grep -w "${gene}" Yoruba.auto.nominals.txt >> Yoruba.both.nominals.txt
grep -w "${gene}" EUR.auto.nominals.txt >> EUR.both.nominals.txt
done
csvfile=susieR.gene.diff.csv
for line in `cat ${csvfile} | grep -v ^#`
do
gene=`echo ${line} |cut -d ',' -f 1`
grep -w "${gene}" Yoruba.auto.nominals.txt >> Yoruba.diff.nominals.txt
grep -w "${gene}" EUR.auto.nominals.txt >> EUR.diff.nominals.txt
done
csvfile=susieR.gene.YRI.csv
for line in `cat ${csvfile} | grep -v ^#`
do
gene=`echo ${line} |cut -d ',' -f 1`
grep -w "${gene}" Yoruba.auto.nominals.txt >> Yoruba.YRI.nominals.txt
grep -w "${gene}" EUR.auto.nominals.txt >> EUR.YRI.nominals.txt
done
csvfile=susieR.gene.EUR.csv
for line in `cat ${csvfile} | grep -v ^#`
do
gene=`echo ${line} |cut -d ',' -f 1`
grep -w "${gene}" Yoruba.auto.nominals.txt >> Yoruba.EUR.nominals.txt
grep -w "${gene}" EUR.auto.nominals.txt >> EUR.EUR.nominals.txt
done
Convert the fastQTL outout to mashR input format
sos run fastqtl_to_mash.ipynb --gene-list genes.both.txt --data-list both.file.txt --cols 5 4
run mashR (mean)
data <- readRDS("EUR.file.mash.rds")
data.temp = mash_set_data(data$random.b,data$random.s,zero_Shat_reset = 1)
Vhat = estimate_null_correlation_simple(data.temp)
rm(data.temp)
data.random = mash_set_data(data$random.b,data$random.s,V=Vhat,zero_Shat_reset = 1)
data.strong = mash_set_data(data$strong.b,data$strong.s, V=Vhat,zero_Shat_reset = 1)
U.pca = cov_pca(data.strong,2)
U.ed = cov_ed(data.strong, U.pca)
U.c = cov_canonical(data.random)
m = mash(data.random, Ulist = c(U.ed,U.c))
print(get_pairwise_sharing(m))
run mashR (SD)
get_pairwise_sharing1 = function(m, factor=0.5, lfsr_thresh=0.05, FUN= identity){
R = mashr:::get_ncond(m)
lfsr = get_lfsr(m)
S=matrix(NA,nrow = R, ncol=R)
SD=matrix(NA,nrow = R, ncol=R)
for(i in 1:R){
for(j in i:R){
sig_i=get_significant_results(m,thresh=lfsr_thresh,conditions = i)
sig_j=get_significant_results(m,thresh=lfsr_thresh,conditions = j)
a=union(sig_i,sig_j)
ratio=FUN(get_pm(m)[a,i])/FUN(get_pm(m)[a,j])##divide effect sizes
S[i,j]=mean(ratio>factor & ratio<(1/factor))
SD[i,j]=sd(ratio>factor & ratio<(1/factor))
}
}
S[lower.tri(S, diag = FALSE)] = t(S)[lower.tri(S, diag = FALSE)]
colnames(S) = row.names(S) = colnames(m$result$PosteriorMean)
SD[lower.tri(SD, diag = FALSE)] = t(SD)[lower.tri(SD, diag = FALSE)]
colnames(SD) = row.names(SD) = colnames(m$result$PosteriorMean)
return(list(S,SD))
}
Prapere phenotype (gene expression) files for GCTA
genelist=read.csv("LDSC/test3.location.csv", header=T,stringsAsFactors = F)
EUR = read.csv("EUR.TPM.scaled.csv", header=T,stringsAsFactors = F)
Yoruba = read.csv("Yoruba.TPM.scaled.csv", header=T,stringsAsFactors = F)
## extract genes from the gene expression list
for(i in 1:3){
grep(genelist[i,1],Yoruba )
}
Yorubalist<-Yoruba[Yoruba[,1]%in%genelist[,1],]
EURlist <- EUR[EUR[,1]%in%genelist[,1],]
comlist <- Yorubalist$X[Yorubalist$X%in% EURlist$gene]
setwd("/Users/saitoumarie/Dropbox/Chicago/RCC/eQTL.practice/LDSC/phen")
for(i in 1:length(comlist)){
hako <- data.frame(cbind(c(names(EURlist), names(Yorubalist)), c(names(EURlist), names(Yorubalist))))
hako$EUR <- c(as.numeric(EURlist[EURlist$gene==comlist[i],]), rep(NA, length(Yorubalist)))
hako$Yoruba <- c(rep(NA, length(EURlist)), as.numeric(Yorubalist[Yorubalist$X==comlist[i],]))
hako<-subset(hako,hako$X1!="gene")
hako<-subset(hako,hako$X1!="X")
colnames(hako) <- c('ID', 'ID', 'EUR', 'Yoruba')
# write.csv(hako, comlist[i])
write.table(hako, file = paste(comlist[i], ".pre"), sep = "\t", row.names = FALSE,
col.names = FALSE,quote=FALSE)
}
run GCTA
export PATH="$PATH:/home/maries1/gcta_1.93.2beta"
#./gcta64
csvfile=finemapped.location.csv
for line in `cat ${csvfile} | grep -v ^#`
do
gene=`echo ${line} | cut -d ',' -f 1`
gcta64 --bfile ${gene}.EandY --autosome --make-grm --out ${gene}
gcta64 --reml-bivar --grm ${gene} --pheno phen/${gene}.phen --out result/${gene}
done
csvfile=finemapped.location.csv
for line in `cat ${csvfile} | grep -v ^#`
do
gene=`echo ${line} | cut -d ',' -f 1`
grep 'V(G)/Vp_tr1' result/${gene}.hsq >> result/trait1.EUR.txt
grep 'V(G)/Vp_tr2' result/${gene}.hsq >> result/trait2.Yoruba.txt
grep 'rG' result/${gene}.hsq >> result/rG.txt
done
csvfile=finemapped.location.csv
for line in `cat ${csvfile} | grep -v ^#`
do
gene=`echo ${line} | cut -d ',' -f 1`
ls result/${gene}.hsq >> list.txt
done
sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.6
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] workflowr_1.6.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.4.6 rprojroot_1.3-2 digest_0.6.25 later_1.1.0.1
[5] R6_2.4.1 backports_1.1.8 git2r_0.27.1 magrittr_1.5
[9] evaluate_0.14 stringi_1.4.6 rlang_0.4.7 fs_1.4.1
[13] promises_1.1.1 whisker_0.4 rmarkdown_2.3 tools_4.0.0
[17] stringr_1.4.0 glue_1.4.1 httpuv_1.5.4 xfun_0.14
[21] yaml_2.2.1 compiler_4.0.0 htmltools_0.4.0 knitr_1.28