Last updated: 2024-10-14

Checks: 6 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 file has unstaged changes. 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 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(20231112) 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 06c5331. 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

Unstaged changes:
    Modified:   analysis/multi_group_compare_decidingweights_4traits_ess.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/multi_group_compare_decidingweights_4traits_ess.Rmd) and HTML (docs/multi_group_compare_decidingweights_4traits_ess.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 06c5331 XSun 2024-10-14 update
html 06c5331 XSun 2024-10-14 update

Settings

6 modalities from Munro

The stQTL was a combination of Munro apa + rs QTL, if a gene has both rs-QTL and APA-QTL, we use rs-QTL.

  1. Weight processing:

PredictDB:

all the PredictDB are converted from FUSION weights

  • drop_strand_ambig = TRUE,
  • scale_by_ld_variance = F (FUSION converted weights)
  • load_predictdb_LD = F,
  1. Parameter estimation and fine-mapping
  • niter_prefit = 5,
  • niter = 30(default),
  • L: determined by uniform susie,
  • group_prior_var_structure = “shared_type”,
  • maxSNP = 20000,
  • min_nonSNP_PIP = 0.5,

weights from predictdb

  1. Weight processing:

PredictDB (eqtl, sqtl)

  • drop_strand_ambig = TRUE,
  • scale_by_ld_variance = T
  • load_predictdb_LD = F,
  1. Parameter estimation and fine-mapping
  • group_prior_var_structure = “shared_type”,
  • filter_L = TRUE,
  • filter_nonSNP_PIP = FALSE,
  • min_nonSNP_PIP = 0.5,
  • min_abs_corr = 0.1,

mem: 100g 10cores

library(ctwas)
library(EnsDb.Hsapiens.v86)
library(VennDiagram)
library(ggplot2)
library(gridExtra)
library(pheatmap)
library(dplyr)

ens_db <- EnsDb.Hsapiens.v86

mapping_predictdb <- readRDS("/project2/xinhe/shared_data/multigroup_ctwas/weights/mapping_files/PredictDB_mapping.RDS")
mapping_munro <- readRDS("/project2/xinhe/shared_data/multigroup_ctwas/weights/mapping_files/Munro_mapping.RDS")
mapping_two <- rbind(mapping_predictdb,mapping_munro)

load("/project2/xinhe/shared_data/multigroup_ctwas/gwas/samplesize.rdata")


colors <- c("#1b9e77", "#d95f02", "#7570b3", "#e7298a", "#66a61e", 
               "#e6ab02", "#a6761d", "#666666", "#a6cee3")

source("/project/xinhe/xsun/r_functions/ctwas_combine_pip_nocs.R")

plot_piechart <- function(ctwas_parameters, colors) {
  data <- data.frame(
    category = names(ctwas_parameters$prop_heritability),
    percentage = ctwas_parameters$prop_heritability
  )
  
  # Calculate percentage labels for the chart
  data$percentage_label <- paste0(round(data$percentage * 100, 1), "%")
  
  pie <- ggplot(data, aes(x = "", y = percentage, fill = category)) +
    geom_bar(stat = "identity", width = 1) +
    coord_polar("y", start = 0) +
    theme_void() +  # Remove background and axes
    geom_text(aes(label = percentage_label), 
              position = position_stack(vjust = 0.5), size = 2) +
    scale_fill_manual(values = colors) +  # Custom colors
    labs(fill = "Category") +  # Legend title
    ggtitle("Percent of heritability")  # Title
  
  return(pie)
}

rename_heatmap_columns <- function(heatmap_data, column_order) {
  # Select columns that are in the column_order and exist in heatmap_data
  selected_columns <- intersect(column_order, colnames(heatmap_data))
  heatmap_data <- heatmap_data[, selected_columns]
  
  # Initialize new_column_names as a copy of selected_columns
  new_column_names <- selected_columns

  # Assign the new column names to heatmap_data
  colnames(heatmap_data) <- new_column_names
  
  return(heatmap_data)
}

plot_heatmap <- function(heatmap_data, main) {
  
  rownames(heatmap_data) <- heatmap_data$gene_name
  heatmap_data <- heatmap_data %>% dplyr::select(-gene_name, -combined_pip)
  
  if(nrow(heatmap_data) ==1){
    
    heatmap_data <- rbind(heatmap_data,rep(0,ncol(heatmap_data)))
    rownames(heatmap_data)[2] <- "fake_gene_for_plotting"
    
  }
  
  heatmap_matrix <- as.matrix(heatmap_data)
  
  p <- pheatmap(heatmap_matrix,
         cluster_rows = F,   # Cluster the rows (genes)
         cluster_cols = F,   # Cluster the columns (QTL types)
         color = colorRampPalette(c("white", "red"))(50), # Color gradient
         display_numbers = TRUE, # Display numbers in cells
         main = main,labels_row = rownames(heatmap_data), silent = T)
  
  return(p)
}


plot_3venn <- function(es, esra, ess) {
  
  venn.plot <- draw.triple.venn(
      area1 = length(es),
      area2 = length(esra),
      area3 = length(ess),
      n12 = length(intersect(es, esra)),
      n23 = length(intersect(esra, ess)),
      n13 = length(intersect(es, ess)),
      n123 = length(Reduce(intersect, list(es, esra, ess))),
      category = c("e+s", "e+s+rs+apa", "e+s+st"),
      fill = c("red", "green", "blue"),
      lty = "dashed",
      cex = 2,
      cat.cex = 1.5,
      cat.col = c("red", "green", "blue"),
      scaled = T
      )
  
  return(venn.plot)
  
}

LDL-ukb-d-30780_irnt

trait <- "LDL-ukb-d-30780_irnt"
tissue <- "Liver"

gwas_n <- samplesize[trait]

results_dir_ess <- paste0("/project/xinhe/xsun/multi_group_ctwas/9.deciding_weights_4traits/results/",trait,"/ess/")

snp_map_ess <- readRDS(paste0(results_dir_ess,trait,".snp_map.RDS"))
ctwas_res_ess <- readRDS(paste0(results_dir_ess,trait,".ctwas.res.RDS"))

param_ess <- ctwas_res_ess$param
finemap_res_ess <- ctwas_res_ess$finemap_res


p_conv_ess <- make_convergence_plots(param_ess, gwas_n, ncol = 1, colors = colors)
ctwas_parameters_ess <- summarize_param(param_ess, gwas_n)
pve_pie_ess <- plot_piechart(ctwas_parameters = ctwas_parameters_ess, colors = colors)

susie_alpha_res_ess <- ctwas_res_ess$susie_alpha_res

susie_alpha_res_ess <- anno_susie_alpha_res(susie_alpha_res_ess,
                                        mapping_table = mapping_two,
                                        map_by = "molecular_id",
                                        drop_unmapped = TRUE)
2024-10-14 10:06:30 INFO::Annotating susie alpha result ...
2024-10-14 10:06:30 INFO::Map molecular traits to genes
2024-10-14 10:06:34 INFO::Split PIPs for molecular traits mapped to multiple genes
combined_pip_by_type_ess <- combine_gene_pips(susie_alpha_res_ess, 
                                             group_by = "gene_name",
                                             by = "type",
                                             method = "combine_cs",
                                             filter_cs = TRUE,
                                             include_cs_id = F)
results_dir_espred <- paste0("/project/xinhe/xsun/multi_group_ctwas/9.deciding_weights_4traits/results/",trait,"/espred/")

snp_map_espred <- readRDS(paste0(results_dir_espred,trait,".snp_map.RDS"))
ctwas_res_espred <- readRDS(paste0(results_dir_espred,trait,".ctwas.res.RDS"))

param_espred <- ctwas_res_espred$param
finemap_res_espred <- ctwas_res_espred$finemap_res


p_conv_espred <- make_convergence_plots(param_espred, gwas_n, ncol = 1, colors = colors)
ctwas_parameters_espred <- summarize_param(param_espred, gwas_n)
pve_pie_espred <- plot_piechart(ctwas_parameters = ctwas_parameters_espred, colors = colors)


finemap_res_espred$molecular_id <- get_molecular_ids(finemap_res_espred)
finemap_res_espred <- anno_finemap_res(finemap_res_espred,
                              snp_map = snp_map_espred,
                              mapping_table = mapping_two,
                              add_gene_annot = TRUE,
                              map_by = "molecular_id",
                              drop_unmapped = TRUE,
                              add_position = TRUE,
                              use_gene_pos = "mid")
2024-10-14 10:07:02 INFO::Annotating fine-mapping result ...
2024-10-14 10:07:02 INFO::Map molecular traits to genes
2024-10-14 10:07:03 INFO::Split PIPs for molecular traits mapped to multiple genes
2024-10-14 10:07:09 INFO::Add gene positions
2024-10-14 10:07:10 INFO::Add SNP positions
combined_pip_by_type_espred <- combine_gene_pips_nocs(finemap_res =finemap_res_espred,
                                  group_by = "gene_name",
                                  by = "type", 
                                  method = "combine_cs",
                                  filter_cs = T )
2024-10-14 10:07:23 INFO::Limit gene results to credible sets
results_dir_4W <- paste0("/project/xinhe/xsun/multi_group_ctwas/9.deciding_weights_4traits/results/",trait,"/4W/")

snp_map_4W <- readRDS(paste0(results_dir_4W,trait,".snp_map.RDS"))
ctwas_res_4W <- readRDS(paste0(results_dir_4W,trait,".ctwas.res.RDS"))

param_4W <- ctwas_res_4W$param
finemap_res_4W <- ctwas_res_4W$finemap_res

p_conv_4W <- make_convergence_plots(param_4W, gwas_n, ncol = 1, colors = colors)
ctwas_parameters_4W <- summarize_param(param_4W, gwas_n)
pve_pie_4W <- plot_piechart(ctwas_parameters = ctwas_parameters_4W, colors = colors)

finemap_res_4W$molecular_id <- get_molecular_ids(finemap_res_4W)
finemap_res_4W <- anno_finemap_res(finemap_res_4W,
                              snp_map = snp_map_4W,
                              mapping_table = mapping_two,
                              add_gene_annot = TRUE,
                              map_by = "molecular_id",
                              drop_unmapped = TRUE,
                              add_position = TRUE,
                              use_gene_pos = "mid")
2024-10-14 10:07:45 INFO::Annotating fine-mapping result ...
2024-10-14 10:07:45 INFO::Map molecular traits to genes
2024-10-14 10:07:46 INFO::Split PIPs for molecular traits mapped to multiple genes
2024-10-14 10:07:49 INFO::Add gene positions
2024-10-14 10:07:50 INFO::Add SNP positions
combined_pip_by_type_4W <- combine_gene_pips_nocs(finemap_res =finemap_res_4W,
                                  group_by = "gene_name",
                                  by = "type", 
                                  method = "combine_cs",
                                  filter_cs = T )
2024-10-14 10:07:59 INFO::Limit gene results to credible sets

Parameters

print("each column represents one setting: predictdb e+s, predictdb e+s + Munro apa+rs, predictdb e+s + Munro st QTL")
[1] "each column represents one setting: predictdb e+s, predictdb e+s + Munro apa+rs, predictdb e+s + Munro st QTL"
grid.arrange(p_conv_espred,p_conv_4W,p_conv_ess, ncol = 3)

Version Author Date
06c5331 XSun 2024-10-14
######pve
group_pve_espred <- ctwas_parameters_espred$group_pve
group_pve_espred <- group_pve_espred[-length(group_pve_espred)]
group_pve_espred <- c(group_pve_espred, rep(NA,3))
group_pve_espred <- c(group_pve_espred, ctwas_parameters_espred$total_pve)
names(group_pve_espred) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro","TOTAL")

group_pve_4W <- ctwas_parameters_4W$group_pve
group_pve_4W <- group_pve_4W[-length(group_pve_4W)]
group_pve_4W <- c(group_pve_4W, rep(NA,1))
group_pve_4W <- c(group_pve_4W, ctwas_parameters_4W$total_pve)
names(group_pve_4W) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro","TOTAL")

group_pve_ess <- ctwas_parameters_ess$group_pve
group_pve_ess <- group_pve_ess[-length(group_pve_ess)]
group_pve_ess <- c(group_pve_ess[1:2], rep(NA,2),group_pve_ess[3])
group_pve_ess <- c(group_pve_ess, ctwas_parameters_ess$total_pve)
names(group_pve_ess) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro","TOTAL")

grouppve <- cbind(group_pve_espred,group_pve_4W,group_pve_ess)
grouppve <- round(grouppve,digits = 4)

######size
group_size_espred <- ctwas_parameters_espred$group_size
group_size_espred <- group_size_espred[-length(group_size_espred)]
group_size_espred <- c(group_size_espred, rep(NA,3))
names(group_size_espred) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro")

group_size_4W <- ctwas_parameters_4W$group_size
group_size_4W <- group_size_4W[-length(group_size_4W)]
group_size_4W <- c(group_size_4W, rep(NA,1))
names(group_size_4W) <-  c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro")

group_size_ess <- ctwas_parameters_ess$group_size
group_size_ess <- group_size_ess[-length(group_size_ess)]
group_size_ess <- c(group_size_ess[1:2], rep(NA,2),group_size_ess[3])
names(group_size_ess) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro")

groupsize <- cbind(group_size_espred,group_size_4W,group_size_ess)

group_info <- cbind(grouppve,rbind(groupsize,c(rep(NA,3))))

DT::datatable(group_info,caption = htmltools::tags$caption( style = 'caption-side: topleft; text-align = left; color:black;','Group PVE and Group Size'),options = list(pageLength = 10) )
print("each pie chart represents one setting: predictdb e+s, predictdb e+s + Munro apa+rs, predictdb e+s + Munro st QTL")
[1] "each pie chart represents one setting: predictdb e+s, predictdb e+s + Munro apa+rs, predictdb e+s + Munro st QTL"
grid.arrange(pve_pie_espred,pve_pie_4W,pve_pie_ess, ncol =3)

Version Author Date
06c5331 XSun 2024-10-14

Fine-mapping results

combined_sig_espred <- combined_pip_by_type_espred[combined_pip_by_type_espred$combined_pip > 0.8,]
combined_sig_4W <- combined_pip_by_type_4W[combined_pip_by_type_4W$combined_pip > 0.8,]
combined_sig_ess <- combined_pip_by_type_ess[combined_pip_by_type_ess$combined_pip > 0.8,]

sprintf("# of genes with PIP > 0.8 = %s -- predictdb e +s", nrow(combined_sig_espred))
[1] "# of genes with PIP > 0.8 = 42 -- predictdb e +s"
sprintf("# of genes with PIP > 0.8 = %s -- predictdb e + s + Munro apa + rs", nrow(combined_sig_4W))
[1] "# of genes with PIP > 0.8 = 60 -- predictdb e + s + Munro apa + rs"
sprintf("# of genes with PIP > 0.8 = %s -- predictdb e+s + Munro st QTL", nrow(combined_sig_ess))
[1] "# of genes with PIP > 0.8 = 58 -- predictdb e+s + Munro st QTL"
venn.plot <- plot_3venn(es = combined_sig_espred$gene_name,esra = combined_sig_4W$gene_name,ess = combined_sig_ess$gene_name)

Version Author Date
06c5331 XSun 2024-10-14
###1
heatmap_data <- combined_sig_ess[!combined_sig_ess$gene_name %in%combined_sig_espred$gene_name, ]
column_order <- c("gene_name","combined_pip",
                  "eQTL_pip", "sQTL_pip", "stQTL_pip")
heatmap_data <- rename_heatmap_columns(heatmap_data = heatmap_data, column_order = column_order)
p1 <- plot_heatmap(heatmap_data = heatmap_data,main = "PIP partition for the genes reported by e + s + st setting but not by e+s setting")

###2
heatmap_data <- combined_sig_4W[!combined_sig_4W$gene_name %in%combined_sig_ess$gene_name, ]
column_order <- c("gene_name","combined_pip",
                  "eQTL_pip", "sQTL_pip", "rsQTL_pip","apaQTL_pip")
heatmap_data <- rename_heatmap_columns(heatmap_data = heatmap_data, column_order = column_order)
p2 <- plot_heatmap(heatmap_data = heatmap_data,main = "PIP partition for the genes reported by e + s + apa + rs setting but not by e+s+st setting")

###3
heatmap_data <- combined_sig_ess[!combined_sig_ess$gene_name %in%combined_sig_4W$gene_name, ]
column_order <- c("gene_name","combined_pip",
                  "eQTL_pip", "sQTL_pip", "stQTL_pip")
heatmap_data <- rename_heatmap_columns(heatmap_data = heatmap_data, column_order = column_order)


p3 <- plot_heatmap(heatmap_data = heatmap_data,main = "PIP partition for the genes reported by e + s + st setting but not by e + s + apa + rs setting")

g1 <- p1$gtable
g2 <- p2$gtable
g3 <- p3$gtable
grid.arrange(g1, g2, g3, ncol=3)

Version Author Date
06c5331 XSun 2024-10-14

IBD-ebi-a-GCST004131

trait <- "IBD-ebi-a-GCST004131"
tissue <- "Colon_Transverse"

gwas_n <- samplesize[trait]

results_dir_ess <- paste0("/project/xinhe/xsun/multi_group_ctwas/9.deciding_weights_4traits/results/",trait,"/ess/")

snp_map_ess <- readRDS(paste0(results_dir_ess,trait,".snp_map.RDS"))
ctwas_res_ess <- readRDS(paste0(results_dir_ess,trait,".ctwas.res.RDS"))

param_ess <- ctwas_res_ess$param
finemap_res_ess <- ctwas_res_ess$finemap_res


p_conv_ess <- make_convergence_plots(param_ess, gwas_n, ncol = 1, colors = colors)
ctwas_parameters_ess <- summarize_param(param_ess, gwas_n)
pve_pie_ess <- plot_piechart(ctwas_parameters = ctwas_parameters_ess, colors = colors)

susie_alpha_res_ess <- ctwas_res_ess$susie_alpha_res

susie_alpha_res_ess <- anno_susie_alpha_res(susie_alpha_res_ess,
                                        mapping_table = mapping_two,
                                        map_by = "molecular_id",
                                        drop_unmapped = TRUE)
2024-10-14 10:08:27 INFO::Annotating susie alpha result ...
2024-10-14 10:08:27 INFO::Map molecular traits to genes
2024-10-14 10:08:28 INFO::Split PIPs for molecular traits mapped to multiple genes
combined_pip_by_type_ess <- combine_gene_pips(susie_alpha_res_ess, 
                                             group_by = "gene_name",
                                             by = "type",
                                             method = "combine_cs",
                                             filter_cs = TRUE,
                                             include_cs_id = F)
results_dir_espred <- paste0("/project/xinhe/xsun/multi_group_ctwas/9.deciding_weights_4traits/results/",trait,"/espred/")

snp_map_espred <- readRDS(paste0(results_dir_espred,trait,".snp_map.RDS"))
ctwas_res_espred <- readRDS(paste0(results_dir_espred,trait,".ctwas.res.RDS"))

param_espred <- ctwas_res_espred$param
finemap_res_espred <- ctwas_res_espred$finemap_res


p_conv_espred <- make_convergence_plots(param_espred, gwas_n, ncol = 1, colors = colors)
ctwas_parameters_espred <- summarize_param(param_espred, gwas_n)
pve_pie_espred <- plot_piechart(ctwas_parameters = ctwas_parameters_espred, colors = colors)


finemap_res_espred$molecular_id <- get_molecular_ids(finemap_res_espred)
finemap_res_espred <- anno_finemap_res(finemap_res_espred,
                              snp_map = snp_map_espred,
                              mapping_table = mapping_two,
                              add_gene_annot = TRUE,
                              map_by = "molecular_id",
                              drop_unmapped = TRUE,
                              add_position = TRUE,
                              use_gene_pos = "mid")
2024-10-14 10:08:48 INFO::Annotating fine-mapping result ...
2024-10-14 10:08:49 INFO::Map molecular traits to genes
2024-10-14 10:08:49 INFO::Split PIPs for molecular traits mapped to multiple genes
2024-10-14 10:08:56 INFO::Add gene positions
2024-10-14 10:08:56 INFO::Add SNP positions
combined_pip_by_type_espred <- combine_gene_pips_nocs(finemap_res =finemap_res_espred,
                                  group_by = "gene_name",
                                  by = "type", 
                                  method = "combine_cs",
                                  filter_cs = T )
2024-10-14 10:09:00 INFO::Limit gene results to credible sets
results_dir_4W <- paste0("/project/xinhe/xsun/multi_group_ctwas/9.deciding_weights_4traits/results/",trait,"/4W/")

snp_map_4W <- readRDS(paste0(results_dir_4W,trait,".snp_map.RDS"))
ctwas_res_4W <- readRDS(paste0(results_dir_4W,trait,".ctwas.res.RDS"))

param_4W <- ctwas_res_4W$param
finemap_res_4W <- ctwas_res_4W$finemap_res

p_conv_4W <- make_convergence_plots(param_4W, gwas_n, ncol = 1, colors = colors)
ctwas_parameters_4W <- summarize_param(param_4W, gwas_n)
pve_pie_4W <- plot_piechart(ctwas_parameters = ctwas_parameters_4W, colors = colors)

finemap_res_4W$molecular_id <- get_molecular_ids(finemap_res_4W)
finemap_res_4W <- anno_finemap_res(finemap_res_4W,
                              snp_map = snp_map_4W,
                              mapping_table = mapping_two,
                              add_gene_annot = TRUE,
                              map_by = "molecular_id",
                              drop_unmapped = TRUE,
                              add_position = TRUE,
                              use_gene_pos = "mid")
2024-10-14 10:09:19 INFO::Annotating fine-mapping result ...
2024-10-14 10:09:19 INFO::Map molecular traits to genes
2024-10-14 10:09:19 INFO::Split PIPs for molecular traits mapped to multiple genes
2024-10-14 10:09:23 INFO::Add gene positions
2024-10-14 10:09:24 INFO::Add SNP positions
combined_pip_by_type_4W <- combine_gene_pips_nocs(finemap_res =finemap_res_4W,
                                  group_by = "gene_name",
                                  by = "type", 
                                  method = "combine_cs",
                                  filter_cs = T )
2024-10-14 10:09:32 INFO::Limit gene results to credible sets

Parameters

print("each column represents one setting: predictdb e+s, predictdb e+s + Munro apa+rs, predictdb e+s + Munro st QTL")
[1] "each column represents one setting: predictdb e+s, predictdb e+s + Munro apa+rs, predictdb e+s + Munro st QTL"
grid.arrange(p_conv_espred,p_conv_4W,p_conv_ess, ncol = 3)

Version Author Date
06c5331 XSun 2024-10-14
######pve
group_pve_espred <- ctwas_parameters_espred$group_pve
group_pve_espred <- group_pve_espred[-length(group_pve_espred)]
group_pve_espred <- c(group_pve_espred, rep(NA,3))
group_pve_espred <- c(group_pve_espred, ctwas_parameters_espred$total_pve)
names(group_pve_espred) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro","TOTAL")

group_pve_4W <- ctwas_parameters_4W$group_pve
group_pve_4W <- group_pve_4W[-length(group_pve_4W)]
group_pve_4W <- c(group_pve_4W, rep(NA,1))
group_pve_4W <- c(group_pve_4W, ctwas_parameters_4W$total_pve)
names(group_pve_4W) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro","TOTAL")

group_pve_ess <- ctwas_parameters_ess$group_pve
group_pve_ess <- group_pve_ess[-length(group_pve_ess)]
group_pve_ess <- c(group_pve_ess[1:2], rep(NA,2),group_pve_ess[3])
group_pve_ess <- c(group_pve_ess, ctwas_parameters_ess$total_pve)
names(group_pve_ess) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro","TOTAL")

grouppve <- cbind(group_pve_espred,group_pve_4W,group_pve_ess)
grouppve <- round(grouppve,digits = 4)

######size
group_size_espred <- ctwas_parameters_espred$group_size
group_size_espred <- group_size_espred[-length(group_size_espred)]
group_size_espred <- c(group_size_espred, rep(NA,3))
names(group_size_espred) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro")

group_size_4W <- ctwas_parameters_4W$group_size
group_size_4W <- group_size_4W[-length(group_size_4W)]
group_size_4W <- c(group_size_4W, rep(NA,1))
names(group_size_4W) <-  c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro")

group_size_ess <- ctwas_parameters_ess$group_size
group_size_ess <- group_size_ess[-length(group_size_ess)]
group_size_ess <- c(group_size_ess[1:2], rep(NA,2),group_size_ess[3])
names(group_size_ess) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro")

groupsize <- cbind(group_size_espred,group_size_4W,group_size_ess)

group_info <- cbind(grouppve,rbind(groupsize,c(rep(NA,3))))

DT::datatable(group_info,caption = htmltools::tags$caption( style = 'caption-side: topleft; text-align = left; color:black;','Group PVE and Group Size'),options = list(pageLength = 10) )
print("each pie chart represents one setting: predictdb e+s, predictdb e+s + Munro apa+rs, predictdb e+s + Munro st QTL")
[1] "each pie chart represents one setting: predictdb e+s, predictdb e+s + Munro apa+rs, predictdb e+s + Munro st QTL"
grid.arrange(pve_pie_espred,pve_pie_4W,pve_pie_ess, ncol =3)

Version Author Date
06c5331 XSun 2024-10-14

Fine-mapping results

combined_sig_espred <- combined_pip_by_type_espred[combined_pip_by_type_espred$combined_pip > 0.8,]
combined_sig_4W <- combined_pip_by_type_4W[combined_pip_by_type_4W$combined_pip > 0.8,]
combined_sig_ess <- combined_pip_by_type_ess[combined_pip_by_type_ess$combined_pip > 0.8,]

sprintf("# of genes with PIP > 0.8 = %s -- predictdb e +s", nrow(combined_sig_espred))
[1] "# of genes with PIP > 0.8 = 17 -- predictdb e +s"
sprintf("# of genes with PIP > 0.8 = %s -- predictdb e + s + Munro apa + rs", nrow(combined_sig_4W))
[1] "# of genes with PIP > 0.8 = 24 -- predictdb e + s + Munro apa + rs"
sprintf("# of genes with PIP > 0.8 = %s -- predictdb e+s + Munro st QTL", nrow(combined_sig_ess))
[1] "# of genes with PIP > 0.8 = 24 -- predictdb e+s + Munro st QTL"
venn.plot <- plot_3venn(es = combined_sig_espred$gene_name,esra = combined_sig_4W$gene_name,ess = combined_sig_ess$gene_name)

Version Author Date
06c5331 XSun 2024-10-14
###1
heatmap_data <- combined_sig_ess[!combined_sig_ess$gene_name %in%combined_sig_espred$gene_name, ]
column_order <- c("gene_name","combined_pip",
                  "eQTL_pip", "sQTL_pip", "stQTL_pip")
heatmap_data <- rename_heatmap_columns(heatmap_data = heatmap_data, column_order = column_order)
p1 <- plot_heatmap(heatmap_data = heatmap_data,main = "PIP partition for the genes reported by e + s + st setting but not by e+s setting")

###2
heatmap_data <- combined_sig_4W[!combined_sig_4W$gene_name %in%combined_sig_ess$gene_name, ]
column_order <- c("gene_name","combined_pip",
                  "eQTL_pip", "sQTL_pip", "rsQTL_pip","apaQTL_pip")
heatmap_data <- rename_heatmap_columns(heatmap_data = heatmap_data, column_order = column_order)
p2 <- plot_heatmap(heatmap_data = heatmap_data,main = "PIP partition for the genes reported by e + s + apa + rs setting but not by e+s+st setting")

###3
heatmap_data <- combined_sig_ess[!combined_sig_ess$gene_name %in%combined_sig_4W$gene_name, ]
column_order <- c("gene_name","combined_pip",
                  "eQTL_pip", "sQTL_pip", "stQTL_pip")
heatmap_data <- rename_heatmap_columns(heatmap_data = heatmap_data, column_order = column_order)


p3 <- plot_heatmap(heatmap_data = heatmap_data,main = "PIP partition for the genes reported by e + s + st setting but not by e + s + apa + rs setting")

g1 <- p1$gtable
g2 <- p2$gtable
g3 <- p3$gtable
grid.arrange(g1, g2, g3, ncol=3)

Version Author Date
06c5331 XSun 2024-10-14

SBP-ukb-a-360

trait <- "SBP-ukb-a-360"
tissue <- "Artery_Tibial"

gwas_n <- samplesize[trait]

results_dir_ess <- paste0("/project/xinhe/xsun/multi_group_ctwas/9.deciding_weights_4traits/results/",trait,"/ess/")

snp_map_ess <- readRDS(paste0(results_dir_ess,trait,".snp_map.RDS"))
ctwas_res_ess <- readRDS(paste0(results_dir_ess,trait,".ctwas.res.RDS"))

param_ess <- ctwas_res_ess$param
finemap_res_ess <- ctwas_res_ess$finemap_res


p_conv_ess <- make_convergence_plots(param_ess, gwas_n, ncol = 1, colors = colors)
ctwas_parameters_ess <- summarize_param(param_ess, gwas_n)
pve_pie_ess <- plot_piechart(ctwas_parameters = ctwas_parameters_ess, colors = colors)

susie_alpha_res_ess <- ctwas_res_ess$susie_alpha_res

susie_alpha_res_ess <- anno_susie_alpha_res(susie_alpha_res_ess,
                                        mapping_table = mapping_two,
                                        map_by = "molecular_id",
                                        drop_unmapped = TRUE)
2024-10-14 10:10:02 INFO::Annotating susie alpha result ...
2024-10-14 10:10:02 INFO::Map molecular traits to genes
2024-10-14 10:10:02 INFO::Split PIPs for molecular traits mapped to multiple genes
combined_pip_by_type_ess <- combine_gene_pips(susie_alpha_res_ess, 
                                             group_by = "gene_name",
                                             by = "type",
                                             method = "combine_cs",
                                             filter_cs = TRUE,
                                             include_cs_id = F)
results_dir_espred <- paste0("/project/xinhe/xsun/multi_group_ctwas/9.deciding_weights_4traits/results/",trait,"/espred/")

snp_map_espred <- readRDS(paste0(results_dir_espred,trait,".snp_map.RDS"))
ctwas_res_espred <- readRDS(paste0(results_dir_espred,trait,".ctwas.res.RDS"))

param_espred <- ctwas_res_espred$param
finemap_res_espred <- ctwas_res_espred$finemap_res


p_conv_espred <- make_convergence_plots(param_espred, gwas_n, ncol = 1, colors = colors)
ctwas_parameters_espred <- summarize_param(param_espred, gwas_n)
pve_pie_espred <- plot_piechart(ctwas_parameters = ctwas_parameters_espred, colors = colors)


finemap_res_espred$molecular_id <- get_molecular_ids(finemap_res_espred)
finemap_res_espred <- anno_finemap_res(finemap_res_espred,
                              snp_map = snp_map_espred,
                              mapping_table = mapping_two,
                              add_gene_annot = TRUE,
                              map_by = "molecular_id",
                              drop_unmapped = TRUE,
                              add_position = TRUE,
                              use_gene_pos = "mid")
2024-10-14 10:10:30 INFO::Annotating fine-mapping result ...
2024-10-14 10:10:30 INFO::Map molecular traits to genes
2024-10-14 10:10:31 INFO::Split PIPs for molecular traits mapped to multiple genes
2024-10-14 10:10:35 INFO::Add gene positions
2024-10-14 10:10:35 INFO::Add SNP positions
combined_pip_by_type_espred <- combine_gene_pips_nocs(finemap_res =finemap_res_espred,
                                  group_by = "gene_name",
                                  by = "type", 
                                  method = "combine_cs",
                                  filter_cs = T )
2024-10-14 10:10:41 INFO::Limit gene results to credible sets
results_dir_4W <- paste0("/project/xinhe/xsun/multi_group_ctwas/9.deciding_weights_4traits/results/",trait,"/4W/")

snp_map_4W <- readRDS(paste0(results_dir_4W,trait,".snp_map.RDS"))
ctwas_res_4W <- readRDS(paste0(results_dir_4W,trait,".ctwas.res.RDS"))

param_4W <- ctwas_res_4W$param
finemap_res_4W <- ctwas_res_4W$finemap_res

p_conv_4W <- make_convergence_plots(param_4W, gwas_n, ncol = 1, colors = colors)
ctwas_parameters_4W <- summarize_param(param_4W, gwas_n)
pve_pie_4W <- plot_piechart(ctwas_parameters = ctwas_parameters_4W, colors = colors)

finemap_res_4W$molecular_id <- get_molecular_ids(finemap_res_4W)
finemap_res_4W <- anno_finemap_res(finemap_res_4W,
                              snp_map = snp_map_4W,
                              mapping_table = mapping_two,
                              add_gene_annot = TRUE,
                              map_by = "molecular_id",
                              drop_unmapped = TRUE,
                              add_position = TRUE,
                              use_gene_pos = "mid")
2024-10-14 10:11:03 INFO::Annotating fine-mapping result ...
2024-10-14 10:11:03 INFO::Map molecular traits to genes
2024-10-14 10:11:05 INFO::Split PIPs for molecular traits mapped to multiple genes
2024-10-14 10:11:09 INFO::Add gene positions
2024-10-14 10:11:09 INFO::Add SNP positions
combined_pip_by_type_4W <- combine_gene_pips_nocs(finemap_res =finemap_res_4W,
                                  group_by = "gene_name",
                                  by = "type", 
                                  method = "combine_cs",
                                  filter_cs = T )
2024-10-14 10:11:19 INFO::Limit gene results to credible sets

Parameters

print("each column represents one setting: predictdb e+s, predictdb e+s + Munro apa+rs, predictdb e+s + Munro st QTL")
[1] "each column represents one setting: predictdb e+s, predictdb e+s + Munro apa+rs, predictdb e+s + Munro st QTL"
grid.arrange(p_conv_espred,p_conv_4W,p_conv_ess, ncol = 3)

Version Author Date
06c5331 XSun 2024-10-14
######pve
group_pve_espred <- ctwas_parameters_espred$group_pve
group_pve_espred <- group_pve_espred[-length(group_pve_espred)]
group_pve_espred <- c(group_pve_espred, rep(NA,3))
group_pve_espred <- c(group_pve_espred, ctwas_parameters_espred$total_pve)
names(group_pve_espred) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro","TOTAL")

group_pve_4W <- ctwas_parameters_4W$group_pve
group_pve_4W <- group_pve_4W[-length(group_pve_4W)]
group_pve_4W <- c(group_pve_4W, rep(NA,1))
group_pve_4W <- c(group_pve_4W, ctwas_parameters_4W$total_pve)
names(group_pve_4W) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro","TOTAL")

group_pve_ess <- ctwas_parameters_ess$group_pve
group_pve_ess <- group_pve_ess[-length(group_pve_ess)]
group_pve_ess <- c(group_pve_ess[1:2], rep(NA,2),group_pve_ess[3])
group_pve_ess <- c(group_pve_ess, ctwas_parameters_ess$total_pve)
names(group_pve_ess) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro","TOTAL")

grouppve <- cbind(group_pve_espred,group_pve_4W,group_pve_ess)
grouppve <- round(grouppve,digits = 4)

######size
group_size_espred <- ctwas_parameters_espred$group_size
group_size_espred <- group_size_espred[-length(group_size_espred)]
group_size_espred <- c(group_size_espred, rep(NA,3))
names(group_size_espred) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro")

group_size_4W <- ctwas_parameters_4W$group_size
group_size_4W <- group_size_4W[-length(group_size_4W)]
group_size_4W <- c(group_size_4W, rep(NA,1))
names(group_size_4W) <-  c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro")

group_size_ess <- ctwas_parameters_ess$group_size
group_size_ess <- group_size_ess[-length(group_size_ess)]
group_size_ess <- c(group_size_ess[1:2], rep(NA,2),group_size_ess[3])
names(group_size_ess) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro")

groupsize <- cbind(group_size_espred,group_size_4W,group_size_ess)

group_info <- cbind(grouppve,rbind(groupsize,c(rep(NA,3))))

DT::datatable(group_info,caption = htmltools::tags$caption( style = 'caption-side: topleft; text-align = left; color:black;','Group PVE and Group Size'),options = list(pageLength = 10) )
print("each pie chart represents one setting: predictdb e+s, predictdb e+s + Munro apa+rs, predictdb e+s + Munro st QTL")
[1] "each pie chart represents one setting: predictdb e+s, predictdb e+s + Munro apa+rs, predictdb e+s + Munro st QTL"
grid.arrange(pve_pie_espred,pve_pie_4W,pve_pie_ess, ncol =3)

Version Author Date
06c5331 XSun 2024-10-14

Fine-mapping results

combined_sig_espred <- combined_pip_by_type_espred[combined_pip_by_type_espred$combined_pip > 0.8,]
combined_sig_4W <- combined_pip_by_type_4W[combined_pip_by_type_4W$combined_pip > 0.8,]
combined_sig_ess <- combined_pip_by_type_ess[combined_pip_by_type_ess$combined_pip > 0.8,]

sprintf("# of genes with PIP > 0.8 = %s -- predictdb e +s", nrow(combined_sig_espred))
[1] "# of genes with PIP > 0.8 = 38 -- predictdb e +s"
sprintf("# of genes with PIP > 0.8 = %s -- predictdb e + s + Munro apa + rs", nrow(combined_sig_4W))
[1] "# of genes with PIP > 0.8 = 46 -- predictdb e + s + Munro apa + rs"
sprintf("# of genes with PIP > 0.8 = %s -- predictdb e+s + Munro st QTL", nrow(combined_sig_ess))
[1] "# of genes with PIP > 0.8 = 41 -- predictdb e+s + Munro st QTL"
venn.plot <- plot_3venn(es = combined_sig_espred$gene_name,esra = combined_sig_4W$gene_name,ess = combined_sig_ess$gene_name)

Version Author Date
06c5331 XSun 2024-10-14
###1
heatmap_data <- combined_sig_ess[!combined_sig_ess$gene_name %in%combined_sig_espred$gene_name, ]
column_order <- c("gene_name","combined_pip",
                  "eQTL_pip", "sQTL_pip", "stQTL_pip")
heatmap_data <- rename_heatmap_columns(heatmap_data = heatmap_data, column_order = column_order)
p1 <- plot_heatmap(heatmap_data = heatmap_data,main = "PIP partition for the genes reported by e + s + st setting but not by e+s setting")

###2
heatmap_data <- combined_sig_4W[!combined_sig_4W$gene_name %in%combined_sig_ess$gene_name, ]
column_order <- c("gene_name","combined_pip",
                  "eQTL_pip", "sQTL_pip", "rsQTL_pip","apaQTL_pip")
heatmap_data <- rename_heatmap_columns(heatmap_data = heatmap_data, column_order = column_order)
p2 <- plot_heatmap(heatmap_data = heatmap_data,main = "PIP partition for the genes reported by e + s + apa + rs setting but not by e+s+st setting")

###3
heatmap_data <- combined_sig_ess[!combined_sig_ess$gene_name %in%combined_sig_4W$gene_name, ]
column_order <- c("gene_name","combined_pip",
                  "eQTL_pip", "sQTL_pip", "stQTL_pip")
heatmap_data <- rename_heatmap_columns(heatmap_data = heatmap_data, column_order = column_order)


p3 <- plot_heatmap(heatmap_data = heatmap_data,main = "PIP partition for the genes reported by e + s + st setting but not by e + s + apa + rs setting")

g1 <- p1$gtable
g2 <- p2$gtable
g3 <- p3$gtable
grid.arrange(g1, g2, g3, ncol=3)

Version Author Date
06c5331 XSun 2024-10-14

WBC-ieu-b-30

trait <- "WBC-ieu-b-30"
tissue <- "Whole_Blood"

gwas_n <- samplesize[trait]

results_dir_ess <- paste0("/project/xinhe/xsun/multi_group_ctwas/9.deciding_weights_4traits/results/",trait,"/ess/")

snp_map_ess <- readRDS(paste0(results_dir_ess,trait,".snp_map.RDS"))
ctwas_res_ess <- readRDS(paste0(results_dir_ess,trait,".ctwas.res.RDS"))

param_ess <- ctwas_res_ess$param
finemap_res_ess <- ctwas_res_ess$finemap_res


p_conv_ess <- make_convergence_plots(param_ess, gwas_n, ncol = 1, colors = colors)
ctwas_parameters_ess <- summarize_param(param_ess, gwas_n)
pve_pie_ess <- plot_piechart(ctwas_parameters = ctwas_parameters_ess, colors = colors)

susie_alpha_res_ess <- ctwas_res_ess$susie_alpha_res

susie_alpha_res_ess <- anno_susie_alpha_res(susie_alpha_res_ess,
                                        mapping_table = mapping_two,
                                        map_by = "molecular_id",
                                        drop_unmapped = TRUE)
2024-10-14 10:11:56 INFO::Annotating susie alpha result ...
2024-10-14 10:11:56 INFO::Map molecular traits to genes
2024-10-14 10:11:56 INFO::Split PIPs for molecular traits mapped to multiple genes
combined_pip_by_type_ess <- combine_gene_pips(susie_alpha_res_ess, 
                                             group_by = "gene_name",
                                             by = "type",
                                             method = "combine_cs",
                                             filter_cs = TRUE,
                                             include_cs_id = F)
results_dir_espred <- paste0("/project/xinhe/xsun/multi_group_ctwas/9.deciding_weights_4traits/results/",trait,"/espred/")

snp_map_espred <- readRDS(paste0(results_dir_espred,trait,".snp_map.RDS"))
ctwas_res_espred <- readRDS(paste0(results_dir_espred,trait,".ctwas.res.RDS"))

param_espred <- ctwas_res_espred$param
finemap_res_espred <- ctwas_res_espred$finemap_res


p_conv_espred <- make_convergence_plots(param_espred, gwas_n, ncol = 1, colors = colors)
ctwas_parameters_espred <- summarize_param(param_espred, gwas_n)
pve_pie_espred <- plot_piechart(ctwas_parameters = ctwas_parameters_espred, colors = colors)


finemap_res_espred$molecular_id <- get_molecular_ids(finemap_res_espred)
finemap_res_espred <- anno_finemap_res(finemap_res_espred,
                              snp_map = snp_map_espred,
                              mapping_table = mapping_two,
                              add_gene_annot = TRUE,
                              map_by = "molecular_id",
                              drop_unmapped = TRUE,
                              add_position = TRUE,
                              use_gene_pos = "mid")
2024-10-14 10:12:28 INFO::Annotating fine-mapping result ...
2024-10-14 10:12:28 INFO::Map molecular traits to genes
2024-10-14 10:12:29 INFO::Split PIPs for molecular traits mapped to multiple genes
2024-10-14 10:12:43 INFO::Add gene positions
2024-10-14 10:12:43 INFO::Add SNP positions
combined_pip_by_type_espred <- combine_gene_pips_nocs(finemap_res =finemap_res_espred,
                                  group_by = "gene_name",
                                  by = "type", 
                                  method = "combine_cs",
                                  filter_cs = T )
2024-10-14 10:12:56 INFO::Limit gene results to credible sets
results_dir_4W <- paste0("/project/xinhe/xsun/multi_group_ctwas/9.deciding_weights_4traits/results/",trait,"/4W/")

snp_map_4W <- readRDS(paste0(results_dir_4W,trait,".snp_map.RDS"))
ctwas_res_4W <- readRDS(paste0(results_dir_4W,trait,".ctwas.res.RDS"))

param_4W <- ctwas_res_4W$param
finemap_res_4W <- ctwas_res_4W$finemap_res

p_conv_4W <- make_convergence_plots(param_4W, gwas_n, ncol = 1, colors = colors)
ctwas_parameters_4W <- summarize_param(param_4W, gwas_n)
pve_pie_4W <- plot_piechart(ctwas_parameters = ctwas_parameters_4W, colors = colors)

finemap_res_4W$molecular_id <- get_molecular_ids(finemap_res_4W)
finemap_res_4W <- anno_finemap_res(finemap_res_4W,
                              snp_map = snp_map_4W,
                              mapping_table = mapping_two,
                              add_gene_annot = TRUE,
                              map_by = "molecular_id",
                              drop_unmapped = TRUE,
                              add_position = TRUE,
                              use_gene_pos = "mid")
2024-10-14 10:13:24 INFO::Annotating fine-mapping result ...
2024-10-14 10:13:24 INFO::Map molecular traits to genes
2024-10-14 10:13:28 INFO::Split PIPs for molecular traits mapped to multiple genes
2024-10-14 10:13:35 INFO::Add gene positions
2024-10-14 10:13:35 INFO::Add SNP positions
combined_pip_by_type_4W <- combine_gene_pips_nocs(finemap_res =finemap_res_4W,
                                  group_by = "gene_name",
                                  by = "type", 
                                  method = "combine_cs",
                                  filter_cs = T )
2024-10-14 10:13:44 INFO::Limit gene results to credible sets

Parameters

print("each column represents one setting: predictdb e+s, predictdb e+s + Munro apa+rs, predictdb e+s + Munro st QTL")
[1] "each column represents one setting: predictdb e+s, predictdb e+s + Munro apa+rs, predictdb e+s + Munro st QTL"
grid.arrange(p_conv_espred,p_conv_4W,p_conv_ess, ncol = 3)

Version Author Date
06c5331 XSun 2024-10-14
######pve
group_pve_espred <- ctwas_parameters_espred$group_pve
group_pve_espred <- group_pve_espred[-length(group_pve_espred)]
group_pve_espred <- c(group_pve_espred, rep(NA,3))
group_pve_espred <- c(group_pve_espred, ctwas_parameters_espred$total_pve)
names(group_pve_espred) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro","TOTAL")

group_pve_4W <- ctwas_parameters_4W$group_pve
group_pve_4W <- group_pve_4W[-length(group_pve_4W)]
group_pve_4W <- c(group_pve_4W, rep(NA,1))
group_pve_4W <- c(group_pve_4W, ctwas_parameters_4W$total_pve)
names(group_pve_4W) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro","TOTAL")

group_pve_ess <- ctwas_parameters_ess$group_pve
group_pve_ess <- group_pve_ess[-length(group_pve_ess)]
group_pve_ess <- c(group_pve_ess[1:2], rep(NA,2),group_pve_ess[3])
group_pve_ess <- c(group_pve_ess, ctwas_parameters_ess$total_pve)
names(group_pve_ess) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro","TOTAL")

grouppve <- cbind(group_pve_espred,group_pve_4W,group_pve_ess)
grouppve <- round(grouppve,digits = 4)

######size
group_size_espred <- ctwas_parameters_espred$group_size
group_size_espred <- group_size_espred[-length(group_size_espred)]
group_size_espred <- c(group_size_espred, rep(NA,3))
names(group_size_espred) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro")

group_size_4W <- ctwas_parameters_4W$group_size
group_size_4W <- group_size_4W[-length(group_size_4W)]
group_size_4W <- c(group_size_4W, rep(NA,1))
names(group_size_4W) <-  c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro")

group_size_ess <- ctwas_parameters_ess$group_size
group_size_ess <- group_size_ess[-length(group_size_ess)]
group_size_ess <- c(group_size_ess[1:2], rep(NA,2),group_size_ess[3])
names(group_size_ess) <- c("eQTL_pred","sQTL_pred","apaQTL_munro","rsQTL_munro","stQTL_munro")

groupsize <- cbind(group_size_espred,group_size_4W,group_size_ess)

group_info <- cbind(grouppve,rbind(groupsize,c(rep(NA,3))))

DT::datatable(group_info,caption = htmltools::tags$caption( style = 'caption-side: topleft; text-align = left; color:black;','Group PVE and Group Size'),options = list(pageLength = 10) )
print("each pie chart represents one setting: predictdb e+s, predictdb e+s + Munro apa+rs, predictdb e+s + Munro st QTL")
[1] "each pie chart represents one setting: predictdb e+s, predictdb e+s + Munro apa+rs, predictdb e+s + Munro st QTL"
grid.arrange(pve_pie_espred,pve_pie_4W,pve_pie_ess, ncol =3)

Version Author Date
06c5331 XSun 2024-10-14

Fine-mapping results

combined_sig_espred <- combined_pip_by_type_espred[combined_pip_by_type_espred$combined_pip > 0.8,]
combined_sig_4W <- combined_pip_by_type_4W[combined_pip_by_type_4W$combined_pip > 0.8,]
combined_sig_ess <- combined_pip_by_type_ess[combined_pip_by_type_ess$combined_pip > 0.8,]

sprintf("# of genes with PIP > 0.8 = %s -- predictdb e +s", nrow(combined_sig_espred))
[1] "# of genes with PIP > 0.8 = 121 -- predictdb e +s"
sprintf("# of genes with PIP > 0.8 = %s -- predictdb e + s + Munro apa + rs", nrow(combined_sig_4W))
[1] "# of genes with PIP > 0.8 = 147 -- predictdb e + s + Munro apa + rs"
sprintf("# of genes with PIP > 0.8 = %s -- predictdb e+s + Munro st QTL", nrow(combined_sig_ess))
[1] "# of genes with PIP > 0.8 = 135 -- predictdb e+s + Munro st QTL"
venn.plot <- plot_3venn(es = combined_sig_espred$gene_name,esra = combined_sig_4W$gene_name,ess = combined_sig_ess$gene_name)

Version Author Date
06c5331 XSun 2024-10-14
###1
heatmap_data <- combined_sig_ess[!combined_sig_ess$gene_name %in%combined_sig_espred$gene_name, ]
column_order <- c("gene_name","combined_pip",
                  "eQTL_pip", "sQTL_pip", "stQTL_pip")
heatmap_data <- rename_heatmap_columns(heatmap_data = heatmap_data, column_order = column_order)
p1 <- plot_heatmap(heatmap_data = heatmap_data,main = "PIP partition for the genes reported by e + s + st setting but not by e+s setting")

###2
heatmap_data <- combined_sig_4W[!combined_sig_4W$gene_name %in%combined_sig_ess$gene_name, ]
column_order <- c("gene_name","combined_pip",
                  "eQTL_pip", "sQTL_pip", "rsQTL_pip","apaQTL_pip")
heatmap_data <- rename_heatmap_columns(heatmap_data = heatmap_data, column_order = column_order)
p2 <- plot_heatmap(heatmap_data = heatmap_data,main = "PIP partition for the genes reported by e + s + apa + rs setting but not by e+s+st setting")

###3
heatmap_data <- combined_sig_ess[!combined_sig_ess$gene_name %in%combined_sig_4W$gene_name, ]
column_order <- c("gene_name","combined_pip",
                  "eQTL_pip", "sQTL_pip", "stQTL_pip")
heatmap_data <- rename_heatmap_columns(heatmap_data = heatmap_data, column_order = column_order)


p3 <- plot_heatmap(heatmap_data = heatmap_data,main = "PIP partition for the genes reported by e + s + st setting but not by e + s + apa + rs setting")

g1 <- p1$gtable
g2 <- p2$gtable
g3 <- p3$gtable
grid.arrange(g1, g2, g3, ncol=3)

Version Author Date
06c5331 XSun 2024-10-14

sessionInfo()
R version 4.2.0 (2022-04-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /software/openblas-0.3.13-el7-x86_64/lib/libopenblas_haswellp-r0.3.13.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] grid      stats4    stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] logging_0.10-108          dplyr_1.1.4              
 [3] pheatmap_1.0.12           gridExtra_2.3            
 [5] ggplot2_3.5.1             VennDiagram_1.7.3        
 [7] futile.logger_1.4.3       EnsDb.Hsapiens.v86_2.99.0
 [9] ensembldb_2.20.2          AnnotationFilter_1.20.0  
