Last updated: 2025-07-14
Checks: 1 1
Knit directory: multigroup_ctwas_analysis/
This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
The R Markdown is untracked by Git. To know which version of the R
Markdown file created these results, you’ll want to first commit it to
the Git repo. If you’re still working on the analysis, you can ignore
this warning. When you’re finished, you can run
wflow_publish
to commit the R Markdown file and build the
HTML.
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 cf54125. 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: .Rhistory
Ignored: cv/
Ignored: figures/lz/IBD-ebi-a-GCST004131/single/
Ignored: figures/lz_ld/IBD-ebi-a-GCST004131/single/
Untracked files:
Untracked: VennDiagram.2025-07-14_11-13-09.log
Untracked: VennDiagram.2025-07-14_11-13-10.log
Untracked: VennDiagram.2025-07-14_11-13-11.log
Untracked: VennDiagram.2025-07-14_11-13-12.log
Untracked: VennDiagram.2025-07-14_11-34-53.log
Untracked: VennDiagram.2025-07-14_11-34-57.log
Untracked: VennDiagram.2025-07-14_11-35-06.log
Untracked: VennDiagram.2025-07-14_11-35-13.log
Untracked: VennDiagram.2025-07-14_11-35-22.log
Untracked: VennDiagram.2025-07-14_11-35-29.log
Untracked: VennDiagram.2025-07-14_11-35-30.log
Untracked: VennDiagram.2025-07-14_11-35-31.log
Untracked: VennDiagram.2025-07-14_11-35-39.log
Untracked: VennDiagram.2025-07-14_11-35-46.log
Untracked: VennDiagram.2025-07-14_11-35-47.log
Untracked: VennDiagram.2025-07-14_11-35-54.log
Untracked: VennDiagram.2025-07-14_11-36-01.log
Untracked: VennDiagram.2025-07-14_11-36-09.log
Untracked: VennDiagram.2025-07-14_11-36-17.log
Untracked: VennDiagram.2025-07-14_11-36-25.log
Untracked: VennDiagram.2025-07-14_12-18-22.log
Untracked: VennDiagram.2025-07-14_12-18-23.log
Untracked: VennDiagram.2025-07-14_12-18-24.log
Untracked: analysis/realdata_final_downstream_enrichment_chatgpt_compare_twasctwascoloc.Rmd
Unstaged changes:
Deleted: VennDiagram.2025-07-11_15-23-40.log
Deleted: VennDiagram.2025-07-11_15-23-41.log
Deleted: VennDiagram.2025-07-11_15-23-42.log
Deleted: VennDiagram.2025-07-11_15-26-15.log
Deleted: VennDiagram.2025-07-11_15-26-16.log
Deleted: VennDiagram.2025-07-11_15-28-18.log
Deleted: VennDiagram.2025-07-11_15-28-19.log
Deleted: VennDiagram.2025-07-11_15-30-07.log
Deleted: VennDiagram.2025-07-11_15-30-08.log
Deleted: VennDiagram.2025-07-11_15-30-09.log
Deleted: VennDiagram.2025-07-11_15-32-08.log
Deleted: VennDiagram.2025-07-11_15-32-09.log
Deleted: VennDiagram.2025-07-11_15-32-10.log
Deleted: VennDiagram.2025-07-11_15-33-53.log
Deleted: VennDiagram.2025-07-11_15-33-54.log
Deleted: VennDiagram.2025-07-11_15-33-55.log
Deleted: VennDiagram.2025-07-11_15-34-48.log
Deleted: VennDiagram.2025-07-11_15-35-03.log
Deleted: VennDiagram.2025-07-11_15-35-13.log
Deleted: VennDiagram.2025-07-11_15-35-20.log
Deleted: VennDiagram.2025-07-11_15-35-27.log
Deleted: VennDiagram.2025-07-11_15-35-36.log
Deleted: VennDiagram.2025-07-11_15-35-42.log
Deleted: VennDiagram.2025-07-11_15-35-49.log
Deleted: VennDiagram.2025-07-11_15-35-57.log
Deleted: VennDiagram.2025-07-11_15-36-04.log
Deleted: VennDiagram.2025-07-11_15-36-13.log
Deleted: VennDiagram.2025-07-11_15-36-21.log
Deleted: VennDiagram.2025-07-11_15-36-30.log
Deleted: VennDiagram.2025-07-11_15-36-39.log
Deleted: VennDiagram.2025-07-11_15-36-49.log
Modified: analysis/index.Rmd
Modified: analysis/realdata_final_downstream_enrichment_compare_twasctwascoloc.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.
There are no past versions. Publish this analysis with
wflow_publish()
to start tracking its development.
We compared overlap with gene lists from chatgpt, across three
analyses: coloc, TWAS, and cTWAS. The prompt we used in
chatgpt 4o
is
can you return some genes with roles in LDL / LDL risk genes, in txt table format, the second column is the gene functions
DT::datatable(matrix())
traits <- c("LDL-ukb-d-30780_irnt","IBD-ebi-a-GCST004131","T1D-GCST90014023","aFib-ebi-a-GCST006414","SBP-ukb-a-360","BMI-panukb","HB-panukb","Height-panukb")
#
folder_results <- "/project/xinhe/xsun/multi_group_ctwas/23.multi_group_0515/results_downstream/enrichr_compare/"
ctwas_folder_results <- "/project/xinhe/xsun/multi_group_ctwas/23.multi_group_0515/snakemake_outputs/"
folder_chatgpt_genes <- "/project/xinhe/xsun/multi_group_ctwas/23.multi_group_0515/data/genelist/"
all_overlap_tables <- list()
for (trait in traits){
# print(trait)
# Load gene lists
ctwas_genes <- readRDS(paste0(ctwas_folder_results, trait, "/", trait, ".3qtls.combined_pip_rmmapping_bygroup_final.RDS"))
ctwas_genes_pip05p <- ctwas_genes$gene_name[ctwas_genes$combined_pip >= 0.5]
ctwas_genes_pip05m <- ctwas_genes$gene_name[ctwas_genes$combined_pip < 0.5]
ctwas_genes_pip08p <- ctwas_genes$gene_name[ctwas_genes$combined_pip >= 0.8]
ctwas_genes_pip08m <- ctwas_genes$gene_name[ctwas_genes$combined_pip < 0.8]
ctwas_genes <- ctwas_genes$gene_name[ctwas_genes$combined_pip > 0.8]
coloc_genes <- readRDS(paste0(folder_results, trait, ".genes.coloc.RDS"))
coloc_genes <- coloc_genes$gene_name[coloc_genes$PP4 > 0.8]
twas_genes <- readRDS(paste0(folder_results, trait, ".genes.twas_bonf.RDS"))
chatgpt_genes <- read.table(paste0(folder_chatgpt_genes, trait, "_genelist_chatgpt.txt"), header = TRUE, sep = "\t")
# Calculate overlaps
overlap_counts <- c(
length(intersect(ctwas_genes, chatgpt_genes$Gene)),
length(intersect(coloc_genes, chatgpt_genes$Gene)),
length(intersect(twas_genes, chatgpt_genes$Gene))
)
percent_overlap <- c(
paste0(round(overlap_counts[1] / length(ctwas_genes) * 100, 1), "%"),
paste0(round(overlap_counts[2] / length(coloc_genes) * 100, 1), "%"),
paste0(round(overlap_counts[3] / length(twas_genes) * 100, 1), "%")
)
overlapping_genes <- c(
paste(intersect(ctwas_genes, chatgpt_genes$Gene), collapse = ", "),
paste(intersect(coloc_genes, chatgpt_genes$Gene), collapse = ", "),
paste(intersect(twas_genes, chatgpt_genes$Gene), collapse = ", ")
)
overlap_table <- data.frame(
Trait = trait,
Analysis = c("cTWAS", "COLOC", "TWAS"),
Total_Genes = c(length(ctwas_genes), length(coloc_genes), length(twas_genes)),
Overlap_with_ChatGPT = c(
paste0(length(intersect(ctwas_genes, chatgpt_genes$Gene))," of ",length(chatgpt_genes$Gene)," Chatgpt genes"),
paste0(length(intersect(coloc_genes, chatgpt_genes$Gene))," of ",length(chatgpt_genes$Gene)," Chatgpt genes"),
paste0(length(intersect(twas_genes, chatgpt_genes$Gene))," of ",length(chatgpt_genes$Gene)," Chatgpt genes")
),
Percent_Overlap = c(
paste0(round(length(intersect(ctwas_genes, chatgpt_genes$Gene)) / length(ctwas_genes) * 100, 1), "%"),
paste0(round(length(intersect(coloc_genes, chatgpt_genes$Gene)) / length(coloc_genes) * 100, 1), "%"),
paste0(round(length(intersect(twas_genes, chatgpt_genes$Gene)) / length(twas_genes) * 100, 1), "%")
),
Overlapping_Genes = c(
paste(intersect(ctwas_genes, chatgpt_genes$Gene), collapse = ", "),
paste(intersect(coloc_genes, chatgpt_genes$Gene), collapse = ", "),
paste(intersect(twas_genes, chatgpt_genes$Gene), collapse = ", ")
)
)
num_gene05p_in_set <- sum(ctwas_genes_pip05p %in% chatgpt_genes$Gene)
num_gene05m_in_set <- sum(ctwas_genes_pip05m %in% chatgpt_genes$Gene)
fisher_b_matrix_05p05m <- matrix(
c(num_gene05p_in_set, num_gene05m_in_set,
length(ctwas_genes_pip05p) - num_gene05p_in_set,
length(ctwas_genes_pip05m) - num_gene05m_in_set),
nrow = 2, byrow = TRUE,
dimnames = list(c("#included", "#notincluded"), c("pip>0.5", "pip<0.5"))
)
fisher_b_result_05p05m <- fisher.test(fisher_b_matrix_05p05m)
overlap_table$`fisher_p-PIP>0.5&PIP<0.5` <- NA
overlap_table$`fisher_p-PIP>0.5&PIP<0.5`[1] <- round(fisher_b_result_05p05m$p.value,digits = 8)
num_gene08p_in_set <- sum(ctwas_genes_pip08p %in% chatgpt_genes$Gene)
num_gene08m_in_set <- sum(ctwas_genes_pip08m %in% chatgpt_genes$Gene)
fisher_b_matrix_08p08m <- matrix(
c(num_gene08p_in_set, num_gene08m_in_set,
length(ctwas_genes_pip08p) - num_gene08p_in_set,
length(ctwas_genes_pip08m) - num_gene08m_in_set),
nrow = 2, byrow = TRUE,
dimnames = list(c("#included", "#notincluded"), c("pip>0.8", "pip<0.8"))
)
fisher_b_result_08p08m <- fisher.test(fisher_b_matrix_08p08m)
overlap_table$`fisher_p-PIP>0.8&PIP<0.8` <- NA
overlap_table$`fisher_p-PIP>0.8&PIP<0.8`[1] <- round(fisher_b_result_08p08m$p.value,digits = 8)
all_overlap_tables[[trait]] <- overlap_table
}
# Combine all into one data frame
combined_overlap_table <- do.call(rbind, all_overlap_tables)
rownames(combined_overlap_table) <- NULL
cat("<br><br>")
cat(knitr::knit_print(DT::datatable(combined_overlap_table,
caption = htmltools::tags$caption(
style = 'caption-side: left; text-align: left; color:black; font-size:150% ;',
'Combined Gene Overlap Summary Across Traits'
),
options = list(pageLength = 10))))
cat("<br><br>")
### print the genes from chatgpt
for (trait in traits){
print(trait)
# Load gene lists
ctwas_genes <- readRDS(paste0(ctwas_folder_results, trait, "/", trait, ".3qtls.combined_pip_rmmapping_bygroup_final.RDS"))
ctwas_genes <- ctwas_genes$gene_name[ctwas_genes$combined_pip > 0.8]
coloc_genes <- readRDS(paste0(folder_results, trait, ".genes.coloc.RDS"))
coloc_genes <- coloc_genes$gene_name[coloc_genes$PP4 > 0.8]
twas_genes <- readRDS(paste0(folder_results, trait, ".genes.twas_bonf.RDS"))
chatgpt_genes <- read.table(paste0(folder_chatgpt_genes, trait, "_genelist_chatgpt.txt"), header = TRUE, sep = "\t")
cat("<br>")
cat("<br>")
cat(knitr::knit_print(DT::datatable(chatgpt_genes,caption = htmltools::tags$caption( style = 'caption-side: left; text-align: left; color:black; font-size:150% ;',paste0('Genes returned by chatgpt - ',trait)),options = list(pageLength = 5) )))
cat("<br>")
cat("<br>")
# Calculate overlaps
overlap_counts <- c(
length(intersect(ctwas_genes, chatgpt_genes$Gene)),
length(intersect(coloc_genes, chatgpt_genes$Gene)),
length(intersect(twas_genes, chatgpt_genes$Gene))
)
percent_overlap <- c(
paste0(round(overlap_counts[1] / length(ctwas_genes) * 100, 1), "%"),
paste0(round(overlap_counts[2] / length(coloc_genes) * 100, 1), "%"),
paste0(round(overlap_counts[3] / length(twas_genes) * 100, 1), "%")
)
overlapping_genes <- c(
paste(intersect(ctwas_genes, chatgpt_genes$Gene), collapse = ", "),
paste(intersect(coloc_genes, chatgpt_genes$Gene), collapse = ", "),
paste(intersect(twas_genes, chatgpt_genes$Gene), collapse = ", ")
)
overlap_table <- data.frame(
Trait = trait,
Analysis = c("cTWAS", "COLOC", "TWAS"),
Total_Genes = c(length(ctwas_genes), length(coloc_genes), length(twas_genes)),
Overlap_with_ChatGPT = c(
paste0(length(intersect(ctwas_genes, chatgpt_genes$Gene))," of ",length(chatgpt_genes$Gene)," Chatgpt genes"),
paste0(length(intersect(coloc_genes, chatgpt_genes$Gene))," of ",length(chatgpt_genes$Gene)," Chatgpt genes"),
paste0(length(intersect(twas_genes, chatgpt_genes$Gene))," of ",length(chatgpt_genes$Gene)," Chatgpt genes")
),
Percent_Overlap = c(
paste0(round(length(intersect(ctwas_genes, chatgpt_genes$Gene)) / length(ctwas_genes) * 100, 1), "%"),
paste0(round(length(intersect(coloc_genes, chatgpt_genes$Gene)) / length(coloc_genes) * 100, 1), "%"),
paste0(round(length(intersect(twas_genes, chatgpt_genes$Gene)) / length(twas_genes) * 100, 1), "%")
),
Overlapping_Genes = c(
paste(intersect(ctwas_genes, chatgpt_genes$Gene), collapse = ", "),
paste(intersect(coloc_genes, chatgpt_genes$Gene), collapse = ", "),
paste(intersect(twas_genes, chatgpt_genes$Gene), collapse = ", ")
)
)
}
[1] “LDL-ukb-d-30780_irnt”
[1] “IBD-ebi-a-GCST004131”
[1] “T1D-GCST90014023”
[1] “aFib-ebi-a-GCST006414”
[1] “SBP-ukb-a-360”
[1] “BMI-panukb”
[1] “HB-panukb”
[1] “Height-panukb”