Last updated: 2024-12-03

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 2120c9f. 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/tissue_selection_extra_tissue.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/tissue_selection_extra_tissue.Rmd) and HTML (docs/tissue_selection_extra_tissue.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 2120c9f XSun 2024-12-03 update
html 2120c9f XSun 2024-12-03 update
Rmd 3f3c588 XSun 2024-12-02 update
html 3f3c588 XSun 2024-12-02 update
Rmd 9110eba XSun 2024-11-27 update
html 9110eba XSun 2024-11-27 update

Introduction

  • For each trait, we select some baseline tissues that well known related to the trait.
  • Take the rest of tissues with sample size >=200, one at a time, as extra tissue and run multi-tissue eQTL ctwas.
  • Evaluate the percent of h2g in the extra tissue, conditioned on the known ones.
library(ctwas)
library(dplyr)

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

IBD-ebi-a-GCST004131

Round 1 – baseline_tissue : Whole_Blood,Colon_Sigmoid,Colon_Transverse

trait <- "IBD-ebi-a-GCST004131"
baseline_tissue <- c("Whole_Blood","Colon_Sigmoid","Colon_Transverse")


gwas_n <- samplesize[trait]

result_dir <- paste0("/project/xinhe/xsun/multi_group_ctwas/12.tissue_selection/results/", trait, "/")

extra_tissue <- list.files(path = result_dir)
extra_tissue <- extra_tissue[-which(extra_tissue == "baseline")]

all <- c()
for (tissue in c("baseline",extra_tissue)) {
  
  para_file <- paste0(result_dir,tissue,"/",trait,"_",tissue,".param.RDS")
  param <- readRDS(para_file)
  
  ctwas_parameters <- summarize_param(param, gwas_n)
  
  if(tissue == "baseline") {
    
    total_pve <- ctwas_parameters$total_pve
    
    total_nonSNP_prob_h2g_baseline <- (1- ctwas_parameters$prop_heritability["SNP"])*100
    
    prob_h2g <- round(as.numeric(ctwas_parameters$prop_heritability[paste0(c(baseline_tissue),"|eQTL")]*100),digits = 4)
    
    h2g_v_tissue <- c(tissue, total_nonSNP_prob_h2g_baseline,NA,prob_h2g,total_pve,NA)
  }else {
    total_pve <- ctwas_parameters$total_pve
    
    total_nonSNP_prob_h2g <- (1- ctwas_parameters$prop_heritability["SNP"])*100
    nonSNP_prob_h2g_gain <- total_nonSNP_prob_h2g - total_nonSNP_prob_h2g_baseline
    
    
    prob_h2g <- round(as.numeric(ctwas_parameters$prop_heritability[paste0(c(baseline_tissue,tissue),"|eQTL")]*100),digits = 4)
    
    h2g_v_tissue <- c(tissue, total_nonSNP_prob_h2g,nonSNP_prob_h2g_gain,prob_h2g,total_pve,NA)
    
  }
  
  all <- rbind(all,h2g_v_tissue)
  
}


colnames(all) <- c("extra_tissue","total_nonSNP_prob_h2g(%)","nonSNP_prob_h2g_gain(%)",paste0("%h2g_",c(baseline_tissue)),"%h2g_extra_tissue","pve_gain")
all <- as.data.frame(all)

all <- all %>%
  dplyr::mutate(across(where(is.character), ~ as.numeric(.x))) %>%  # Convert character columns to numeric
  dplyr::mutate(across(where(is.numeric), ~ round(.x, digits = 4))) # Round numeric columns

all$extra_tissue <- c("baseline",extra_tissue)
rownames(all) <- seq(1:nrow(all))

DT::datatable(all,caption = htmltools::tags$caption( style = 'caption-side: left; text-align: left; color:black;  font-size:150% ;','PVE change after adding extra tissue'),options = list(pageLength = 10) )

Round 2 – baseline_tissue : Whole_Blood,Colon_Sigmoid,Colon_Transverse,Artery_Coronary

trait <- "IBD-ebi-a-GCST004131"
baseline_tissue <- c("Whole_Blood","Colon_Sigmoid","Colon_Transverse","Artery_Coronary")

gwas_n <- samplesize[trait]

result_dir <- paste0("/project/xinhe/xsun/multi_group_ctwas/12.tissue_selection/results/", trait,"_round2", "/")

extra_tissue <- list.files(path = result_dir)
extra_tissue <- extra_tissue[-which(extra_tissue == "baseline")]

all <- c()
for (tissue in c("baseline",extra_tissue)) {
  
  para_file <- paste0(result_dir,tissue,"/",trait,"_",tissue,".param.RDS")
  param <- readRDS(para_file)
  
  ctwas_parameters <- summarize_param(param, gwas_n)
  
  if(tissue == "baseline") {
    
    total_pve <- ctwas_parameters$total_pve
    
    total_nonSNP_prob_h2g_baseline <- (1- ctwas_parameters$prop_heritability["SNP"])*100
    
    prob_h2g <- round(as.numeric(ctwas_parameters$prop_heritability[paste0(c(baseline_tissue),"|eQTL")]*100),digits = 4)
    
    h2g_v_tissue <- c(tissue, total_nonSNP_prob_h2g_baseline,NA,prob_h2g,total_pve,NA)
  }else {
    total_pve <- ctwas_parameters$total_pve
    
    total_nonSNP_prob_h2g <- (1- ctwas_parameters$prop_heritability["SNP"])*100
    nonSNP_prob_h2g_gain <- total_nonSNP_prob_h2g - total_nonSNP_prob_h2g_baseline
    
    
    prob_h2g <- round(as.numeric(ctwas_parameters$prop_heritability[paste0(c(baseline_tissue,tissue),"|eQTL")]*100),digits = 4)
    
    h2g_v_tissue <- c(tissue, total_nonSNP_prob_h2g,nonSNP_prob_h2g_gain,prob_h2g,total_pve,NA)
    
  }
  
  all <- rbind(all,h2g_v_tissue)
  
}


colnames(all) <- c("extra_tissue","total_nonSNP_prob_h2g(%)","nonSNP_prob_h2g_gain(%)",paste0("%h2g_",c(baseline_tissue)),"%h2g_extra_tissue","pve_gain")
all <- as.data.frame(all)

all <- all %>%
  dplyr::mutate(across(where(is.character), ~ as.numeric(.x))) %>%  # Convert character columns to numeric
  dplyr::mutate(across(where(is.numeric), ~ round(.x, digits = 4))) # Round numeric columns

all$extra_tissue <- c("baseline",extra_tissue)
rownames(all) <- seq(1:nrow(all))

DT::datatable(all,caption = htmltools::tags$caption( style = 'caption-side: left; text-align: left; color:black;  font-size:150% ;','PVE change after adding extra tissue'),options = list(pageLength = 10) )

Round 3 – baseline_tissue : Whole_Blood,Colon_Sigmoid,Colon_Transverse,Artery_Coronary,Heart_Left_Ventricle

trait <- "IBD-ebi-a-GCST004131"
baseline_tissue <- c("Whole_Blood","Colon_Sigmoid","Colon_Transverse","Artery_Coronary","Heart_Left_Ventricle")

gwas_n <- samplesize[trait]

result_dir <- paste0("/project/xinhe/xsun/multi_group_ctwas/12.tissue_selection/results/", trait,"_round3", "/")

extra_tissue <- list.files(path = result_dir)
extra_tissue <- extra_tissue[-which(extra_tissue == "baseline")]

all <- c()
for (tissue in c("baseline",extra_tissue)) {
  
  para_file <- paste0(result_dir,tissue,"/",trait,"_",tissue,".param.RDS")
  param <- readRDS(para_file)
  
  ctwas_parameters <- summarize_param(param, gwas_n)
  
  if(tissue == "baseline") {
    
    total_pve <- ctwas_parameters$total_pve
    
    total_nonSNP_prob_h2g_baseline <- (1- ctwas_parameters$prop_heritability["SNP"])*100
    
    prob_h2g <- round(as.numeric(ctwas_parameters$prop_heritability[paste0(c(baseline_tissue),"|eQTL")]*100),digits = 4)
    
    h2g_v_tissue <- c(tissue, total_nonSNP_prob_h2g_baseline,NA,prob_h2g,total_pve,NA)
  }else {
    total_pve <- ctwas_parameters$total_pve
    
    total_nonSNP_prob_h2g <- (1- ctwas_parameters$prop_heritability["SNP"])*100
    nonSNP_prob_h2g_gain <- total_nonSNP_prob_h2g - total_nonSNP_prob_h2g_baseline
    
    
    prob_h2g <- round(as.numeric(ctwas_parameters$prop_heritability[paste0(c(baseline_tissue,tissue),"|eQTL")]*100),digits = 4)
    
    h2g_v_tissue <- c(tissue, total_nonSNP_prob_h2g,nonSNP_prob_h2g_gain,prob_h2g,total_pve,NA)
    
  }
  
  all <- rbind(all,h2g_v_tissue)
  
}


colnames(all) <- c("extra_tissue","total_nonSNP_prob_h2g(%)","nonSNP_prob_h2g_gain(%)",paste0("%h2g_",c(baseline_tissue)),"%h2g_extra_tissue","pve_gain")
all <- as.data.frame(all)

all <- all %>%
  dplyr::mutate(across(where(is.character), ~ as.numeric(.x))) %>%  # Convert character columns to numeric
  dplyr::mutate(across(where(is.numeric), ~ round(.x, digits = 4))) # Round numeric columns

all$extra_tissue <- c("baseline",extra_tissue)
rownames(all) <- seq(1:nrow(all))

DT::datatable(all,caption = htmltools::tags$caption( style = 'caption-side: left; text-align: left; color:black;  font-size:150% ;','PVE change after adding extra tissue'),options = list(pageLength = 10) )

Round 4 – baseline_tissue : Whole_Blood,Colon_Sigmoid,Colon_Transverse,Artery_Coronary,Heart_Left_Ventricle,Cells_Cultured_fibroblasts

trait <- "IBD-ebi-a-GCST004131"
baseline_tissue <- c("Whole_Blood","Colon_Sigmoid","Colon_Transverse","Artery_Coronary","Heart_Left_Ventricle","Cells_Cultured_fibroblasts")

gwas_n <- samplesize[trait]

result_dir <- paste0("/project/xinhe/xsun/multi_group_ctwas/12.tissue_selection/results/", trait,"_round4", "/")

extra_tissue <- list.files(path = result_dir)
extra_tissue <- extra_tissue[-which(extra_tissue == "baseline")]

all <- c()
for (tissue in c("baseline",extra_tissue)) {
  
  para_file <- paste0(result_dir,tissue,"/",trait,"_",tissue,".param.RDS")
  param <- readRDS(para_file)
  
  ctwas_parameters <- summarize_param(param, gwas_n)
  
  if(tissue == "baseline") {
    
    total_pve <- ctwas_parameters$total_pve
    
    total_nonSNP_prob_h2g_baseline <- (1- ctwas_parameters$prop_heritability["SNP"])*100
    
    prob_h2g <- round(as.numeric(ctwas_parameters$prop_heritability[paste0(c(baseline_tissue),"|eQTL")]*100),digits = 4)
    
    h2g_v_tissue <- c(tissue, total_nonSNP_prob_h2g_baseline,NA,prob_h2g,total_pve,NA)
  }else {
    total_pve <- ctwas_parameters$total_pve
    
    total_nonSNP_prob_h2g <- (1- ctwas_parameters$prop_heritability["SNP"])*100
    nonSNP_prob_h2g_gain <- total_nonSNP_prob_h2g - total_nonSNP_prob_h2g_baseline
    
    
    prob_h2g <- round(as.numeric(ctwas_parameters$prop_heritability[paste0(c(baseline_tissue,tissue),"|eQTL")]*100),digits = 4)
    
    h2g_v_tissue <- c(tissue, total_nonSNP_prob_h2g,nonSNP_prob_h2g_gain,prob_h2g,total_pve,NA)
    
  }
  
  all <- rbind(all,h2g_v_tissue)
  
}


colnames(all) <- c("extra_tissue","total_nonSNP_prob_h2g(%)","nonSNP_prob_h2g_gain(%)",paste0("%h2g_",c(baseline_tissue)),"%h2g_extra_tissue","pve_gain")
all <- as.data.frame(all)

all <- all %>%
  dplyr::mutate(across(where(is.character), ~ as.numeric(.x))) %>%  # Convert character columns to numeric
  dplyr::mutate(across(where(is.numeric), ~ round(.x, digits = 4))) # Round numeric columns

all$extra_tissue <- c("baseline",extra_tissue)
rownames(all) <- seq(1:nrow(all))

DT::datatable(all,caption = htmltools::tags$caption( style = 'caption-side: left; text-align: left; color:black;  font-size:150% ;','PVE change after adding extra tissue'),options = list(pageLength = 10) )

SBP-ukb-a-360

Round 1 – baseline_tissue : Artery_Aorta,Heart_Left_Ventricle,Adrenal_Gland

trait <- "SBP-ukb-a-360"
baseline_tissue <- c("Artery_Aorta", "Heart_Left_Ventricle", "Adrenal_Gland")


gwas_n <- samplesize[trait]

result_dir <- paste0("/project/xinhe/xsun/multi_group_ctwas/12.tissue_selection/results/", trait, "/")

extra_tissue <- list.files(path = result_dir)
extra_tissue <- extra_tissue[-which(extra_tissue == "baseline")]

all <- c()
for (tissue in c("baseline",extra_tissue)) {
  
  para_file <- paste0(result_dir,tissue,"/",trait,"_",tissue,".param.RDS")
  param <- readRDS(para_file)
  
  ctwas_parameters <- summarize_param(param, gwas_n)
  
  if(tissue == "baseline") {
    
    total_pve <- ctwas_parameters$total_pve
    
    total_nonSNP_prob_h2g_baseline <- (1- ctwas_parameters$prop_heritability["SNP"])*100
    
    prob_h2g <- round(as.numeric(ctwas_parameters$prop_heritability[paste0(c(baseline_tissue),"|eQTL")]*100),digits = 4)
    
    h2g_v_tissue <- c(tissue, total_nonSNP_prob_h2g_baseline,NA,prob_h2g,total_pve,NA)
  }else {
    total_pve <- ctwas_parameters$total_pve
    
    total_nonSNP_prob_h2g <- (1- ctwas_parameters$prop_heritability["SNP"])*100
    nonSNP_prob_h2g_gain <- total_nonSNP_prob_h2g - total_nonSNP_prob_h2g_baseline
    
    
    prob_h2g <- round(as.numeric(ctwas_parameters$prop_heritability[paste0(c(baseline_tissue,tissue),"|eQTL")]*100),digits = 4)
    
    h2g_v_tissue <- c(tissue, total_nonSNP_prob_h2g,nonSNP_prob_h2g_gain,prob_h2g,total_pve,NA)
    
  }
  
  all <- rbind(all,h2g_v_tissue)
  
}


colnames(all) <- c("extra_tissue","total_nonSNP_prob_h2g(%)","nonSNP_prob_h2g_gain(%)",paste0("%h2g_",c(baseline_tissue)),"%h2g_extra_tissue","pve_gain")
all <- as.data.frame(all)

all <- all %>%
  dplyr::mutate(across(where(is.character), ~ as.numeric(.x))) %>%  # Convert character columns to numeric
  dplyr::mutate(across(where(is.numeric), ~ round(.x, digits = 4))) # Round numeric columns

all$extra_tissue <- c("baseline",extra_tissue)
rownames(all) <- seq(1:nrow(all))

DT::datatable(all,caption = htmltools::tags$caption( style = 'caption-side: left; text-align: left; color:black;  font-size:150% ;','PVE change after adding extra tissue'),options = list(pageLength = 10) )

Round 2 – baseline_tissue : Artery_Aorta,Heart_Left_Ventricle,Adrenal_Gland,Brain_Cortex

baseline_tissue <- c("Artery_Aorta", "Heart_Left_Ventricle", "Adrenal_Gland","Brain_Cortex")

gwas_n <- samplesize[trait]

result_dir <- paste0("/project/xinhe/xsun/multi_group_ctwas/12.tissue_selection/results/", trait,"_round2", "/")

extra_tissue <- list.files(path = result_dir)
extra_tissue <- extra_tissue[-which(extra_tissue == "baseline")]

all <- c()
for (tissue in c("baseline",extra_tissue)) {
  
  para_file <- paste0(result_dir,tissue,"/",trait,"_",tissue,".param.RDS")
  param <- readRDS(para_file)
  
  ctwas_parameters <- summarize_param(param, gwas_n)
  
  if(tissue == "baseline") {
    
    total_pve <- ctwas_parameters$total_pve
    
    total_nonSNP_prob_h2g_baseline <- (1- ctwas_parameters$prop_heritability["SNP"])*100
    
    prob_h2g <- round(as.numeric(ctwas_parameters$prop_heritability[paste0(c(baseline_tissue),"|eQTL")]*100),digits = 4)
    
    h2g_v_tissue <- c(tissue, total_nonSNP_prob_h2g_baseline,NA,prob_h2g,total_pve,NA)
  }else {
    total_pve <- ctwas_parameters$total_pve
    
    total_nonSNP_prob_h2g <- (1- ctwas_parameters$prop_heritability["SNP"])*100
    nonSNP_prob_h2g_gain <- total_nonSNP_prob_h2g - total_nonSNP_prob_h2g_baseline
    
    
    prob_h2g <- round(as.numeric(ctwas_parameters$prop_heritability[paste0(c(baseline_tissue,tissue),"|eQTL")]*100),digits = 4)
    
    h2g_v_tissue <- c(tissue, total_nonSNP_prob_h2g,nonSNP_prob_h2g_gain,prob_h2g,total_pve,NA)
    
  }
  
  all <- rbind(all,h2g_v_tissue)
  
}


colnames(all) <- c("extra_tissue","total_nonSNP_prob_h2g(%)","nonSNP_prob_h2g_gain(%)",paste0("%h2g_",c(baseline_tissue)),"%h2g_extra_tissue","pve_gain")
all <- as.data.frame(all)

all <- all %>%
  dplyr::mutate(across(where(is.character), ~ as.numeric(.x))) %>%  # Convert character columns to numeric
  dplyr::mutate(across(where(is.numeric), ~ round(.x, digits = 4))) # Round numeric columns

all$extra_tissue <- c("baseline",extra_tissue)
rownames(all) <- seq(1:nrow(all))

DT::datatable(all,caption = htmltools::tags$caption( style = 'caption-side: left; text-align: left; color:black;  font-size:150% ;','PVE change after adding extra tissue'),options = list(pageLength = 10) )

SBP-ukb-a-360 – another baseline selection

Round 1 – baseline_tissue : Artery_Aorta,Artery_Tibial,Adrenal_Gland

trait <- "SBP-ukb-a-360"
baseline_tissue <- c("Artery_Aorta", "Artery_Tibial", "Adrenal_Gland")


gwas_n <- samplesize[trait]

result_dir <- paste0("/project/xinhe/xsun/multi_group_ctwas/12.tissue_selection/results/", trait, "_base2/")

extra_tissue <- list.files(path = result_dir)
extra_tissue <- extra_tissue[-which(extra_tissue == "baseline")]

all <- c()
for (tissue in c("baseline",extra_tissue)) {
  
  para_file <- paste0(result_dir,tissue,"/",trait,"_",tissue,".param.RDS")
  param <- readRDS(para_file)
  
  ctwas_parameters <- summarize_param(param, gwas_n)
  
  if(tissue == "baseline") {
    
    total_pve <- ctwas_parameters$total_pve
    
    total_nonSNP_prob_h2g_baseline <- (1- ctwas_parameters$prop_heritability["SNP"])*100
    
    prob_h2g <- round(as.numeric(ctwas_parameters$prop_heritability[paste0(c(baseline_tissue),"|eQTL")]*100),digits = 4)
    
    h2g_v_tissue <- c(tissue, total_nonSNP_prob_h2g_baseline,NA,prob_h2g,total_pve,NA)
  }else {
    total_pve <- ctwas_parameters$total_pve
    
    total_nonSNP_prob_h2g <- (1- ctwas_parameters$prop_heritability["SNP"])*100
    nonSNP_prob_h2g_gain <- total_nonSNP_prob_h2g - total_nonSNP_prob_h2g_baseline
    
    
    prob_h2g <- round(as.numeric(ctwas_parameters$prop_heritability[paste0(c(baseline_tissue,tissue),"|eQTL")]*100),digits = 4)
    
    h2g_v_tissue <- c(tissue, total_nonSNP_prob_h2g,nonSNP_prob_h2g_gain,prob_h2g,total_pve,NA)
    
  }
  
  all <- rbind(all,h2g_v_tissue)
  
}


colnames(all) <- c("extra_tissue","total_nonSNP_prob_h2g(%)","nonSNP_prob_h2g_gain(%)",paste0("%h2g_",c(baseline_tissue)),"%h2g_extra_tissue","pve_gain")
all <- as.data.frame(all)

all <- all %>%
  dplyr::mutate(across(where(is.character), ~ as.numeric(.x))) %>%  # Convert character columns to numeric
  dplyr::mutate(across(where(is.numeric), ~ round(.x, digits = 4))) # Round numeric columns

all$extra_tissue <- c("baseline",extra_tissue)
rownames(all) <- seq(1:nrow(all))

DT::datatable(all,caption = htmltools::tags$caption( style = 'caption-side: left; text-align: left; color:black;  font-size:150% ;','PVE change after adding extra tissue'),options = list(pageLength = 10) )

Round 2 – baseline_tissue : Artery_Aorta,Heart_Left_Ventricle,Adrenal_Gland,Brain_Cortex

baseline_tissue <- c("Artery_Aorta", "Heart_Left_Ventricle", "Adrenal_Gland","Brain_Cortex")

gwas_n <- samplesize[trait]

result_dir <- paste0("/project/xinhe/xsun/multi_group_ctwas/12.tissue_selection/results/", trait, "_base2_round2", "/")

extra_tissue <- list.files(path = result_dir)
extra_tissue <- extra_tissue[-which(extra_tissue == "baseline")]

all <- c()
for (tissue in c("baseline",extra_tissue)) {
  
  para_file <- paste0(result_dir,tissue,"/",trait,"_",tissue,".param.RDS")
  param <- readRDS(para_file)
  
  ctwas_parameters <- summarize_param(param, gwas_n)
  
  if(tissue == "baseline") {
    
    total_pve <- ctwas_parameters$total_pve
    
    total_nonSNP_prob_h2g_baseline <- (1- ctwas_parameters$prop_heritability["SNP"])*100
    
    prob_h2g <- round(as.numeric(ctwas_parameters$prop_heritability[paste0(c(baseline_tissue),"|eQTL")]*100),digits = 4)
    
    h2g_v_tissue <- c(tissue, total_nonSNP_prob_h2g_baseline,NA,prob_h2g,total_pve,NA)
  }else {
    total_pve <- ctwas_parameters$total_pve
    
    total_nonSNP_prob_h2g <- (1- ctwas_parameters$prop_heritability["SNP"])*100
    nonSNP_prob_h2g_gain <- total_nonSNP_prob_h2g - total_nonSNP_prob_h2g_baseline
    
    
    prob_h2g <- round(as.numeric(ctwas_parameters$prop_heritability[paste0(c(baseline_tissue,tissue),"|eQTL")]*100),digits = 4)
    
    h2g_v_tissue <- c(tissue, total_nonSNP_prob_h2g,nonSNP_prob_h2g_gain,prob_h2g,total_pve,NA)
    
  }
  
  all <- rbind(all,h2g_v_tissue)
  
}


colnames(all) <- c("extra_tissue","total_nonSNP_prob_h2g(%)","nonSNP_prob_h2g_gain(%)",paste0("%h2g_",c(baseline_tissue)),"%h2g_extra_tissue","pve_gain")
all <- as.data.frame(all)

all <- all %>%
  dplyr::mutate(across(where(is.character), ~ as.numeric(.x))) %>%  # Convert character columns to numeric
  dplyr::mutate(across(where(is.numeric), ~ round(.x, digits = 4))) # Round numeric columns

all$extra_tissue <- c("baseline",extra_tissue)
rownames(all) <- seq(1:nrow(all))

DT::datatable(all,caption = htmltools::tags$caption( style = 'caption-side: left; text-align: left; color:black;  font-size:150% ;','PVE change after adding extra tissue'),options = list(pageLength = 10) )

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] C

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

