suppressPackageStartupMessages(source(data.dir %&% "helpers.R", chdir = TRUE))
<- get_db()
phenomexcan_con dbListTables(phenomexcan_con)
PhenomeXcan Query
query PhenomeXcan association with top phenotypes for list of genes
= list()
input $pheno = c("Obesity")
input$limit = 30000
input<- suppressMessages(get_results_from_data_db(input)) obesity_genes
= list()
input $pheno = c("Body fat percentage")
input$limit = 30000
input<- suppressMessages(get_results_from_data_db(input)) body_fat_genes
= list()
input $pheno = c("Body mass index (BMI) (21001_raw)")
input$limit = 30000
input<- suppressMessages(get_results_from_data_db(input)) BMI_genes
= list()
input $pheno = c("Fasting Glucose")
input$limit = 30000
input<- suppressMessages(get_results_from_data_db(input)) glucose_genes
= list()
input $pheno = c("Height")
input$limit = 30000
input<- suppressMessages(get_results_from_data_db(input)) height_genes
Generate a table of all human MultiXcan results
#matrix - humans (rows are genes and columns are traits (fat, BMI, Obesity))
<- list(BMI_genes, body_fat_genes, obesity_genes, glucose_genes, height_genes)
listphenos <- data_frame(gene_name = as.character())
pheno_Multi_humans
for(l in listphenos) {
<- l$phenotype[1]
trait <- l %>% dplyr::select(c(gene_name, pvalue))
tempo colnames(tempo)[2] = paste("pvalue", trait, sep="_")
<- full_join(pheno_Multi_humans, tempo, by = "gene_name")
pheno_Multi_humans
}
<- as.data.frame(pheno_Multi_humans$gene_name)
human_genes
#pheno_humans <- as.matrix(pheno_humans %>% dplyr::select(-c(gene_name)))
= useEnsembl(biomart='ensembl', dataset="hsapiens_gene_ensembl", mirror = "uswest")
human #human = useMart("ensembl", dataset = "hsapiens_gene_ensembl", mirror = "uswest")
<- listAttributes(human)
attributes
= c("ensembl_gene_id", "external_gene_name", "rnorvegicus_homolog_ensembl_gene", "rnorvegicus_homolog_associated_gene_name")
attributes = getBM(attributes, filters="with_rnorvegicus_homolog",values=TRUE, mart = human, uniqueRows=TRUE)
orth.rats
<- human_genes %>% dplyr::rename(external_gene_name = `pheno_Multi_humans$gene_name`)
human_genes <- inner_join(human_genes, orth.rats, by = "external_gene_name") %>% dplyr::select(c(external_gene_name, rnorvegicus_homolog_associated_gene_name)) human_genes
Generate a table of all rat MultiXcan results
<- list.files("/gpfs/data/im-lab/nas40t2/natasha/rat_genomics/MultiXcan/results", pattern = "assoc.txt",full.names = TRUE)
filelist
<- data_frame(gene = as.character())
pheno_Multi_ratfor(fila in filelist) {
<- substr(fila, 66, str_length(fila)-18)
trait <- fread(fila) %>% select(c(gene, pvalue))
tempo colnames(tempo)[2] = paste("pvalue", trait, sep=".")
<- full_join(pheno_Multi_rat, tempo, by = "gene")
pheno_Multi_rat
}
#pheno_Multi_rat <- read_tsv("/Users/natashasanthanam/Downloads/rat_metabolic_MultiXcan_pval_assoc.txt", col_names = TRUE)
<- pheno_Multi_rat %>% mutate(gene_name = orth.rats[match(pheno_Multi_rat$gene, orth.rats$rnorvegicus_homolog_ensembl_gene),2]$external_gene_name) pheno_Multi_rat
Enrichment Analysis
::source_gist("38431b74c6c0bf90c12f")
devtools::source_gist("1e9053c8f35c30396429350a08f33ea7") devtools
<- full_df %>% mutate(gene_name = orth.rats[match(full_df$gene, orth.rats$rnorvegicus_homolog_ensembl_gene), 2]$external_gene_name)
full_df
qqunif(BMI_genes$pvalue, col= "maroon1" )
colnames(pheno_Multi_humans)[2] <- "pvalue_BMI"
<- full_df %>% filter(metabolic_trait == "Body Mass Index (BMI) with tail") %>% filter(pvalue <= 0.05) %>% .[["gene_name"]]
BMI_genes_rats qqpoints(BMI_genes %>% filter(gene_name %in% BMI_genes_rats) %>% .[["pvalue"]],pch='+', col = "dodgerblue")
qqunif(height_genes$pvalue, col = "maroon1")
<- full_df %>% filter(metabolic_trait == "Body length including tail") %>% filter(pvalue <= 0.05) %>% .[["gene_name"]]
height_genes_rats qqpoints(height_genes %>% filter(gene_name %in% height_genes_rats) %>% .[["pvalue"]],pch='+', col="dodgerblue")
qqunif(BMI_genes$pvalue, col= "maroon1")
<- pheno_Multi_rat %>% filter(pvalue.bmi_bodylength_wo_tail <= 0.05) %>% .[["gene_name"]] %>% na.omit()
BMI_genes_rats qqpoints(BMI_genes %>% filter(gene_name %in% BMI_genes_rats) %>% .[["pvalue"]],pch='+', col="dodgerblue")
qqunif(height_genes$pvalue, col= "maroon1")
<- pheno_Multi_rat %>% filter(pvalue.bodylength_w_tail <= 0.05) %>% .[["gene_name"]] %>% na.omit()
height_genes_rats qqpoints(height_genes %>% filter(gene_name %in% height_genes_rats) %>% .[["pvalue"]],pch='+', col="dodgerblue")
<- BMI_genes %>% mutate(in_rats = ifelse(BMI_genes$gene_name %in% BMI_genes_rats, 1, 0))
all_bmi_genes
<- height_genes %>% mutate(in_rats = ifelse(height_genes$gene_name %in% height_genes_rats, 1, 0))
all_height_genes
wilcox.test(pvalue ~ in_rats, data=all_bmi_genes)
wilcox.test(pvalue ~ in_rats, data=all_height_genes)
No matching items