Last updated: 2024-09-21
Checks: 7 0
Knit directory: cross_ancestory_LCL/
This reproducible R Markdown analysis was created with workflowr (version 1.7.1). 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 20c4949. 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/.RData
Ignored: analysis/.Rhistory
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: analysis/1.21.WIP.Rmd
Untracked: analysis/12.WIP.Rmd
Untracked: analysis/first-analysis.Rmd alias
Untracked: getfastqtest2.csv
Unstaged changes:
Modified: analysis/correl.Rmd
Modified: analysis/manuscript2.Rmd
Modified: analysis/manuscript3.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/manuscript1.Rmd
) and HTML
(docs/manuscript1.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 | 20c4949 | mariesaitou | 2024-09-21 | workflowr::wflow_publish("analysis/manuscript1.Rmd") |
html | 9474f66 | mariesaitou | 2022-04-11 | Build site. |
Rmd | c6a488f | mariesaitou | 2022-04-11 | Update the files for myproject |
html | d23b1be | mariesaitou | 2021-07-02 | Build site. |
html | 64421f6 | mariesaitou | 2021-07-02 | Build site. |
html | d2e1bc0 | mariesaitou | 2021-07-02 | Build site. |
html | 2abb7f5 | mariesaitou | 2021-07-02 | Build site. |
Rmd | 90217b9 | mariesaitou | 2021-07-02 | Publish the files for myproject |
mkdir genotype
wget ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/release/20130502/ALL.chr{1..22}.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz
# keep the 455 individuals who are reported in both the 1000 Genome Project and Geuvadis
module load vcftools
for i in `seq 1 22`
do
vcftools --gzvcf /genotype/phase3/ALL.chr$i.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz --keep 1000g.ind.sample.txt --recode --out /genotype/phase3/chr$i.1000gphase3.455
done
# exclude rare (less than 0.01 frequency) variants
vcftools --vcf /genotype/phase3/chr$i.1000gphase3.455.recode.vcf --maf 0.01 --max-maf 0.99 --recode --out /genotype/phase3/chr$i.1000gphase3.455.0.01
# keep only bi-allelic variants
vcftools --vcf /genotype/phase3/chr$i.1000gphase3.455.0.01.recode.vcf --min-alleles 2 --max-alleles 2 --recode --out /genotype/phase3/chr$i.1000gphase3.455.0.01.biallelic
Identify covariates (genetic and non-genetic)
# Convert vcf file to plink format
plink --vcf chr22.1000gphase3.455.0.01.recode.vcf --make-bed --out chr22.1000gphase3.455.0.01.recode.bed
# Run pca
plink --bfile chr22.1000gphase3.455.0.01.recode.bed --pca --out
# Plot pca
library(ggplot2)
ggplot(data=pca, aes(V3,V4)) + geom_point()
# Download the fastq dataset from the Geuvadis project
# sample information https://www.ebi.ac.uk/arrayexpress/files/E-GEUV-1/
# fastq files ftp://ftp.sra.ebi.ac.uk/vol1/fastq/
csvfile=getfastq.csv
for line in `cat ${csvfile} | grep -v ^#`
do
url=`echo ${line} | cut -d ',' -f 2`
wget ${url}
done
#FastQC - quality check
module load fastqc
fastqc *.fastq.gz -o /fastqc_out/
module load multiqc
multiqc . -f
#Kallisto - make index files - pseudomapping
module load kallisto
wget ftp://ftp.ensembl.org/pub/grch37/current/fasta/homo_sapiens/cdna/Homo_sapiens.GRCh37.cdna.all.fa.gz
gunzip Homo_sapiens.GRCh37.cdna.all.fa.gz
kallisto index -i human.GRCh37.cdna.all.idx Homo_sapiens.GRCh37.cdna.all.fa
wget https://github.com/pachterlab/kallisto-transcriptome-indices/releases/download/ensembl-96/homo_sapiens.tar.gz
gunzip Homo_sapiens
# homo_sapiens/transcriptome.idx
# Gene expression quantification for all samples with Kallisto
module load kallisto
csvfile=1000g.sample.csv
for line in `cat ${csvfile} | grep -v ^#`
do
file=`echo ${line} | cut -d ',' -f 1`
kallisto quant -i human.GRCh37.cdna.all.idx -o kallisto/${file}.kallisto -n 100 -t 32 fastq2/${file}.1.fastq.gz fastq2/${file}.2.fastq.gz
done
library(tximport)
library(biomaRt)
update.packages()
install.packages("rlang")
## convert transcripts into genes
mart <- useDataset("hsapiens_gene_ensembl", useMart("ensembl", host="grch37.ensembl.org"))
df <- read.table("kallisto/HG00096.kallisto/abundance.tsv", header = TRUE,sep = "\t")
genes <- df$target_id
G_list <- getBM(filters= "ensembl_transcript_id_version", attributes=c('ensembl_transcript_id_version','ensembl_gene_id'),mart= mart,values=genes)
head(G_list)
write.csv(G_list, file = "transcripts.to.genes2.csv", append = FALSE, quote = FALSE, sep = ",",
eol = "\n", na = "NA", dec = ".", row.names = FALSE,
col.names = FALSE, qmethod = "double",
fileEncoding = "")
# summarize (gene expression) data from each individual
samples <-read.csv("1000g.EUR.sample.csv",header=TRUE)
files <- file.path(dir, "kallisto", samples$kallisto, "abundance.tsv")
names(files) <- paste0(samples$X)
all(file.exists(files))
txi <- tximport(files, type = "kallisto", tx2gene = tx2gene, txOut = FALSE, ignoreAfterBar = TRUE)
write.table(txi$est_counts,sep="\t", file = "EUR.counts.tsv")
write.table(txi$tpm,sep="\t", file = "EUR.TPM.tsv")
library('biomaRt')
mart <- useDataset("hsapiens_gene_ensembl", useMart("ensembl", host="grch37.ensembl.org"))
df <- read.csv(file.choose(), header = T, sep = ",")
gene <- df$gene
G_list <- getBM(filters= "ensembl_gene_id", attributes=c('ensembl_gene_id', 'hgnc_symbol','description','chromosome_name','start_position','end_position'),mart= mart,values=gene)
G_list2<-merge(df,G_list,by.x="gene",by.y="ensembl_gene_id",all.x=T)
write.csv(G_list2, file = "EUR.gene.TPM.csv")
## only genes with CPM (counts per million)>0.5 in more than half of the total samples
## are kept for further analysis to avoid false positives in the eQTL
d1 <- read.table("EUR.counts.tsv", header = T,row.names=1,sep = "\t")
d1_scaled <- apply(d1, 2, function(x){x/sum(x)*1000000})
d1_cleaned<-d1_scaled[rowSums(d1_scaled > 0.5) > length(d1[1,])/2, ]
write.csv(d1_cleaned, file = "EUR.CPM.survived.csv")
matall<-read.table(file = 'Yoruba.TPM.filtered.tsv', sep = '\t', header = T,row.names=1)
matall<-as.matrix(matall,row.names=1,header=T)
head(matall)
matfilter <- matall[rowSums(matall) > 90,]
hist(mat[,1])
hist(mat[1,],breaks=20)
mat<-normalize.quantiles(matfilter)
mat<-scale (mat)
tmat<-t(mat)
stmat<-scale (tmat)
mat1<-t(stmat)
head(mat1)
hist(mat1[,1])
hist(mat1[1,],breaks=40)
class(mat)
colnames(mat)<-matal
write.csv(mat1, file = "Yoruba.TPM.scaled.csv")
# Convert vcf file to plink format
plink --vcf chr22.1000gphase3.455.0.01.recode.vcf --make-bed --out chr22.1000gphase3.455.0.01.recode.bed
# Run pca
plink --bfile chr22.1000gphase3.455.0.01.recode.bed --pca --out
# Plot pca
library(ggplot2)
ggplot(data=pca, aes(V3,V4)) + geom_point()
# surrogate variable analysis
library(sva)
mm <- model.matrix(~ population, colData(ddsTxi))
mm0 <- model.matrix(~ 1, colData(ddsTxi))
norm.cts <- norm.cts[rowSums(norm.cts) > 10,]
fit <- svaseq(norm.cts, mod=mm, mod0=mm0)
# 50 SVs are found. I use 7 SVs
sva7 = sva(norm.cts , mm, mm0, n.sv=7)
write.csv(sva7$sv[,1:7], file = "sva7.csv")
library("DESeq2")
colData <-read.csv("1000g.sample.csv",header = T,row.names=1)
class(colData$date)
colData$date1<-factor(colData$date)
ddsTxi <- DESeqDataSetFromTximport(txi,
colData = colData,
design = ~ sex+population+performer)
colData <-read.csv("1000g.EUR.YRI.csv",header = T,row.names=1)
ddsEurYri <- DESeqDataSetFromTximport(txi,
colData = colData,
design = ~ sex+population+V1+V2+V3+V4+V5+V6+V7)
keep <- rowsum(counds(ddsEurYri)) >=455
ddsEurYri <- ddsEurYri[keep,]
ddsEY<-DESeq(ddsEurYri)
deg <- results(ddsEY, contrast=c("population","EUR","Yoruba"))
write.csv(deg, file = "E-GEUV_EUR_Yoruba.csv")
# prepare input bed.gz and index files
module load bedtools
bedtools sort -i British.gene.TPM.bed -header > British.gene.TPM.sorted.bed
bgzip British.gene.TPM.sorted.bed && tabix -p bed British.gene.TPM.sorted.bed.gz
# prepare input vcf.gz and index files
module load htslib
module load tabix
for i in `seq 1 22`
do
bgzip genotype/phase3/chr$i.1000gphase3.Yoruba.0.01.biallelic.recode.vcf && tabix -p vcf genotype/phase3/chr$i.1000gphase3.Yoruba.0.01.biallelic.recode.vcf.gz
done
for i in `seq 1 22`
do
bgzip genotype/phase3/chr$i.1000gphase3.EUR.0.01.biallelic.recode.vcf && tabix -p vcf genotype/phase3/chr$i.1000gphase3.EUR.0.01.biallelic.recode.vcf.gz
done
# run fastQTL
## https://github.com/francois-a/fastqtl
for i in `seq 1 22`
do
./bin/fastQTL.static fastQTL --vcf /project2/xuanyao/marie/E-GEUV-1/genotype/phase3/chr$i.1000gphase3.EUR.0.01.biallelic.recode.vcf.gz --bed GEUV/EUR.gene.TPM.sorted.bed.gz --region $i:1-249250621 --threshold 0.001 --permute 1000 --out GEUV/EUR.chr$i.permute.0.001.txt --cov GEUV/EUR.cov.txt --normal
done
for i in `seq 1 22`
do
./bin/fastQTL.static fastQTL --vcf /project2/xuanyao/marie/E-GEUV-1/genotype/phase3/chr$i.1000gphase3.Yoruba.0.01.biallelic.recode.vcf.gz --bed GEUV/Yoruba.gene.TPM.sorted.bed.gz --region $i:1-249250621 --threshold 0.001 --permute 1000 --out GEUV/Yoruba.chr$i.permute.0.001.txt --cov GEUV/Yoruba.cov.txt --normal
done
setwd("/project2/xuanyao/marie/E-GEUV-1")
library(ggplot2)
library("ggrepel")
library("plyr")
library(gplots)
library(reshape2)
## remove multi-allelic SNPs reported as bi-allelic SNPs which confuse the result
EUR1<-subset(EUR2,
EUR2$gene.SNP!="ENSG00000188659.rs542232278"&
EUR2$gene.SNP!="ENSG00000255769.rs145926341"&
EUR2$gene.SNP!="ENSG00000255769.rs371891811"&
EUR2$gene.SNP!="ENSG00000259328.rs145926341"&
EUR2$gene.SNP!="ENSG00000259323.rs145926341"&
EUR2$gene.SNP!="ENSG00000259472.rs145926341"&
EUR2$gene.SNP!="ENSG00000103942.rs1610794"&
EUR2$gene.SNP!="ENSG00000103342.rs140839133"&
EUR2$gene.SNP!="ENSG00000159202.rs77094622"&
EUR2$gene.SNP!="ENSG00000189050.rs112549034"&
EUR2$gene.SNP!="ENSG00000108592.rs138776605"&
EUR2$gene.SNP!="ENSG00000256771.rs10650867"&
EUR2$gene.SNP!="ENSG00000134330.rs139337028"&
EUR2$gene.SNP!="ENSG00000125991.rs139252705"&
EUR2$gene.SNP!="ENSG00000214078.rs142898689"&
EUR2$gene.SNP!="ENSG00000087586.rs5842156"&
EUR2$gene.SNP!="ENSG00000171522.rs139036988"&
EUR2$gene.SNP!="ENSG00000196284.rs112143344"&
EUR2$gene.SNP!="ENSG00000135316.rs71553453"&
EUR2$gene.SNP!="ENSG00000232559.rs377632592"&
EUR2$gene.SNP!="ENSG00000131558.rs141161799"&
EUR2$gene.SNP!="ENSG00000162441.rs36126617"&
EUR2$gene.SNP!="ENSG00000162441.rs151178549"&
EUR2$gene.SNP!="ENSG00000142794.rs35506192"&
EUR2$gene.SNP!="ENSG00000142794.rs145038894"&
EUR2$gene.SNP!="ENSG00000116128.rs10657777"&
EUR2$gene.SNP!="ENSG00000117280.rs149256505"&
EUR2$gene.SNP!="ENSG00000107719.rs138584752"&
EUR2$gene.SNP!="ENSG00000198561.rs142865693"&
EUR2$gene.SNP!="ENSG00000087365.rs5792377"&
EUR2$gene.SNP!="ENSG00000162341.rs111786372"&
EUR2$gene.SNP!="ENSG00000110092.rs59333593"&
EUR2$gene.SNP!="ENSG00000111215.rs61604574"&
EUR2$gene.SNP!="ENSG00000165502.rs141634854"&
EUR2$gene.SNP!="ENSG00000104093.rs138911097")
YRI1<-subset(YRI2, YRI2$gene.SNP!="ENSG00000143106.rs545041240"&
YRI2$gene.SNP!="ENSG00000078403.rs528760884"&
YRI2$gene.SNP!="ENSG00000167996.rs150035626"&
YRI2$gene.SNP!="ENSG00000111252.rs367797687"&
YRI2$gene.SNP!="ENSG00000172458.rs112879834"&
YRI2$gene.SNP!="ENSG00000183044.rs367630500"&
YRI2$gene.SNP!="ENSG00000154874.rs138555657"&
YRI2$gene.SNP!="ENSG00000011132.rs71166969"&
YRI2$gene.SNP!="ENSG00000125991.rs142898689"&
YRI2$gene.SNP!="ENSG00000198832.rs35065681"&
YRI2$gene.SNP!="ENSG00000128268.rs142897975"&
YRI2$gene.SNP!="ENSG00000161013.rs71591436"&
YRI2$gene.SNP!="ENSG00000170727.rs60257564")
sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.6.1
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: Europe/Oslo
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] workflowr_1.7.1
loaded via a namespace (and not attached):
[1] vctrs_0.6.5 httr_1.4.7 cli_3.6.2 knitr_1.45
[5] rlang_1.1.3 xfun_0.42 stringi_1.8.3 processx_3.8.3
[9] promises_1.3.0 jsonlite_1.8.8 glue_1.7.0 rprojroot_2.0.4
[13] git2r_0.33.0 htmltools_0.5.7 httpuv_1.6.15 ps_1.7.6
[17] sass_0.4.8 fansi_1.0.6 rmarkdown_2.26 jquerylib_0.1.4
[21] tibble_3.2.1 evaluate_0.23 fastmap_1.1.1 yaml_2.3.8
[25] lifecycle_1.0.4 whisker_0.4.1 stringr_1.5.1 compiler_4.3.1
[29] fs_1.6.3 pkgconfig_2.0.3 Rcpp_1.0.12 rstudioapi_0.15.0
[33] later_1.3.2 digest_0.6.34 R6_2.5.1 utf8_1.2.4
[37] pillar_1.9.0 callr_3.7.5 magrittr_2.0.3 bslib_0.6.1
[41] tools_4.3.1 cachem_1.0.8 getPass_0.2-4