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 47d5912. 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/prep.Rmd
) and HTML (docs/prep.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 | 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”, |
The master working directory on UChicago RCC
cd /project2/xuanyao/marie/E-GEUV-1
# 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/
cat getfastq.csv | awk 'NR==21,NR==90' > getfastqtest2.csv
csvfile=getfastqtest2.csv
for line in `cat ${csvfile} | grep -v ^#`
do
url=`echo ${line} | cut -d ',' -f 2`
file=`echo ${line} | cut -d ',' -f 4`
wget ${url} -O fastq2/${file}.fastq.gz
done
Download the genotype dataset from the 1000 Genomes project phase 3
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
Kallisto - make index files
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=sample.filelist.csv
for line in `cat ${csvfile} | grep -v ^#`
do
file=`echo ${line} | cut -d ',' -f 5`
kallisto quant -i human.GRCh37.cdna.all.idx -o kallisto/${file}.kallistoOut -n 100 -t 32 fastq/${file}.1.fastq fastq/${file}.2.fastq
done
# summarize TPM (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$abundance,sep="\t", file = "EUR.TPM.tsv")
# add gene annotations to the TPM file
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 = "British.gene.TPM.csv")
# keep the 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 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
# 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 <- rowsume(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")
preparation
# 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.Yoruba.0.01.biallelic.recode.vcf.gz --bed GEUV/Yoruba.gene.TPM.sorted.bed.gz --region $i:1-249250621 --threshold 0.01 --out GEUV/Yoruba.chr$i.nominals.0.01.txt --cov GEUV/Yoruba.cov.txt --normal
done
cat Yoruba.chr*.nominals.0.01.txt > Yoruba.auto.nominals.0.01.txt
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")
Manhattan plot example
x<-read.csv("YRI.EUR.DEG.for.manhattan.csv", header = TRUE)
x<- x[order(x$Chromosome),]
nCHR <- length(unique(x$Chromosome))
x$BPcum <- NA
s <- 0
nbp <- c()
for (i in unique(x$Chromosome)){
nbp[i] <- max(x[x$Chromosome == i,]$start)
x[x$Chromosome == i,"BPcum"] <- x[x$Chromosome == i,"start"] + s
s <- s + nbp[i]
}
axis.set <- x %>%
group_by(Chromosome) %>%
summarize(center = (max(BPcum) + min(BPcum)) / 2)
x1 <- subset (x, -log10(padj)>40 )
manhplot <- ggplot(x, aes(x = BPcum, y = sign(log2FoldChange)*(-log10(padj)),
color = as.factor(Chromosome))) +
geom_point(alpha = 0.85) +
scale_x_continuous(label = axis.set$Chromosome, breaks = axis.set$center) +
scale_color_manual(values = rep(c("gray", "black"), nCHR)) +
scale_size_continuous(range = c(0.5,3)) +
theme_minimal() +theme_bw(base_size = 12)+
theme(
legend.position = "none",
panel.border = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
axis.text.x = element_text(angle = 90, size = 8, vjust = 0.5)
)+geom_label_repel(data=x1,aes(label = gene.name), color = 'blue',
size = 3)
# GTEx comparison
# GTEx.Cells_EBV-transformed_lymphocytes.v8.egenes.txt
# GTEx_Analysis_2017-06-05_v8_RNASeQCv1.1.9_gene_median_tpm.gct
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