Last updated: 2020-11-24
Checks: 6 1
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.
The R Markdown file has unstaged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish
to commit the R Markdown file and build the HTML.
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 594a569. 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: .RData
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: analysis/.DS_Store
Ignored: analysis/11.24.2020.2.png
Ignored: analysis/11.24.2020.3.png
Ignored: analysis/11.24.2020.4.png
Ignored: analysis/11.24.2020.5.png
Ignored: analysis/11.24.2020.6.png
Ignored: analysis/11.24.2020.7.png
Ignored: analysis/11.24.2020.8.png
Ignored: analysis/11.24.2020.9.png
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
Unstaged changes:
Modified: analysis/prep.Rmd
Modified: analysis/susie.Rmd
Modified: analysis/varLD.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/varLD.Rmd
) and HTML (docs/varLD.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 | fc30af3 | mariesaitou | 2020-09-06 | Build site. |
html | f0b76bf | mariesaitou | 2020-08-31 | Build site. |
html | dc5d623 | mariesaitou | 2020-08-31 | Build site. |
html | 6ab347a | mariesaitou | 2020-08-31 | wflow_git_commit(all = T) |
html | 70f8755 | mariesaitou | 2020-08-31 | Build site. |
Rmd | f23aa21 | mariesaitou | 2020-08-31 | wflow_publish(c(“analysis/index.Rmd”, “analysis/correl.Rmd”, |
html | 147ba3e | mariesaitou | 2020-08-31 | Build site. |
Rmd | 47d5912 | mariesaitou | 2020-08-31 | wflow_publish(c(“analysis/index.Rmd”, “analysis/correl.Rmd”, |
html | b1b285d | mariesaitou | 2020-08-31 | Build site. |
Rmd | a74fad2 | mariesaitou | 2020-08-31 | wflow_publish(c(“analysis/index.Rmd”, “analysis/correl.Rmd”, |
html | 2ba9baf | mariesaitou | 2020-08-31 | Build site. |
Rmd | 2c33bd3 | mariesaitou | 2020-08-31 | wflow_publish(c(“analysis/index.Rmd”, “analysis/correl.Rmd”, |
html | 31bf3fa | mariesaitou | 2020-08-31 | Build site. |
html | d55436d | mariesaitou | 2020-08-31 | Build site. |
html | d81e9a3 | mariesaitou | 2020-08-31 | Build site. |
html | 7c2b7b4 | mariesaitou | 2020-08-31 | Build site. |
Rmd | c1e1ee0 | mariesaitou | 2020-08-31 | wflow_publish(c(“analysis/index.Rmd”, “analysis/correl.Rmd”, |
html | 898542f | mariesaitou | 2020-08-31 | Build site. |
html | 1c78096 | mariesaitou | 2020-08-31 | Build site. |
Rmd | 3662b4e | mariesaitou | 2020-08-31 | wflow_publish(c(“analysis/index.Rmd”, “analysis/correl.Rmd”, |
html | 3a2eead | mariesaitou | 2020-08-17 | Build site. |
Rmd | 8a5d7d1 | mariesaitou | 2020-08-17 | wflow_publish(c(“analysis/index.Rmd”, “analysis/correl.Rmd”, |
#######vcf to varLD genotype format
import pandas as pd
import numpy as np
pd.set_option('display.max_colwidth', 9999)
#### from all the genes
### files from csv list
genelist=pd.read_csv('/project2/xuanyao/marie/E-GEUV-1/finemap/finemapped.location.csv')
## for 0 to len(genelist)
genes=genelist.iloc[:,0]
dfYRI = []
for gene in genes:
df = pd.read_table(f'{gene}.Yoruba.genotype.recode.vcf',header=252)
df = df.replace('0|0', '1').replace('0|1', '2').replace('1|0', '2').replace('1|1', '3')
df = df.iloc[:, [2,1] + list(range(10, len(df.columns)))]
df.to_csv(f'{gene}.varLDgenotype.Yoruba.csv',index=0,header=False,sep="\t")
dfEUR = []
for gene in genes:
df = pd.read_table(f'{gene}.EUR.genotype.recode.vcf',header=252)
df = df.replace('0|0', '1').replace('0|1', '2').replace('1|0', '2').replace('1|1', '3')
df = df.iloc[:, [2,1] + list(range(10, len(df.columns)))]
df.to_csv(f'{gene}.varLDgenotype.EUR.csv',index=0,header=False,sep="\t")
############
csvfile=/project2/xuanyao/marie/E-GEUV-1/finemap/finemapped.location.csv
for line in `cat ${csvfile} | grep -v ^#`
do
gene=`echo ${line} |cut -d ',' -f 1`
java -jar rgenetics-1.0.jar -p VarLD /project2/xuanyao/marie/E-GEUV-1/finemap/YRI/${gene}.varLDgenotype.Yoruba.csv /project2/xuanyao/marie/E-GEUV-1/finemap/EUR/${gene}.varLDgenotype.EUR.csv -o varLD${gene}.txt
done
module load plink
plink --vcf ENSG00000267733.Yoruba.genotype.recode.vcf --r --matrix --out ENSG00000267733.Yoruba.LD.matrix
plink --vcf ENSG00000267733.Yoruba.genotype.recode.vcf --recode --out ENSG00000267733.Yoruba.ped
####### matix for trans-pop-finemapping analysis
setwd("/Users/saitoumarie/Dropbox/Chicago/RCC/eQTL.practice/LDSC/PESCA")
EURgeno<-read.table("ENSG00000160284.EUR.genotype.recode.vcf", header = FALSE, sep = "\t", skip = 252)
#head(EURgeno)
EURLD<-read.table("ENSG00000160284.EUR.LD.matrix.ld", header = FALSE, sep = " ")
#head(EURLD)
rownames(EURLD) <- EURgeno$V3
colnames(EURLD) <- EURgeno$V3
#####
YRIgeno<-read.table("ENSG00000160284.Yoruba.genotype.recode.vcf", header = FALSE, sep = "\t", skip = 252)
YRILD<-read.table("ENSG00000160284.Yoruba.LD.matrix.ld", header = FALSE, sep = " ")
rownames(YRILD) <- YRIgeno$V3
colnames(YRILD) <- YRIgeno$V3
###
EURz<-read.table("ENSG00000160284.zscore.EUR.txt", header = FALSE, sep = " ")
YRIz<-read.table("ENSG00000160284.zscore.Yoruba.txt", header = FALSE, sep = " ")
#(1) Extract the shared genes from EURLD and YRILD
#(2) Extract the shared genes of (1) from EURz and YRIz
#(3) make a new matrix by pasting EURgeno$V1, EURgeno$V2, EURgeno$V3, EURz$V5, YRIz$V5
#(4) make two new matrices by pasting EURgeno$V3, EURgeno$V2, (EURgeno$V4 and EURgeno$V5) , EURz$V5,
#(1) LD file
dat <- YRILD[!apply(is.na(YRILD), 1, all),]
YRILD2<-dat[ ,!apply(is.na(dat), 2, all) ]
dat1 <- EURLD[!apply(is.na(EURLD), 1, all),]
EURLD2<-dat1[,!apply(is.na(dat1), 2, all) ]
YRILD3 <- YRILD2[ intersect(names(YRILD2), names(EURLD2)),intersect(names(YRILD2), names(EURLD2))]
EURLD3 <- EURLD2[ intersect(names(YRILD2), names(EURLD2)),intersect(names(YRILD2), names(EURLD2))]
#(2) shared gene extraction
EURz2<-subset(EURz,EURz$V2 %in% intersect(names(YRILD2), names(EURLD2)))
YRIz2<-subset(YRIz,YRIz$V2 %in% intersect(names(YRILD2), names(EURLD2)))
#(3) PAINTOR z-score
EURgeno2<-subset(EURgeno,EURgeno$V3 %in% intersect(names(YRILD2), names(EURLD2)))
YRIgeno2<-subset(YRIgeno,YRIgeno$V3 %in% intersect(names(YRILD2), names(EURLD2)))
z.2pop<-data.frame(EURgeno2$V1, EURgeno2$V2, EURgeno2$V3, EURz2$V5, YRIz2$V5)
names(z.2pop) <- c("CHR","POS","RSID","ZSCORE.EUR","ZSCORE.YRI")
head(z.2pop)
plot(z.2pop$ZSCORE.EUR,z.2pop$ZSCORE.YRI)
hist(z.2pop$POS, breaks=20)
plot(z.2pop$POS,z.2pop$ZSCORE.EUR)
## output PAINTOR
write.table(z.2pop, file = "ENSG00000160284.Paintor.z.txt", sep = " ",quote=FALSE,
row.names = FALSE,col.names = TRUE)
write.table(EURLD3, file = "ENSG00000160284.EUR.LD", sep = " ",quote=FALSE,
row.names = FALSE,col.names = FALSE)
write.table(YRILD3, file = "ENSG00000160284.YRI.LD", sep = " ",quote=FALSE,
row.names = FALSE,col.names = FALSE)
write.table(anno, file = "ENSG00000160284.anno", sep = " ",quote=FALSE,
row.names = FALSE,col.names = TRUE)
#(4) PESCA z-score
# N= 358, 87
# SNP BP A2 A1 Z N
#(4) make two new matrices by pasting EURgeno$V3, EURgeno$V2, (EURgeno$V4 and EURgeno$V5) , EURz$V5,
# if EURz2$V5 < 0, take EURgeno2$V4. If EURz2$V5 >= 0, take EURgeno2$V5)
# A2: Effect allele (i.e. trait increasing allele) of the SNP. The sign of Z-score is with respect to this allele.
z.EUR.pesca<-data.frame(EURgeno2$V3, EURgeno2$V2, EURgeno2$V4, EURgeno2$V5, EURz2$V5)
z.EUR.pesca$V6<-c(358)
names(z.EUR.pesca) <- c("SNP","BP","A2","A1","Z","N")
#z.EUR.pesca<-data.frame(EURgeno2$V3, EURgeno2$V2, EURgeno2$V4 or EURgeno2$V5, EURz2$V5, abs(EURz2$V5))
### 8/6
z.EUR.pesca$V6 <- NA
z.EUR.pesca$V7 <- NA
for(i in 1:nrow(z.EUR.pesca)){
if (EURz2[i,5] < 0){
z.EUR.pesca$V6[i] <- EURgeno2[i,4]
z.EUR.pesca$V7[i] <- EURgeno2[i,5]
} else {
z.EUR.pesca$V6[i] <- EURgeno2[i,5]
z.EUR.pesca$V7[i] <- EURgeno2[i,4]
}
}
z.EUR.pesca2<-data.frame(z.EUR.pesca$SNP, z.EUR.pesca$BP, z.EUR.pesca$V6, z.EUR.pesca$V7, z.EUR.pesca$Z,z.EUR.pesca$N)
names(z.EUR.pesca2) <- c("SNP","BP","A2","A1","Z","N")
write.table(z.EUR.pesca2, file = "ENSG00000160284.PESCA.EUR.z.txt", sep = " ",quote=FALSE,
row.names = FALSE,col.names = TRUE)
write.table(z.YRI.pesca2, file = "ENSG00000160284.PESCA.YRI.z.txt", sep = " ",quote=FALSE,
row.names = FALSE,col.names = TRUE)
###
z.YRI.pesca<-data.frame(YRIgeno2$V3, YRIgeno2$V2, YRIgeno2$V4, YRIgeno2$V5, YRIz2$V5)
z.YRI.pesca$V6<-c(87)
names(z.YRI.pesca) <- c("SNP","BP","A2","A1","Z","N")
z.YRI.pesca$V6 <- NA
z.YRI.pesca$V7 <- NA
for(i in 1:nrow(z.YRI.pesca)){
if (YRIz2[i,5] < 0){
z.YRI.pesca$V6[i] <- YRIgeno2[i,4]
z.YRI.pesca$V7[i] <- YRIgeno2[i,5]
} else {
z.YRI.pesca$V6[i] <- YRIgeno2[i,5]
z.YRI.pesca$V7[i] <- YRIgeno2[i,4]
}
}
z.YRI.pesca2<-data.frame(z.YRI.pesca$SNP, z.YRI.pesca$BP, z.YRI.pesca$V6, z.YRI.pesca$V7, z.YRI.pesca$Z,z.YRI.pesca$N)
names(z.YRI.pesca2) <- c("SNP","BP","A2","A1","Z","N")
########### for
for(i in 1:nrow(z.EUR.pesca)){
if (EURz2[i,5] < 0){
EURz2$V6 <- EURgeno2[i,4]
EURz2$V7 <- EURgeno2[i,5]
} else {
EURz2$V6 <- EURgeno2[i,5]
EURz2$V7 <- EURgeno2[i,4]
}
}
############## ikkai
if (EURz2[1,5] < 0){
print(EURgeno2[1,4])
}else{
print(EURgeno2[1,5])
}
##############
matches <- list(c(2,1),c(5,2),c(6,3))
for (match in matches){
if (match[1] > match[2]){
print("Win")
} else {
print ("Lose")
}
}
i==1
answer[1,3]
z.EUR.pesca[1,3]
z.EUR.pesca[[i],3]
matches <- list(c(2,1),c(5,2),c(6,3))
for (match in matches){
if (match[1] > match[2]){
print("Win")
} else {
print ("Lose")
}
}
for(i in 1:nrow(z.EUR.pesca)){
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')
}
#(5) make a dummy annotation file (1 * SNP number)
anno<-data.frame(rep(1,length(EURgeno2$V1)))
names(anno) <- c("dummy")
module load boost/1.55
/home/maries1/pesca/src/pesca \
--mode fit \
--zscore1 input.EUR.z.ENSG00000160284.txt \
--zscore2 input.YRI.z.ENSG00000160284.txt \
--ld1 input.EUR.LD.ENSG00000160284.txt\
--ld2 input.YRI.LD.ENSG00000160284.txt \
--nburn 5000 \
--nsample 5000 \
--lambda 0.0001 \
--sigmasq1 105.89 \
--sigmasq2 44.75 \
--totnsnp 837 \
--max_iter 200 \
--out ENSG00000160284.PESCA.step1
./PAINTOR -input input.files.ENSG00000160284.txt -in -Zhead ZSCORE.EUR,ZSCORE.YRI -LDname EUR.LD,YRI.LD -in /ENSG00000160284/ -out /ENSG00000160284/ -enumerate 3 -annotations dummy
setwd("/project2/xuanyao/marie/E-GEUV-1/LDSC/PAINTOR_V3.0/")
genelist=read.csv("/project2/xuanyao/marie/E-GEUV-1/LDSC/PAINTOR_V3.0/susieR.gene.diff.csv", stringsAsFactors = F)
file <-paste("/project2/xuanyao/marie/E-GEUV-1/LDSC/PAINTOR_V3.0/files/",genelist[,"gene"], ".Paintor.results",sep="")
paintor<- lapply(file, FUN=read.table, header = TRUE, stringsAsFactors = F)
names(paintor) <- genelist[,"gene"]
# get list of posterior probabilities
posterior <- lapply(paintor, '[[',"Posterior_Prob")
# define functions for convenience
larger <- function(x,y){
x > y
}
getlist <- function(x,y){
x[y,]
}
put_name <- function(x,y){
if(nrow(x)!=0){
x['gene'] <- y
x
}
}
# subset elements with posterior probability > 0.95
result <- mapply(getlist, paintor, lapply(posterior,larger, 0.8), SIMPLIFY=F)
result <- mapply(put_name, result, names(result), SIMPLIFY = F) # put gene name in dataframe
#merge data frames
result.dataframe = data.frame()
for(i in 1:length(result)){
result.dataframe <- rbind(result.dataframe, result[[i]])
}
write.csv(result.dataframe, file = " Paintor.diffSNP.PIP80.csv")
Image Title
sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS 10.16
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.5 rstudioapi_0.11 whisker_0.4 knitr_1.30
[5] magrittr_1.5 R6_2.4.1 rlang_0.4.8 stringr_1.4.0
[9] tools_4.0.2 xfun_0.18 git2r_0.27.1 htmltools_0.5.0
[13] ellipsis_0.3.1 rprojroot_1.3-2 yaml_2.2.1 digest_0.6.27
[17] tibble_3.0.4 lifecycle_0.2.0 crayon_1.3.4 later_1.1.0.1
[21] vctrs_0.3.4 promises_1.1.1 fs_1.5.0 glue_1.4.2
[25] evaluate_0.14 rmarkdown_2.5 stringi_1.5.3 compiler_4.0.2
[29] pillar_1.4.6 backports_1.1.10 httpuv_1.5.4 pkgconfig_2.0.3