-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added metabrain analysis and pleiotropy qc
- Loading branch information
Cath
committed
May 24, 2021
1 parent
9173b3a
commit 22337e4
Showing
25 changed files
with
801 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
|
||
|
||
library("dplyr") | ||
library("readr") | ||
library("biomaRt") | ||
|
||
# load druggable genome | ||
|
||
druggable <- read_tsv("druggable_genome_new.txt", col_types=cols(.default="c")) | ||
|
||
|
||
# load basal ganglia data | ||
|
||
bg <- read_csv("eqtl_data_metabrain/metabrain_basalganglia_eur.csv", col_types=cols(.default="c")) | ||
bg$new_gene_id <- gsub("\\..*","", bg$Gene) | ||
|
||
bg <- subset(bg, bg$new_gene_id %in% druggable$gene_stable_id) | ||
|
||
|
||
bg$rsid <- gsub(".*:rs", "rs",bg$`SNP Name`) | ||
bg$rsid <- gsub("\\:.*", "",bg$rsid) | ||
|
||
bg$beta <- gsub("\\ .*", "",bg$`Meta-analysis Beta (s.e.)`) | ||
bg$se <- gsub(".*\\(", "",bg$`Meta-analysis Beta (s.e.)`) | ||
bg$se <- gsub(")", "",bg$se) | ||
|
||
names(bg) <- gsub(" ", "_", names(bg)) | ||
|
||
|
||
# find gene start and end positions #grch38 | ||
biolist <- as.data.frame(listMarts()) | ||
ensembl=useMart("ensembl") | ||
esemblist <- as.data.frame(listDatasets(ensembl)) | ||
ensembl = useDataset("hsapiens_gene_ensembl",mart=ensembl) | ||
filters = listFilters(ensembl) | ||
attributes = listAttributes(ensembl) | ||
|
||
t2g<-getBM(attributes=c('ensembl_gene_id',"ensembl_gene_id_version",'chromosome_name','start_position','end_position'), mart = ensembl) | ||
|
||
my_ids <- data.frame(ensembl_gene_id_version=bg$Gene) | ||
my_ids$ensembl_gene_id <- gsub("\\..*","", my_ids$ensembl_gene_id_version) | ||
|
||
my_ids.version <- merge(my_ids, t2g, by= 'ensembl_gene_id') | ||
|
||
bg_with_gene_pos <- left_join(bg, my_ids.version[,3:6], by = c("Gene"="ensembl_gene_id_version.y")) | ||
|
||
bg_with_gene_pos <- bg_with_gene_pos[!is.na(bg_with_gene_pos$start_position),] | ||
|
||
|
||
|
||
# keep 5kb window around the gene | ||
|
||
if (all(bg_with_gene_pos$SNP_Chromosome == bg_with_gene_pos$Gene_Chromosome)) { | ||
bg_with_gene_pos_cis <- bg_with_gene_pos | ||
} else { | ||
bg_with_gene_pos_cis <- bg_with_gene_pos[which(bg_with_gene_pos$SNP_Chromosome == bg_with_gene_pos$Gene_Chromosome),] | ||
} | ||
|
||
bg_with_gene_pos_cis$SNP_Chromosome_Position <- as.numeric(bg_with_gene_pos_cis$SNP_Chromosome_Position) | ||
|
||
bg_5kb_window <- bg_with_gene_pos_cis[which( | ||
bg_with_gene_pos_cis$SNP_Chromosome_Position >= (bg_with_gene_pos_cis$start_position-5000) & | ||
bg_with_gene_pos_cis$SNP_Chromosome_Position <= (bg_with_gene_pos_cis$end_position+5000) | ||
),] | ||
|
||
|
||
bg_5kb_window <- tidyr::separate(bg_5kb_window, | ||
col="SNP_Alleles", | ||
"into"=c("allele1","allele2"), | ||
sep="/" | ||
) | ||
bg_5kb_window$other_allele <- NA | ||
bg_5kb_window$other_allele[which(bg_5kb_window$allele1==bg_5kb_window$Effect_Allele)] <- bg_5kb_window$allele2[which(bg_5kb_window$allele1==bg_5kb_window$Effect_Allele)] | ||
bg_5kb_window$other_allele[which(bg_5kb_window$allele2==bg_5kb_window$Effect_Allele)] <- bg_5kb_window$allele1[which(bg_5kb_window$allele2==bg_5kb_window$Effect_Allele)] | ||
|
||
write.table(bg_5kb_window, "eqtl_data_metabrain/metabrain_basalganglia_eur_exposure_dat_snps_5kb_window.txt", sep = "\t", row.names = F, quote = F) | ||
|
||
|
||
print("mission complete") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
|
||
|
||
library("dplyr") | ||
library("readr") | ||
library("biomaRt") | ||
|
||
|
||
# load druggable genome | ||
|
||
druggable <- read_tsv("druggable_genome_new.txt", col_types=cols(.default="c")) | ||
|
||
|
||
# load cortex data | ||
|
||
cortex <- read_csv("eqtl_data_metabrain/metabrain_cortex_eur.csv", col_types=cols(.default="c")) | ||
cortex$new_gene_id <- gsub("\\..*","", cortex$Gene) | ||
|
||
cortex <- subset(cortex, cortex$new_gene_id %in% druggable$gene_stable_id) | ||
|
||
|
||
cortex$rsid <- gsub(".*:rs", "rs",cortex$`SNP Name`) | ||
cortex$rsid <- gsub("\\:.*", "",cortex$rsid) | ||
|
||
cortex$beta <- gsub("\\ .*", "",cortex$`Meta-analysis Beta (s.e.)`) | ||
cortex$se <- gsub(".*\\(", "",cortex$`Meta-analysis Beta (s.e.)`) | ||
cortex$se <- gsub(")", "",cortex$se) | ||
|
||
names(cortex) <- gsub(" ", "_", names(cortex)) | ||
|
||
|
||
# find gene start and end positions #grch38 | ||
biolist <- as.data.frame(listMarts()) | ||
ensembl=useMart("ensembl") | ||
esemblist <- as.data.frame(listDatasets(ensembl)) | ||
ensembl = useDataset("hsapiens_gene_ensembl",mart=ensembl) | ||
filters = listFilters(ensembl) | ||
attributes = listAttributes(ensembl) | ||
|
||
t2g<-getBM(attributes=c('ensembl_gene_id',"ensembl_gene_id_version",'chromosome_name','start_position','end_position'), mart = ensembl) | ||
|
||
my_ids <- data.frame(ensembl_gene_id_version=cortex$Gene) | ||
my_ids$ensembl_gene_id <- gsub("\\..*","", my_ids$ensembl_gene_id_version) | ||
|
||
my_ids.version <- merge(my_ids, t2g, by= 'ensembl_gene_id') | ||
|
||
cortex_with_gene_pos <- left_join(cortex, my_ids.version[,3:6], by = c("Gene"="ensembl_gene_id_version.y")) | ||
|
||
cortex_with_gene_pos <- cortex_with_gene_pos[!is.na(cortex_with_gene_pos$start_position),] | ||
|
||
|
||
# keep 5kb window around the gene | ||
|
||
if (all(cortex_with_gene_pos$SNP_Chromosome == cortex_with_gene_pos$Gene_Chromosome)) { | ||
cortex_with_gene_pos_cis <- cortex_with_gene_pos | ||
} else { | ||
cortex_with_gene_pos_cis <- cortex_with_gene_pos[which(cortex_with_gene_pos$SNP_Chromosome == cortex_with_gene_pos$Gene_Chromosome),] | ||
} | ||
|
||
cortex_with_gene_pos_cis$SNP_Chromosome_Position <- as.numeric(cortex_with_gene_pos_cis$SNP_Chromosome_Position) | ||
|
||
cortex_5kb_window <- cortex_with_gene_pos_cis[which( | ||
cortex_with_gene_pos_cis$SNP_Chromosome_Position >= (cortex_with_gene_pos_cis$start_position-5000) & | ||
cortex_with_gene_pos_cis$SNP_Chromosome_Position <= (cortex_with_gene_pos_cis$end_position+5000) | ||
),] | ||
|
||
cortex_5kb_window <- tidyr::separate(cortex_5kb_window, | ||
col="SNP_Alleles", | ||
"into"=c("allele1","allele2"), | ||
sep="/" | ||
) | ||
cortex_5kb_window$other_allele <- NA | ||
cortex_5kb_window$other_allele[which(cortex_5kb_window$allele1==cortex_5kb_window$Effect_Allele)] <- cortex_5kb_window$allele2[which(cortex_5kb_window$allele1==cortex_5kb_window$Effect_Allele)] | ||
cortex_5kb_window$other_allele[which(cortex_5kb_window$allele2==cortex_5kb_window$Effect_Allele)] <- cortex_5kb_window$allele1[which(cortex_5kb_window$allele2==cortex_5kb_window$Effect_Allele)] | ||
|
||
write.table(cortex_5kb_window, "eqtl_data_metabrain/metabrain_cortex_eur_exposure_dat_snps_5kb_window.txt", sep = "\t", row.names = F, quote = F) | ||
|
||
|
||
print("mission complete") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.