[11] GenomicFeatures_1.48.3    AnnotationDbi_1.58.0     
[13] Biobase_2.56.0            GenomicRanges_1.48.0     
[15] GenomeInfoDb_1.39.9       IRanges_2.30.0           
[17] S4Vectors_0.34.0          BiocGenerics_0.42.0      
[19] ctwas_0.4.15             

loaded via a namespace (and not attached):
  [1] colorspace_2.0-3            rjson_0.2.21               
  [3] ellipsis_0.3.2              rprojroot_2.0.3            
  [5] XVector_0.36.0              locuszoomr_0.2.1           
  [7] fs_1.5.2                    rstudioapi_0.13            
  [9] farver_2.1.0                DT_0.22                    
 [11] ggrepel_0.9.1               bit64_4.0.5                
 [13] fansi_1.0.3                 xml2_1.3.3                 
 [15] codetools_0.2-18            cachem_1.0.6               
 [17] knitr_1.39                  jsonlite_1.8.0             
 [19] workflowr_1.7.0             Rsamtools_2.12.0           
 [21] dbplyr_2.1.1                png_0.1-7                  
 [23] readr_2.1.2                 compiler_4.2.0             
 [25] httr_1.4.3                  assertthat_0.2.1           
 [27] Matrix_1.5-3                fastmap_1.1.0              
 [29] lazyeval_0.2.2              cli_3.6.1                  
 [31] formatR_1.12                later_1.3.0                
 [33] htmltools_0.5.2             prettyunits_1.1.1          
 [35] tools_4.2.0                 gtable_0.3.0               
 [37] glue_1.6.2                  GenomeInfoDbData_1.2.8     
 [39] rappdirs_0.3.3              Rcpp_1.0.12                
 [41] jquerylib_0.1.4             vctrs_0.6.5                
 [43] Biostrings_2.64.0           rtracklayer_1.56.0         
 [45] crosstalk_1.2.0             xfun_0.41                  
 [47] stringr_1.5.1               lifecycle_1.0.4            
 [49] irlba_2.3.5                 restfulr_0.0.14            
 [51] XML_3.99-0.14               zlibbioc_1.42.0            
 [53] zoo_1.8-10                  scales_1.3.0               
 [55] gggrid_0.2-0                hms_1.1.1                  
 [57] promises_1.2.0.1            MatrixGenerics_1.8.0       
 [59] ProtGenerics_1.28.0         parallel_4.2.0             
 [61] SummarizedExperiment_1.26.1 RColorBrewer_1.1-3         
 [63] lambda.r_1.2.4              LDlinkR_1.2.3              
 [65] yaml_2.3.5                  curl_4.3.2                 
 [67] memoise_2.0.1               sass_0.4.1                 
 [69] biomaRt_2.54.1              stringi_1.7.6              
 [71] RSQLite_2.3.1               highr_0.9                  
 [73] BiocIO_1.6.0                filelock_1.0.2             
 [75] BiocParallel_1.30.3         rlang_1.1.2                
 [77] pkgconfig_2.0.3             matrixStats_0.62.0         
 [79] bitops_1.0-7                evaluate_0.15              
 [81] lattice_0.20-45             purrr_1.0.2                
 [83] labeling_0.4.2              GenomicAlignments_1.32.0   
 [85] htmlwidgets_1.5.4           cowplot_1.1.1              
 [87] bit_4.0.4                   tidyselect_1.2.0           
 [89] magrittr_2.0.3              R6_2.5.1                   
 [91] generics_0.1.2              DelayedArray_0.22.0        
 [93] DBI_1.2.2                   withr_2.5.0                
 [95] pgenlibr_0.3.3              pillar_1.9.0               
 [97] whisker_0.4                 KEGGREST_1.36.3            
 [99] RCurl_1.98-1.7              mixsqp_0.3-43              
[101] tibble_3.2.1                crayon_1.5.1               
[103] futile.options_1.0.1        utf8_1.2.2                 
[105] BiocFileCache_2.4.0         plotly_4.10.0              
[107] tzdb_0.4.0                  rmarkdown_2.25             
[109] progress_1.2.2              data.table_1.14.2          
[111] blob_1.2.3                  git2r_0.30.1               
[113] digest_0.6.29               tidyr_1.3.0                
[115] httpuv_1.6.5                munsell_0.5.0              
[117] viridisLite_0.4.0           bslib_0.3.1