other attached packages:
[1] dplyr_1.1.4  ctwas_0.4.19

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] GenomicRanges_1.48.0        fs_1.5.2                   
  [9] rstudioapi_0.13             DT_0.22                    
 [11] ggrepel_0.9.1               bit64_4.0.5                
 [13] AnnotationDbi_1.58.0        fansi_1.0.3                
 [15] xml2_1.3.3                  codetools_0.2-18           
 [17] logging_0.10-108            cachem_1.0.6               
 [19] knitr_1.39                  jsonlite_1.8.0             
 [21] workflowr_1.7.0             Rsamtools_2.12.0           
 [23] dbplyr_2.1.1                png_0.1-7                  
 [25] readr_2.1.2                 compiler_4.2.0             
 [27] httr_1.4.3                  assertthat_0.2.1           
 [29] Matrix_1.5-3                fastmap_1.1.0              
 [31] lazyeval_0.2.2              cli_3.6.1                  
 [33] later_1.3.0                 htmltools_0.5.2            
 [35] prettyunits_1.1.1           tools_4.2.0                
 [37] gtable_0.3.0                glue_1.6.2                 
 [39] GenomeInfoDbData_1.2.8      rappdirs_0.3.3             
 [41] Rcpp_1.0.12                 Biobase_2.56.0             
 [43] jquerylib_0.1.4             vctrs_0.6.5                
 [45] Biostrings_2.64.0           rtracklayer_1.56.0         
 [47] crosstalk_1.2.0             xfun_0.41                  
 [49] stringr_1.5.1               lifecycle_1.0.4            
 [51] irlba_2.3.5                 restfulr_0.0.14            
 [53] ensembldb_2.20.2            XML_3.99-0.14              
 [55] zlibbioc_1.42.0             zoo_1.8-10                 
 [57] scales_1.3.0                gggrid_0.2-0               
 [59] hms_1.1.1                   promises_1.2.0.1           
 [61] MatrixGenerics_1.8.0        ProtGenerics_1.28.0        
 [63] parallel_4.2.0              SummarizedExperiment_1.26.1
 [65] AnnotationFilter_1.20.0     LDlinkR_1.2.3              
 [67] yaml_2.3.5                  curl_4.3.2                 
 [69] memoise_2.0.1               ggplot2_3.5.1              
 [71] sass_0.4.1                  biomaRt_2.54.1             
 [73] stringi_1.7.6               RSQLite_2.3.1              
 [75] S4Vectors_0.34.0            BiocIO_1.6.0               
 [77] GenomicFeatures_1.48.3      BiocGenerics_0.42.0        
 [79] filelock_1.0.2              BiocParallel_1.30.3        
 [81] GenomeInfoDb_1.39.9         rlang_1.1.2                
 [83] pkgconfig_2.0.3             matrixStats_0.62.0         
 [85] bitops_1.0-7                evaluate_0.15              
 [87] lattice_0.20-45             purrr_1.0.2                
 [89] GenomicAlignments_1.32.0    htmlwidgets_1.5.4          
 [91] cowplot_1.1.1               bit_4.0.4                  
 [93] tidyselect_1.2.0            magrittr_2.0.3             
 [95] R6_2.5.1                    IRanges_2.30.0             
 [97] generics_0.1.2              DelayedArray_0.22.0        
 [99] DBI_1.2.2                   withr_2.5.0                
[101] pgenlibr_0.3.3              pillar_1.9.0               
[103] whisker_0.4                 KEGGREST_1.36.3            
[105] RCurl_1.98-1.7              mixsqp_0.3-43              
[107] tibble_3.2.1                crayon_1.5.1               
[109] utf8_1.2.2                  BiocFileCache_2.4.0        
[111] plotly_4.10.0               tzdb_0.4.0                 
[113] rmarkdown_2.25              progress_1.2.2             
[115] grid_4.2.0                  data.table_1.14.2          
[117] blob_1.2.3                  git2r_0.30.1               
[119] digest_0.6.29               tidyr_1.3.0                
[121] httpuv_1.6.5                stats4_4.2.0               
[123] munsell_0.5.0               viridisLite_0.4.0          
[125] bslib_0.3.1