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 f23aa21. 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

Unstaged changes:
    Deleted:    analysis/paintor.822.test.pdf

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
Rmd f23aa21 mariesaitou 2020-08-30 wflow_publish(c(“analysis/index.Rmd”, “analysis/correl.Rmd”,
html 147ba3e mariesaitou 2020-08-30 Build site.
Rmd 47d5912 mariesaitou 2020-08-30 wflow_publish(c(“analysis/index.Rmd”, “analysis/correl.Rmd”,
html b1b285d mariesaitou 2020-08-30 Build site.
Rmd a74fad2 mariesaitou 2020-08-30 wflow_publish(c(“analysis/index.Rmd”, “analysis/correl.Rmd”,
html 2ba9baf mariesaitou 2020-08-30 Build site.
Rmd 2c33bd3 mariesaitou 2020-08-30 wflow_publish(c(“analysis/index.Rmd”, “analysis/correl.Rmd”,
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.
Rmd c1e1ee0 mariesaitou 2020-08-30 wflow_publish(c(“analysis/index.Rmd”, “analysis/correl.Rmd”,
html 898542f mariesaitou 2020-08-30 Build site.
html 1c78096 mariesaitou 2020-08-30 Build site.
Rmd 3662b4e mariesaitou 2020-08-30 wflow_publish(c(“analysis/index.Rmd”, “analysis/correl.Rmd”,
html 3a2eead mariesaitou 2020-08-16 Build site.
Rmd 8a5d7d1 mariesaitou 2020-08-16 wflow_publish(c(“analysis/index.Rmd”, “analysis/correl.Rmd”,

varLD input file preparation

#######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")
############

run varLD

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

make LD matrix for one gene


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

PESCA and PAINTOR preparation - ongoing and for one gene; Aug 2020-

####### 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")

run PESCA

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

run PAINTOR

./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

results

Image Title


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