Last updated: 2025-04-25

Checks: 6 1

Knit directory: multigroup_ctwas_analysis/

This reproducible R Markdown analysis was created with workflowr (version 1.7.1). 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 aff96ad. 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/

Untracked files:
    Untracked:  slurm-30623874.out
    Untracked:  slurm-30624233.out
    Untracked:  slurm-30624452.out
    Untracked:  slurm-30624453.out

Unstaged changes:
    Modified:   analysis/comparing_differnt_settings_ldmm.Rmd
    Modified:   knitrmd.sbatch

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/comparing_differnt_settings_ldmm.Rmd) and HTML (docs/comparing_differnt_settings_ldmm.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 6e49457 XSun 2025-04-17 update
html 6e49457 XSun 2025-04-17 update
Rmd c9f6691 XSun 2025-04-17 update
html c9f6691 XSun 2025-04-17 update
Rmd 8ee6c92 XSun 2025-04-16 update
Rmd 82784b3 XSun 2025-04-08 update
html 82784b3 XSun 2025-04-08 update
Rmd 4c80969 XSun 2025-02-24 update

Introduction

We compare different ld - mismatch settings

  • remove the ld-mismatched snp, recompute the z-scores and re-do the finemapping
  • re-finemap without LD
library(ggplot2)
library(ctwas)
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
folder_results_susieST <- "/project/xinhe/xsun/multi_group_ctwas/15.susie_weights/snakemake_outputs/"

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)

IBD-ebi-a-GCST004131

Setting: shared_all, thin = 1, L = 5, susieST

trait <- "IBD-ebi-a-GCST004131"
thin <- 1
var_struc <- "shared_all"
st <- "with_susieST"
L <- 5

ctwas_res_origin <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".finemap_regions_res.RDS"))
finemap_res_origin <- ctwas_res_origin$finemap_res
finemap_res_gene_origin <- finemap_res_origin[finemap_res_origin$type != "SNP",]

ctwas_res_regionmerge <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".regionmerge_finemap_regions_res.RDS"))
finemap_res_regionmerge <- ctwas_res_regionmerge$finemap_res
finemap_res_gene_regionmerge <- finemap_res_regionmerge[finemap_res_regionmerge$type != "SNP",]

df_summary <- c()

susie_alpha_res_regionmerge <- ctwas_res_regionmerge$susie_alpha_res
susie_alpha_res_regionmerge <- anno_susie_alpha_res(susie_alpha_res_regionmerge,
                                        mapping_table = mapping_two,
                                        map_by = "molecular_id",
                                        drop_unmapped = TRUE)
2025-04-25 11:58:04 INFO::Annotating susie alpha result ...
2025-04-25 11:58:06 INFO::Map molecular traits to genes
2025-04-25 11:58:10 INFO::Split PIPs for molecular traits mapped to multiple genes
combined_pip_by_group_regionmerge <- combine_gene_pips(susie_alpha_res_regionmerge,
                                           group_by = "gene_name",
                                           by = "group",
                                           method = "combine_cs",
                                           filter_cs = TRUE,
                                           include_cs_id = F)

Thresholds for ld mismatch diagnosis: nonSNP PIP = 0.5, SNP p_diff = 5e-8

threshold_nonSNP_PIPs <- 0.5
threshold_SNP_p <- "5e-08"
file_res_ldmm <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

res_ldmm <- readRDS(file_res_ldmm)
n_problematic_snp <- length(res_ldmm$problematic_snps)

file_problematic_genes <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

if(file.exists(file_problematic_genes)) {
  
  problematic_genes <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  n_problematic_gene <- length(problematic_genes)
  
  finemap_res_gene_origin$highlight <- ifelse(finemap_res_gene_origin$id %in% problematic_genes, "problematic genes", "good genes")
  
  p1 <- ggplot(data = finemap_res_gene_origin, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("Original ctwas results") +
    theme_minimal()
  
  finemap_res_gene_regionmerge$highlight <- ifelse(finemap_res_gene_regionmerge$id %in% problematic_genes, "problematic genes", "good genes")
  
  p2 <- ggplot(data = finemap_res_gene_regionmerge, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("After region merge") +
    theme_minimal()
  
  ctwas_res_ldmismatch <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatch <- ctwas_res_ldmismatch$finemap_res
  finemap_res_gene_ldmismatch <- finemap_res_ldmismatch[finemap_res_ldmismatch$type != "SNP",]
  finemap_res_gene_ldmismatch$highlight <- ifelse(finemap_res_gene_ldmismatch$id %in% problematic_genes, "problematic genes", "good genes")
  
  p3 <- ggplot(data = finemap_res_gene_ldmismatch, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  ctwas_res_ldmismatchnoLD <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_noLD_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatchnoLD <- ctwas_res_ldmismatchnoLD$finemap_res
  finemap_res_gene_ldmismatchnoLD <- finemap_res_ldmismatchnoLD[finemap_res_ldmismatchnoLD$type != "SNP",]
  finemap_res_gene_ldmismatchnoLD$highlight <- ifelse(finemap_res_gene_ldmismatchnoLD$id %in% problematic_genes, "problematic genes", "good genes")
  
  p4 <- ggplot(data = finemap_res_gene_ldmismatchnoLD, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  grid::grid.newpage()
  gridExtra::grid.arrange(p1,p2,p3,p4,
                          ncol = 4,
                          top = paste0(trait,"-nonSNP_PIPs:",threshold_nonSNP_PIPs,"-SNP_p:",threshold_SNP_p))
  
  
  
  susie_alpha_res_ldmismatch <- ctwas_res_ldmismatch$susie_alpha_res
  susie_alpha_res_ldmismatch <- anno_susie_alpha_res(susie_alpha_res_ldmismatch,
                                                     mapping_table = mapping_two,
                                                     map_by = "molecular_id",
                                                     drop_unmapped = TRUE)
  combined_pip_by_group_ldmismatch <- combine_gene_pips(susie_alpha_res_ldmismatch,
                                                        group_by = "gene_name",
                                                        by = "group",
                                                        method = "combine_cs",
                                                        filter_cs = TRUE,
                                                        include_cs_id = F)
  
  
  susie_alpha_res_ldmismatchnoLD <- ctwas_res_ldmismatchnoLD$susie_alpha_res
  susie_alpha_res_ldmismatchnoLD <- anno_susie_alpha_res(susie_alpha_res_ldmismatchnoLD,
                                                         mapping_table = mapping_two,
                                                         map_by = "molecular_id",
                                                         drop_unmapped = TRUE)
  combined_pip_by_group_ldmismatchnoLD <- combine_gene_pips(susie_alpha_res_ldmismatchnoLD,
                                                            group_by = "gene_name",
                                                            by = "group",
                                                            method = "combine_cs",
                                                            filter_cs = TRUE,
                                                            include_cs_id = F)
  
  combined_pip_by_group_ldmismatch <- combined_pip_by_group_ldmismatch[,c("gene_name","combined_pip")]
  combined_pip_by_group_regionmerge <- combined_pip_by_group_regionmerge[,c("gene_name","combined_pip")]
  combined_pip_by_group_ldmismatchnoLD <- combined_pip_by_group_ldmismatchnoLD[,c("gene_name","combined_pip")]
  
  
  merged <- merge(combined_pip_by_group_regionmerge,combined_pip_by_group_ldmismatch, by = "gene_name", all.x = T)
  merged <- merge(merged,combined_pip_by_group_ldmismatchnoLD, by = "gene_name", all.x = T)
  
  colnames(merged) <- c("gene_name","combined_pip_regionmerge", "combined_pip_ldmismatch_remove", "combined_pip_ldmismatchnoLD")
  
  genes_diff <- merged %>%
    rowwise() %>%
    dplyr::filter(n_distinct(c(combined_pip_regionmerge, combined_pip_ldmismatch_remove, combined_pip_ldmismatchnoLD)) > 1)
  
  
  known <- readRDS(paste0("/project/xinhe/xsun/multi_group_ctwas/data/silverstandard/known_annotations_IBD.RDS"))
  bystander <- readRDS(paste0("/project/xinhe/xsun/multi_group_ctwas/data/silverstandard/bystanders_IBD.RDS"))
  
  genes_diff <- genes_diff %>%
    mutate(
      is_silver = gene_name %in% known,
      is_bystander = gene_name %in% bystander
    )

  
}else {
  
  n_problematic_gene <- 0
  
}

Version Author Date
c9f6691 XSun 2025-04-17
82784b3 XSun 2025-04-08
2025-04-25 12:01:03 INFO::Annotating susie alpha result ...
2025-04-25 12:01:04 INFO::Map molecular traits to genes
2025-04-25 12:01:08 INFO::Split PIPs for molecular traits mapped to multiple genes
2025-04-25 12:02:13 INFO::Annotating susie alpha result ...
2025-04-25 12:02:14 INFO::Map molecular traits to genes
2025-04-25 12:02:16 INFO::Split PIPs for molecular traits mapped to multiple genes
# setting <- paste0("thin",thin,".",var_struc,".L",L,".genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)
setting <- paste0("genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)

tmp <- c(setting, n_problematic_snp, n_problematic_gene)

df_summary <- rbind(df_summary,tmp)

DT::datatable(genes_diff,caption = htmltools::tags$caption( style = 'caption-side: left; text-align: left; color:black;  font-size:150% ;','Genes -- PIP changed'),options = list(pageLength = 10) )

Thresholds for ld mismatch diagnosis: nonSNP PIP = 0.5, SNP p_diff = 5e-6

threshold_nonSNP_PIPs <- 0.5
threshold_SNP_p <- "5e-06"
file_res_ldmm <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

res_ldmm <- readRDS(file_res_ldmm)
n_problematic_snp <- length(res_ldmm$problematic_snps)

file_problematic_genes <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

if(file.exists(file_problematic_genes)) {
  
  problematic_genes <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  n_problematic_gene <- length(problematic_genes)
  
  finemap_res_gene_origin$highlight <- ifelse(finemap_res_gene_origin$id %in% problematic_genes, "problematic genes", "good genes")
  
  p1 <- ggplot(data = finemap_res_gene_origin, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("Original ctwas results") +
    theme_minimal()
  
  finemap_res_gene_regionmerge$highlight <- ifelse(finemap_res_gene_regionmerge$id %in% problematic_genes, "problematic genes", "good genes")
  
  p2 <- ggplot(data = finemap_res_gene_regionmerge, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("After region merge") +
    theme_minimal()
  
  ctwas_res_ldmismatch <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatch <- ctwas_res_ldmismatch$finemap_res
  finemap_res_gene_ldmismatch <- finemap_res_ldmismatch[finemap_res_ldmismatch$type != "SNP",]
  finemap_res_gene_ldmismatch$highlight <- ifelse(finemap_res_gene_ldmismatch$id %in% problematic_genes, "problematic genes", "good genes")
  
  p3 <- ggplot(data = finemap_res_gene_ldmismatch, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  ctwas_res_ldmismatchnoLD <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_noLD_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatchnoLD <- ctwas_res_ldmismatchnoLD$finemap_res
  finemap_res_gene_ldmismatchnoLD <- finemap_res_ldmismatchnoLD[finemap_res_ldmismatchnoLD$type != "SNP",]
  finemap_res_gene_ldmismatchnoLD$highlight <- ifelse(finemap_res_gene_ldmismatchnoLD$id %in% problematic_genes, "problematic genes", "good genes")
  
  p4 <- ggplot(data = finemap_res_gene_ldmismatchnoLD, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  grid::grid.newpage()
  gridExtra::grid.arrange(p1,p2,p3,p4,
                          ncol = 4,
                          top = paste0(trait,"-nonSNP_PIPs:",threshold_nonSNP_PIPs,"-SNP_p:",threshold_SNP_p))
  
  
  
  susie_alpha_res_ldmismatch <- ctwas_res_ldmismatch$susie_alpha_res
  susie_alpha_res_ldmismatch <- anno_susie_alpha_res(susie_alpha_res_ldmismatch,
                                                     mapping_table = mapping_two,
                                                     map_by = "molecular_id",
                                                     drop_unmapped = TRUE)
  combined_pip_by_group_ldmismatch <- combine_gene_pips(susie_alpha_res_ldmismatch,
                                                        group_by = "gene_name",
                                                        by = "group",
                                                        method = "combine_cs",
                                                        filter_cs = TRUE,
                                                        include_cs_id = F)
  
  
  susie_alpha_res_ldmismatchnoLD <- ctwas_res_ldmismatchnoLD$susie_alpha_res
  susie_alpha_res_ldmismatchnoLD <- anno_susie_alpha_res(susie_alpha_res_ldmismatchnoLD,
                                                         mapping_table = mapping_two,
                                                         map_by = "molecular_id",
                                                         drop_unmapped = TRUE)
  combined_pip_by_group_ldmismatchnoLD <- combine_gene_pips(susie_alpha_res_ldmismatchnoLD,
                                                            group_by = "gene_name",
                                                            by = "group",
                                                            method = "combine_cs",
                                                            filter_cs = TRUE,
                                                            include_cs_id = F)
  
  combined_pip_by_group_ldmismatch <- combined_pip_by_group_ldmismatch[,c("gene_name","combined_pip")]
  combined_pip_by_group_regionmerge <- combined_pip_by_group_regionmerge[,c("gene_name","combined_pip")]
  combined_pip_by_group_ldmismatchnoLD <- combined_pip_by_group_ldmismatchnoLD[,c("gene_name","combined_pip")]
  
  
  merged <- merge(combined_pip_by_group_regionmerge,combined_pip_by_group_ldmismatch, by = "gene_name", all.x = T)
  merged <- merge(merged,combined_pip_by_group_ldmismatchnoLD, by = "gene_name", all.x = T)
  
  colnames(merged) <- c("gene_name","combined_pip_regionmerge", "combined_pip_ldmismatch_remove", "combined_pip_ldmismatchnoLD")
  
  genes_diff <- merged %>%
    rowwise() %>%
    dplyr::filter(n_distinct(c(combined_pip_regionmerge, combined_pip_ldmismatch_remove, combined_pip_ldmismatchnoLD)) > 1)
  
  
  known <- readRDS(paste0("/project/xinhe/xsun/multi_group_ctwas/data/silverstandard/known_annotations_IBD.RDS"))
  bystander <- readRDS(paste0("/project/xinhe/xsun/multi_group_ctwas/data/silverstandard/bystanders_IBD.RDS"))
  
  genes_diff <- genes_diff %>%
    mutate(
      is_silver = gene_name %in% known,
      is_bystander = gene_name %in% bystander
    )

  
}else {
  
  n_problematic_gene <- 0
  
}

Version Author Date
c9f6691 XSun 2025-04-17
82784b3 XSun 2025-04-08
2025-04-25 12:05:38 INFO::Annotating susie alpha result ...
2025-04-25 12:05:39 INFO::Map molecular traits to genes
2025-04-25 12:05:45 INFO::Split PIPs for molecular traits mapped to multiple genes
2025-04-25 12:06:47 INFO::Annotating susie alpha result ...
2025-04-25 12:06:48 INFO::Map molecular traits to genes
2025-04-25 12:06:50 INFO::Split PIPs for molecular traits mapped to multiple genes
# setting <- paste0("thin",thin,".",var_struc,".L",L,".genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)
setting <- paste0("genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)

tmp <- c(setting, n_problematic_snp, n_problematic_gene)

df_summary <- rbind(df_summary,tmp)

DT::datatable(genes_diff,caption = htmltools::tags$caption( style = 'caption-side: left; text-align: left; color:black;  font-size:150% ;','Genes -- PIP changed'),options = list(pageLength = 10) )

Thresholds for ld mismatch diagnosis: nonSNP PIP = 0.2, SNP p_diff = 5e-8

threshold_nonSNP_PIPs <- 0.2
threshold_SNP_p <- "5e-08"
file_res_ldmm <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

res_ldmm <- readRDS(file_res_ldmm)
n_problematic_snp <- length(res_ldmm$problematic_snps)

file_problematic_genes <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

if(file.exists(file_problematic_genes)) {
  
  problematic_genes <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  n_problematic_gene <- length(problematic_genes)
  
  finemap_res_gene_origin$highlight <- ifelse(finemap_res_gene_origin$id %in% problematic_genes, "problematic genes", "good genes")
  
  p1 <- ggplot(data = finemap_res_gene_origin, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("Original ctwas results") +
    theme_minimal()
  
  finemap_res_gene_regionmerge$highlight <- ifelse(finemap_res_gene_regionmerge$id %in% problematic_genes, "problematic genes", "good genes")
  
  p2 <- ggplot(data = finemap_res_gene_regionmerge, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("After region merge") +
    theme_minimal()
  
  ctwas_res_ldmismatch <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatch <- ctwas_res_ldmismatch$finemap_res
  finemap_res_gene_ldmismatch <- finemap_res_ldmismatch[finemap_res_ldmismatch$type != "SNP",]
  finemap_res_gene_ldmismatch$highlight <- ifelse(finemap_res_gene_ldmismatch$id %in% problematic_genes, "problematic genes", "good genes")
  
  p3 <- ggplot(data = finemap_res_gene_ldmismatch, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  ctwas_res_ldmismatchnoLD <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_noLD_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatchnoLD <- ctwas_res_ldmismatchnoLD$finemap_res
  finemap_res_gene_ldmismatchnoLD <- finemap_res_ldmismatchnoLD[finemap_res_ldmismatchnoLD$type != "SNP",]
  finemap_res_gene_ldmismatchnoLD$highlight <- ifelse(finemap_res_gene_ldmismatchnoLD$id %in% problematic_genes, "problematic genes", "good genes")
  
  p4 <- ggplot(data = finemap_res_gene_ldmismatchnoLD, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  grid::grid.newpage()
  gridExtra::grid.arrange(p1,p2,p3,p4,
                          ncol = 4,
                          top = paste0(trait,"-nonSNP_PIPs:",threshold_nonSNP_PIPs,"-SNP_p:",threshold_SNP_p))
  
  
  
  susie_alpha_res_ldmismatch <- ctwas_res_ldmismatch$susie_alpha_res
  susie_alpha_res_ldmismatch <- anno_susie_alpha_res(susie_alpha_res_ldmismatch,
                                                     mapping_table = mapping_two,
                                                     map_by = "molecular_id",
                                                     drop_unmapped = TRUE)
  combined_pip_by_group_ldmismatch <- combine_gene_pips(susie_alpha_res_ldmismatch,
                                                        group_by = "gene_name",
                                                        by = "group",
                                                        method = "combine_cs",
                                                        filter_cs = TRUE,
                                                        include_cs_id = F)
  
  
  susie_alpha_res_ldmismatchnoLD <- ctwas_res_ldmismatchnoLD$susie_alpha_res
  susie_alpha_res_ldmismatchnoLD <- anno_susie_alpha_res(susie_alpha_res_ldmismatchnoLD,
                                                         mapping_table = mapping_two,
                                                         map_by = "molecular_id",
                                                         drop_unmapped = TRUE)
  combined_pip_by_group_ldmismatchnoLD <- combine_gene_pips(susie_alpha_res_ldmismatchnoLD,
                                                            group_by = "gene_name",
                                                            by = "group",
                                                            method = "combine_cs",
                                                            filter_cs = TRUE,
                                                            include_cs_id = F)
  
  combined_pip_by_group_ldmismatch <- combined_pip_by_group_ldmismatch[,c("gene_name","combined_pip")]
  combined_pip_by_group_regionmerge <- combined_pip_by_group_regionmerge[,c("gene_name","combined_pip")]
  combined_pip_by_group_ldmismatchnoLD <- combined_pip_by_group_ldmismatchnoLD[,c("gene_name","combined_pip")]
  
  
  merged <- merge(combined_pip_by_group_regionmerge,combined_pip_by_group_ldmismatch, by = "gene_name", all.x = T)
  merged <- merge(merged,combined_pip_by_group_ldmismatchnoLD, by = "gene_name", all.x = T)
  
  colnames(merged) <- c("gene_name","combined_pip_regionmerge", "combined_pip_ldmismatch_remove", "combined_pip_ldmismatchnoLD")
  
  genes_diff <- merged %>%
    rowwise() %>%
    dplyr::filter(n_distinct(c(combined_pip_regionmerge, combined_pip_ldmismatch_remove, combined_pip_ldmismatchnoLD)) > 1)
  
  
  known <- readRDS(paste0("/project/xinhe/xsun/multi_group_ctwas/data/silverstandard/known_annotations_IBD.RDS"))
  bystander <- readRDS(paste0("/project/xinhe/xsun/multi_group_ctwas/data/silverstandard/bystanders_IBD.RDS"))
  
  genes_diff <- genes_diff %>%
    mutate(
      is_silver = gene_name %in% known,
      is_bystander = gene_name %in% bystander
    )

  
}else {
  
  n_problematic_gene <- 0
  
}

Version Author Date
c9f6691 XSun 2025-04-17
82784b3 XSun 2025-04-08
2025-04-25 12:10:13 INFO::Annotating susie alpha result ...
2025-04-25 12:10:13 INFO::Map molecular traits to genes
2025-04-25 12:10:15 INFO::Split PIPs for molecular traits mapped to multiple genes
2025-04-25 12:11:18 INFO::Annotating susie alpha result ...
2025-04-25 12:11:19 INFO::Map molecular traits to genes
2025-04-25 12:11:21 INFO::Split PIPs for molecular traits mapped to multiple genes
# setting <- paste0("thin",thin,".",var_struc,".L",L,".genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)
setting <- paste0("genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)

tmp <- c(setting, n_problematic_snp, n_problematic_gene)

df_summary <- rbind(df_summary,tmp)

DT::datatable(genes_diff,caption = htmltools::tags$caption( style = 'caption-side: left; text-align: left; color:black;  font-size:150% ;','Genes -- PIP changed'),options = list(pageLength = 10) )

Thresholds for ld mismatch diagnosis: nonSNP PIP = 0.2, SNP p_diff = 5e-6

threshold_nonSNP_PIPs <- 0.2
threshold_SNP_p <- "5e-06"
file_res_ldmm <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

res_ldmm <- readRDS(file_res_ldmm)
n_problematic_snp <- length(res_ldmm$problematic_snps)

file_problematic_genes <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

if(file.exists(file_problematic_genes)) {
  
  problematic_genes <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  n_problematic_gene <- length(problematic_genes)
  
  finemap_res_gene_origin$highlight <- ifelse(finemap_res_gene_origin$id %in% problematic_genes, "problematic genes", "good genes")
  
  p1 <- ggplot(data = finemap_res_gene_origin, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("Original ctwas results") +
    theme_minimal()
  
  finemap_res_gene_regionmerge$highlight <- ifelse(finemap_res_gene_regionmerge$id %in% problematic_genes, "problematic genes", "good genes")
  
  p2 <- ggplot(data = finemap_res_gene_regionmerge, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("After region merge") +
    theme_minimal()
  
  ctwas_res_ldmismatch <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatch <- ctwas_res_ldmismatch$finemap_res
  finemap_res_gene_ldmismatch <- finemap_res_ldmismatch[finemap_res_ldmismatch$type != "SNP",]
  finemap_res_gene_ldmismatch$highlight <- ifelse(finemap_res_gene_ldmismatch$id %in% problematic_genes, "problematic genes", "good genes")
  
  p3 <- ggplot(data = finemap_res_gene_ldmismatch, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  ctwas_res_ldmismatchnoLD <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_noLD_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatchnoLD <- ctwas_res_ldmismatchnoLD$finemap_res
  finemap_res_gene_ldmismatchnoLD <- finemap_res_ldmismatchnoLD[finemap_res_ldmismatchnoLD$type != "SNP",]
  finemap_res_gene_ldmismatchnoLD$highlight <- ifelse(finemap_res_gene_ldmismatchnoLD$id %in% problematic_genes, "problematic genes", "good genes")
  
  p4 <- ggplot(data = finemap_res_gene_ldmismatchnoLD, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  grid::grid.newpage()
  gridExtra::grid.arrange(p1,p2,p3,p4,
                          ncol = 4,
                          top = paste0(trait,"-nonSNP_PIPs:",threshold_nonSNP_PIPs,"-SNP_p:",threshold_SNP_p))
  
  
  
  susie_alpha_res_ldmismatch <- ctwas_res_ldmismatch$susie_alpha_res
  susie_alpha_res_ldmismatch <- anno_susie_alpha_res(susie_alpha_res_ldmismatch,
                                                     mapping_table = mapping_two,
                                                     map_by = "molecular_id",
                                                     drop_unmapped = TRUE)
  combined_pip_by_group_ldmismatch <- combine_gene_pips(susie_alpha_res_ldmismatch,
                                                        group_by = "gene_name",
                                                        by = "group",
                                                        method = "combine_cs",
                                                        filter_cs = TRUE,
                                                        include_cs_id = F)
  
  
  susie_alpha_res_ldmismatchnoLD <- ctwas_res_ldmismatchnoLD$susie_alpha_res
  susie_alpha_res_ldmismatchnoLD <- anno_susie_alpha_res(susie_alpha_res_ldmismatchnoLD,
                                                         mapping_table = mapping_two,
                                                         map_by = "molecular_id",
                                                         drop_unmapped = TRUE)
  combined_pip_by_group_ldmismatchnoLD <- combine_gene_pips(susie_alpha_res_ldmismatchnoLD,
                                                            group_by = "gene_name",
                                                            by = "group",
                                                            method = "combine_cs",
                                                            filter_cs = TRUE,
                                                            include_cs_id = F)
  
  combined_pip_by_group_ldmismatch <- combined_pip_by_group_ldmismatch[,c("gene_name","combined_pip")]
  combined_pip_by_group_regionmerge <- combined_pip_by_group_regionmerge[,c("gene_name","combined_pip")]
  combined_pip_by_group_ldmismatchnoLD <- combined_pip_by_group_ldmismatchnoLD[,c("gene_name","combined_pip")]
  
  
  merged <- merge(combined_pip_by_group_regionmerge,combined_pip_by_group_ldmismatch, by = "gene_name", all.x = T)
  merged <- merge(merged,combined_pip_by_group_ldmismatchnoLD, by = "gene_name", all.x = T)
  
  colnames(merged) <- c("gene_name","combined_pip_regionmerge", "combined_pip_ldmismatch_remove", "combined_pip_ldmismatchnoLD")
  
  genes_diff <- merged %>%
    rowwise() %>%
    dplyr::filter(n_distinct(c(combined_pip_regionmerge, combined_pip_ldmismatch_remove, combined_pip_ldmismatchnoLD)) > 1)
  
  
  known <- readRDS(paste0("/project/xinhe/xsun/multi_group_ctwas/data/silverstandard/known_annotations_IBD.RDS"))
  bystander <- readRDS(paste0("/project/xinhe/xsun/multi_group_ctwas/data/silverstandard/bystanders_IBD.RDS"))
  
  genes_diff <- genes_diff %>%
    mutate(
      is_silver = gene_name %in% known,
      is_bystander = gene_name %in% bystander
    )

  
}else {
  
  n_problematic_gene <- 0
  
}

Version Author Date
c9f6691 XSun 2025-04-17
82784b3 XSun 2025-04-08
2025-04-25 12:14:41 INFO::Annotating susie alpha result ...
2025-04-25 12:14:42 INFO::Map molecular traits to genes
2025-04-25 12:14:44 INFO::Split PIPs for molecular traits mapped to multiple genes
2025-04-25 12:15:47 INFO::Annotating susie alpha result ...
2025-04-25 12:15:48 INFO::Map molecular traits to genes
2025-04-25 12:15:50 INFO::Split PIPs for molecular traits mapped to multiple genes
# setting <- paste0("thin",thin,".",var_struc,".L",L,".genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)
setting <- paste0("genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)

tmp <- c(setting, n_problematic_snp, n_problematic_gene)

df_summary <- rbind(df_summary,tmp)

DT::datatable(genes_diff,caption = htmltools::tags$caption( style = 'caption-side: left; text-align: left; color:black;  font-size:150% ;','Genes -- PIP changed'),options = list(pageLength = 10) )

Thresholds for ld mismatch diagnosis: nonSNP PIP = 0.2, SNP p_diff = 5e-4

threshold_nonSNP_PIPs <- 0.2
threshold_SNP_p <- "5e-04"
file_res_ldmm <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

res_ldmm <- readRDS(file_res_ldmm)
n_problematic_snp <- length(res_ldmm$problematic_snps)

file_problematic_genes <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

if(file.exists(file_problematic_genes)) {
  
  problematic_genes <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  n_problematic_gene <- length(problematic_genes)
  
  finemap_res_gene_origin$highlight <- ifelse(finemap_res_gene_origin$id %in% problematic_genes, "problematic genes", "good genes")
  
  p1 <- ggplot(data = finemap_res_gene_origin, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("Original ctwas results") +
    theme_minimal()
  
  finemap_res_gene_regionmerge$highlight <- ifelse(finemap_res_gene_regionmerge$id %in% problematic_genes, "problematic genes", "good genes")
  
  p2 <- ggplot(data = finemap_res_gene_regionmerge, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("After region merge") +
    theme_minimal()
  
  ctwas_res_ldmismatch <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatch <- ctwas_res_ldmismatch$finemap_res
  finemap_res_gene_ldmismatch <- finemap_res_ldmismatch[finemap_res_ldmismatch$type != "SNP",]
  finemap_res_gene_ldmismatch$highlight <- ifelse(finemap_res_gene_ldmismatch$id %in% problematic_genes, "problematic genes", "good genes")
  
  p3 <- ggplot(data = finemap_res_gene_ldmismatch, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  ctwas_res_ldmismatchnoLD <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_noLD_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatchnoLD <- ctwas_res_ldmismatchnoLD$finemap_res
  finemap_res_gene_ldmismatchnoLD <- finemap_res_ldmismatchnoLD[finemap_res_ldmismatchnoLD$type != "SNP",]
  finemap_res_gene_ldmismatchnoLD$highlight <- ifelse(finemap_res_gene_ldmismatchnoLD$id %in% problematic_genes, "problematic genes", "good genes")
  
  p4 <- ggplot(data = finemap_res_gene_ldmismatchnoLD, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  grid::grid.newpage()
  gridExtra::grid.arrange(p1,p2,p3,p4,
                          ncol = 4,
                          top = paste0(trait,"-nonSNP_PIPs:",threshold_nonSNP_PIPs,"-SNP_p:",threshold_SNP_p))
  
  
  
  susie_alpha_res_ldmismatch <- ctwas_res_ldmismatch$susie_alpha_res
  susie_alpha_res_ldmismatch <- anno_susie_alpha_res(susie_alpha_res_ldmismatch,
                                                     mapping_table = mapping_two,
                                                     map_by = "molecular_id",
                                                     drop_unmapped = TRUE)
  combined_pip_by_group_ldmismatch <- combine_gene_pips(susie_alpha_res_ldmismatch,
                                                        group_by = "gene_name",
                                                        by = "group",
                                                        method = "combine_cs",
                                                        filter_cs = TRUE,
                                                        include_cs_id = F)
  
  
  susie_alpha_res_ldmismatchnoLD <- ctwas_res_ldmismatchnoLD$susie_alpha_res
  susie_alpha_res_ldmismatchnoLD <- anno_susie_alpha_res(susie_alpha_res_ldmismatchnoLD,
                                                         mapping_table = mapping_two,
                                                         map_by = "molecular_id",
                                                         drop_unmapped = TRUE)
  combined_pip_by_group_ldmismatchnoLD <- combine_gene_pips(susie_alpha_res_ldmismatchnoLD,
                                                            group_by = "gene_name",
                                                            by = "group",
                                                            method = "combine_cs",
                                                            filter_cs = TRUE,
                                                            include_cs_id = F)
  
  combined_pip_by_group_ldmismatch <- combined_pip_by_group_ldmismatch[,c("gene_name","combined_pip")]
  combined_pip_by_group_regionmerge <- combined_pip_by_group_regionmerge[,c("gene_name","combined_pip")]
  combined_pip_by_group_ldmismatchnoLD <- combined_pip_by_group_ldmismatchnoLD[,c("gene_name","combined_pip")]
  
  
  merged <- merge(combined_pip_by_group_regionmerge,combined_pip_by_group_ldmismatch, by = "gene_name", all.x = T)
  merged <- merge(merged,combined_pip_by_group_ldmismatchnoLD, by = "gene_name", all.x = T)
  
  colnames(merged) <- c("gene_name","combined_pip_regionmerge", "combined_pip_ldmismatch_remove", "combined_pip_ldmismatchnoLD")
  
  genes_diff <- merged %>%
    rowwise() %>%
    dplyr::filter(n_distinct(c(combined_pip_regionmerge, combined_pip_ldmismatch_remove, combined_pip_ldmismatchnoLD)) > 1)
  
  
  known <- readRDS(paste0("/project/xinhe/xsun/multi_group_ctwas/data/silverstandard/known_annotations_IBD.RDS"))
  bystander <- readRDS(paste0("/project/xinhe/xsun/multi_group_ctwas/data/silverstandard/bystanders_IBD.RDS"))
  
  genes_diff <- genes_diff %>%
    mutate(
      is_silver = gene_name %in% known,
      is_bystander = gene_name %in% bystander
    )

  
}else {
  
  n_problematic_gene <- 0
  
}

Version Author Date
6e49457 XSun 2025-04-17
2025-04-25 12:19:12 INFO::Annotating susie alpha result ...
2025-04-25 12:19:12 INFO::Map molecular traits to genes
2025-04-25 12:19:15 INFO::Split PIPs for molecular traits mapped to multiple genes
2025-04-25 12:20:18 INFO::Annotating susie alpha result ...
2025-04-25 12:20:19 INFO::Map molecular traits to genes
2025-04-25 12:20:21 INFO::Split PIPs for molecular traits mapped to multiple genes
# setting <- paste0("thin",thin,".",var_struc,".L",L,".genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)
setting <- paste0("genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)

tmp <- c(setting, n_problematic_snp, n_problematic_gene)

df_summary <- rbind(df_summary,tmp)

DT::datatable(genes_diff,caption = htmltools::tags$caption( style = 'caption-side: left; text-align: left; color:black;  font-size:150% ;','Genes -- PIP changed'),options = list(pageLength = 10) )
colnames(df_summary) <- c("threshold","num_problematic_snp","num_problematic_gene")
rownames(df_summary) <- NULL
DT::datatable(df_summary,caption = htmltools::tags$caption( style = 'caption-side: left; text-align: left; color:black;  font-size:150% ;','Number of problematci genes & snps'),options = list(pageLength = 10) )

aFib-ebi-a-GCST006414

Setting: shared_all, thin = 1, L = 5, susieST

trait <- "aFib-ebi-a-GCST006414"
thin <- 1
var_struc <- "shared_all"
st <- "with_susieST"
L <- 5

ctwas_res_origin <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".finemap_regions_res.RDS"))
finemap_res_origin <- ctwas_res_origin$finemap_res
finemap_res_gene_origin <- finemap_res_origin[finemap_res_origin$type != "SNP",]

ctwas_res_regionmerge <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".regionmerge_finemap_regions_res.RDS"))
finemap_res_regionmerge <- ctwas_res_regionmerge$finemap_res
finemap_res_gene_regionmerge <- finemap_res_regionmerge[finemap_res_regionmerge$type != "SNP",]

df_summary <- c()

Thresholds for ld mismatch diagnosis: nonSNP PIP = 0.5, SNP p_diff = 5e-8

threshold_nonSNP_PIPs <- 0.5
threshold_SNP_p <- "5e-08"
file_res_ldmm <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

res_ldmm <- readRDS(file_res_ldmm)
n_problematic_snp <- length(res_ldmm$problematic_snps)

file_problematic_genes <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

if(file.exists(file_problematic_genes)) {
  
  problematic_genes <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  n_problematic_gene <- length(problematic_genes)
  
  finemap_res_gene_origin$highlight <- ifelse(finemap_res_gene_origin$id %in% problematic_genes, "problematic genes", "good genes")
  
  p1 <- ggplot(data = finemap_res_gene_origin, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("Original ctwas results") +
    theme_minimal()
  
  finemap_res_gene_regionmerge$highlight <- ifelse(finemap_res_gene_regionmerge$id %in% problematic_genes, "problematic genes", "good genes")
  
  p2 <- ggplot(data = finemap_res_gene_regionmerge, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("After region merge") +
    theme_minimal()
  
  ctwas_res_ldmismatch <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatch <- ctwas_res_ldmismatch$finemap_res
  finemap_res_gene_ldmismatch <- finemap_res_ldmismatch[finemap_res_ldmismatch$type != "SNP",]
  finemap_res_gene_ldmismatch$highlight <- ifelse(finemap_res_gene_ldmismatch$id %in% problematic_genes, "problematic genes", "good genes")
  
  p3 <- ggplot(data = finemap_res_gene_ldmismatch, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  ctwas_res_ldmismatchnoLD <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_noLD_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatchnoLD <- ctwas_res_ldmismatchnoLD$finemap_res
  finemap_res_gene_ldmismatchnoLD <- finemap_res_ldmismatchnoLD[finemap_res_ldmismatchnoLD$type != "SNP",]
  finemap_res_gene_ldmismatchnoLD$highlight <- ifelse(finemap_res_gene_ldmismatchnoLD$id %in% problematic_genes, "problematic genes", "good genes")
  
  p4 <- ggplot(data = finemap_res_gene_ldmismatchnoLD, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  grid::grid.newpage()
  gridExtra::grid.arrange(p1,p2,p3,p4,
                          ncol = 4,
                          top = paste0(trait,"-nonSNP_PIPs:",threshold_nonSNP_PIPs,"-SNP_p:",threshold_SNP_p))
}else {
  
  n_problematic_gene <- 0
  
}

Version Author Date
6e49457 XSun 2025-04-17
82784b3 XSun 2025-04-08
# setting <- paste0("thin",thin,".",var_struc,".L",L,".genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)
setting <- paste0("genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)

tmp <- c(setting, n_problematic_snp, n_problematic_gene)

df_summary <- rbind(df_summary,tmp)

Thresholds for ld mismatch diagnosis: nonSNP PIP = 0.5, SNP p_diff = 5e-6

threshold_nonSNP_PIPs <- 0.5
threshold_SNP_p <- "5e-06"
file_res_ldmm <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

res_ldmm <- readRDS(file_res_ldmm)
n_problematic_snp <- length(res_ldmm$problematic_snps)

file_problematic_genes <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

if(file.exists(file_problematic_genes)) {
  
  problematic_genes <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  n_problematic_gene <- length(problematic_genes)
  
  finemap_res_gene_origin$highlight <- ifelse(finemap_res_gene_origin$id %in% problematic_genes, "problematic genes", "good genes")
  
  p1 <- ggplot(data = finemap_res_gene_origin, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("Original ctwas results") +
    theme_minimal()
  
  finemap_res_gene_regionmerge$highlight <- ifelse(finemap_res_gene_regionmerge$id %in% problematic_genes, "problematic genes", "good genes")
  
  p2 <- ggplot(data = finemap_res_gene_regionmerge, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("After region merge") +
    theme_minimal()
  
  ctwas_res_ldmismatch <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatch <- ctwas_res_ldmismatch$finemap_res
  finemap_res_gene_ldmismatch <- finemap_res_ldmismatch[finemap_res_ldmismatch$type != "SNP",]
  finemap_res_gene_ldmismatch$highlight <- ifelse(finemap_res_gene_ldmismatch$id %in% problematic_genes, "problematic genes", "good genes")
  
  p3 <- ggplot(data = finemap_res_gene_ldmismatch, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  ctwas_res_ldmismatchnoLD <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_noLD_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatchnoLD <- ctwas_res_ldmismatchnoLD$finemap_res
  finemap_res_gene_ldmismatchnoLD <- finemap_res_ldmismatchnoLD[finemap_res_ldmismatchnoLD$type != "SNP",]
  finemap_res_gene_ldmismatchnoLD$highlight <- ifelse(finemap_res_gene_ldmismatchnoLD$id %in% problematic_genes, "problematic genes", "good genes")
  
  p4 <- ggplot(data = finemap_res_gene_ldmismatchnoLD, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  grid::grid.newpage()
  gridExtra::grid.arrange(p1,p2,p3,p4,
                          ncol = 4,
                          top = paste0(trait,"-nonSNP_PIPs:",threshold_nonSNP_PIPs,"-SNP_p:",threshold_SNP_p))
}else {
  
  n_problematic_gene <- 0
  
}

Version Author Date
6e49457 XSun 2025-04-17
82784b3 XSun 2025-04-08
# setting <- paste0("thin",thin,".",var_struc,".L",L,".genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)
setting <- paste0("genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)

tmp <- c(setting, n_problematic_snp, n_problematic_gene)

df_summary <- rbind(df_summary,tmp)

Thresholds for ld mismatch diagnosis: nonSNP PIP = 0.2, SNP p_diff = 5e-8

threshold_nonSNP_PIPs <- 0.2
threshold_SNP_p <- "5e-08"
file_res_ldmm <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

res_ldmm <- readRDS(file_res_ldmm)
n_problematic_snp <- length(res_ldmm$problematic_snps)

file_problematic_genes <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

if(file.exists(file_problematic_genes)) {
  
  problematic_genes <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  n_problematic_gene <- length(problematic_genes)
  
  finemap_res_gene_origin$highlight <- ifelse(finemap_res_gene_origin$id %in% problematic_genes, "problematic genes", "good genes")
  
  p1 <- ggplot(data = finemap_res_gene_origin, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("Original ctwas results") +
    theme_minimal()
  
  finemap_res_gene_regionmerge$highlight <- ifelse(finemap_res_gene_regionmerge$id %in% problematic_genes, "problematic genes", "good genes")
  
  p2 <- ggplot(data = finemap_res_gene_regionmerge, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("After region merge") +
    theme_minimal()
  
  ctwas_res_ldmismatch <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatch <- ctwas_res_ldmismatch$finemap_res
  finemap_res_gene_ldmismatch <- finemap_res_ldmismatch[finemap_res_ldmismatch$type != "SNP",]
  finemap_res_gene_ldmismatch$highlight <- ifelse(finemap_res_gene_ldmismatch$id %in% problematic_genes, "problematic genes", "good genes")
  
  p3 <- ggplot(data = finemap_res_gene_ldmismatch, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  ctwas_res_ldmismatchnoLD <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_noLD_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatchnoLD <- ctwas_res_ldmismatchnoLD$finemap_res
  finemap_res_gene_ldmismatchnoLD <- finemap_res_ldmismatchnoLD[finemap_res_ldmismatchnoLD$type != "SNP",]
  finemap_res_gene_ldmismatchnoLD$highlight <- ifelse(finemap_res_gene_ldmismatchnoLD$id %in% problematic_genes, "problematic genes", "good genes")
  
  p4 <- ggplot(data = finemap_res_gene_ldmismatchnoLD, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  grid::grid.newpage()
  gridExtra::grid.arrange(p1,p2,p3,p4,
                          ncol = 4,
                          top = paste0(trait,"-nonSNP_PIPs:",threshold_nonSNP_PIPs,"-SNP_p:",threshold_SNP_p))
}else {
  
  n_problematic_gene <- 0
  
}

Version Author Date
6e49457 XSun 2025-04-17
82784b3 XSun 2025-04-08
# setting <- paste0("thin",thin,".",var_struc,".L",L,".genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)
setting <- paste0("genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)

tmp <- c(setting, n_problematic_snp, n_problematic_gene)

df_summary <- rbind(df_summary,tmp)

Thresholds for ld mismatch diagnosis: nonSNP PIP = 0.2, SNP p_diff = 5e-6

threshold_nonSNP_PIPs <- 0.2
threshold_SNP_p <- "5e-06"
file_res_ldmm <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

res_ldmm <- readRDS(file_res_ldmm)
n_problematic_snp <- length(res_ldmm$problematic_snps)

file_problematic_genes <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

if(file.exists(file_problematic_genes)) {
  
  problematic_genes <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  n_problematic_gene <- length(problematic_genes)
  
  finemap_res_gene_origin$highlight <- ifelse(finemap_res_gene_origin$id %in% problematic_genes, "problematic genes", "good genes")
  
  p1 <- ggplot(data = finemap_res_gene_origin, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("Original ctwas results") +
    theme_minimal()
  
  finemap_res_gene_regionmerge$highlight <- ifelse(finemap_res_gene_regionmerge$id %in% problematic_genes, "problematic genes", "good genes")
  
  p2 <- ggplot(data = finemap_res_gene_regionmerge, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("After region merge") +
    theme_minimal()
  
  ctwas_res_ldmismatch <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatch <- ctwas_res_ldmismatch$finemap_res
  finemap_res_gene_ldmismatch <- finemap_res_ldmismatch[finemap_res_ldmismatch$type != "SNP",]
  finemap_res_gene_ldmismatch$highlight <- ifelse(finemap_res_gene_ldmismatch$id %in% problematic_genes, "problematic genes", "good genes")
  
  p3 <- ggplot(data = finemap_res_gene_ldmismatch, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  ctwas_res_ldmismatchnoLD <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_noLD_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatchnoLD <- ctwas_res_ldmismatchnoLD$finemap_res
  finemap_res_gene_ldmismatchnoLD <- finemap_res_ldmismatchnoLD[finemap_res_ldmismatchnoLD$type != "SNP",]
  finemap_res_gene_ldmismatchnoLD$highlight <- ifelse(finemap_res_gene_ldmismatchnoLD$id %in% problematic_genes, "problematic genes", "good genes")
  
  p4 <- ggplot(data = finemap_res_gene_ldmismatchnoLD, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  grid::grid.newpage()
  gridExtra::grid.arrange(p1,p2,p3,p4,
                          ncol = 4,
                          top = paste0(trait,"-nonSNP_PIPs:",threshold_nonSNP_PIPs,"-SNP_p:",threshold_SNP_p))
}else {
  
  n_problematic_gene <- 0
  
}

Version Author Date
6e49457 XSun 2025-04-17
82784b3 XSun 2025-04-08
# setting <- paste0("thin",thin,".",var_struc,".L",L,".genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)
setting <- paste0("genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)

tmp <- c(setting, n_problematic_snp, n_problematic_gene)

df_summary <- rbind(df_summary,tmp)

Thresholds for ld mismatch diagnosis: nonSNP PIP = 0.2, SNP p_diff = 5e-4

threshold_nonSNP_PIPs <- 0.2
threshold_SNP_p <- "5e-04"
file_res_ldmm <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

res_ldmm <- readRDS(file_res_ldmm)
n_problematic_snp <- length(res_ldmm$problematic_snps)

file_problematic_genes <- paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS")

if(file.exists(file_problematic_genes)) {
  
  problematic_genes <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_problematic_genes_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  n_problematic_gene <- length(problematic_genes)
  
  finemap_res_gene_origin$highlight <- ifelse(finemap_res_gene_origin$id %in% problematic_genes, "problematic genes", "good genes")
  
  p1 <- ggplot(data = finemap_res_gene_origin, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("Original ctwas results") +
    theme_minimal()
  
  finemap_res_gene_regionmerge$highlight <- ifelse(finemap_res_gene_regionmerge$id %in% problematic_genes, "problematic genes", "good genes")
  
  p2 <- ggplot(data = finemap_res_gene_regionmerge, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("After region merge") +
    theme_minimal()
  
  ctwas_res_ldmismatch <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatch <- ctwas_res_ldmismatch$finemap_res
  finemap_res_gene_ldmismatch <- finemap_res_ldmismatch[finemap_res_ldmismatch$type != "SNP",]
  finemap_res_gene_ldmismatch$highlight <- ifelse(finemap_res_gene_ldmismatch$id %in% problematic_genes, "problematic genes", "good genes")
  
  p3 <- ggplot(data = finemap_res_gene_ldmismatch, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  ctwas_res_ldmismatchnoLD <- readRDS(paste0(folder_results_susieST,trait,"/",trait,".",st,".thin",thin,".",var_struc,".L",L,".ldmismatch_noLD_finemap_regions_res_genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p,".RDS"))
  finemap_res_ldmismatchnoLD <- ctwas_res_ldmismatchnoLD$finemap_res
  finemap_res_gene_ldmismatchnoLD <- finemap_res_ldmismatchnoLD[finemap_res_ldmismatchnoLD$type != "SNP",]
  finemap_res_gene_ldmismatchnoLD$highlight <- ifelse(finemap_res_gene_ldmismatchnoLD$id %in% problematic_genes, "problematic genes", "good genes")
  
  p4 <- ggplot(data = finemap_res_gene_ldmismatchnoLD, aes(x= abs(z), y= susie_pip, color = highlight)) +
    geom_point() +
    scale_color_manual(values = c("problematic genes" = "red", "good genes" = "black")) +
    ggtitle("LD mismatch fixed -- remove the snp") +
    theme_minimal()
  
  grid::grid.newpage()
  gridExtra::grid.arrange(p1,p2,p3,p4,
                          ncol = 4,
                          top = paste0(trait,"-nonSNP_PIPs:",threshold_nonSNP_PIPs,"-SNP_p:",threshold_SNP_p))
}else {
  
  n_problematic_gene <- 0
  
}

Version Author Date
6e49457 XSun 2025-04-17
82784b3 XSun 2025-04-08
# setting <- paste0("thin",thin,".",var_struc,".L",L,".genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)
setting <- paste0("genepip",threshold_nonSNP_PIPs,"_snpp_",threshold_SNP_p)

tmp <- c(setting, n_problematic_snp, n_problematic_gene)

df_summary <- rbind(df_summary,tmp)
colnames(df_summary) <- c("threshold","num_problematic_snp","num_problematic_gene")
rownames(df_summary) <- NULL
DT::datatable(df_summary,caption = htmltools::tags$caption( style = 'caption-side: left; text-align: left; color:black;  font-size:150% ;','Number of problematci genes & snps'),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 8

Matrix products: default
BLAS/LAPACK: /software/openblas-0.3.13-el8-x86_64/lib/libopenblas_skylakexp-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] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] dplyr_1.1.2      ctwas_0.5.5.9001 ggplot2_3.4.2    workflowr_1.7.1 

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.38.0              locuszoomr_0.1.5           
  [7] GenomicRanges_1.50.2        base64enc_0.1-3            
  [9] fs_1.5.2                    rstudioapi_0.14            
 [11] farver_2.1.0                DT_0.22                    
 [13] ggrepel_0.9.3               bit64_4.0.5                
 [15] AnnotationDbi_1.60.2        fansi_1.0.3                
 [17] xml2_1.3.3                  logging_0.10-108           
 [19] codetools_0.2-18            cachem_1.0.6               
 [21] knitr_1.42                  jsonlite_1.8.9             
 [23] Rsamtools_2.14.0            dbplyr_2.3.2               
 [25] png_0.1-7                   readr_2.1.4                
 [27] compiler_4.2.0              httr_1.4.7                 
 [29] Matrix_1.6-1.1              fastmap_1.1.0              
 [31] lazyeval_0.2.2              cli_3.6.2                  
 [33] later_1.3.0                 htmltools_0.5.7            
 [35] prettyunits_1.1.1           tools_4.2.0                
 [37] gtable_0.3.0                glue_1.6.2                 
 [39] GenomeInfoDbData_1.2.9      rappdirs_0.3.3             
 [41] Rcpp_1.0.14                 Biobase_2.58.0             
 [43] jquerylib_0.1.4             vctrs_0.6.1                
 [45] Biostrings_2.66.0           rtracklayer_1.58.0         
 [47] crosstalk_1.2.0             xfun_0.38                  
 [49] stringr_1.5.0               ps_1.7.0                   
 [51] irlba_2.3.5                 lifecycle_1.0.4            
 [53] restfulr_0.0.15             ensembldb_2.22.0           
 [55] XML_3.99-0.9                getPass_0.2-2              
 [57] zlibbioc_1.44.0             scales_1.2.0               
 [59] gggrid_0.2-0                hms_1.1.3                  
 [61] promises_1.2.0.1            MatrixGenerics_1.10.0      
 [63] ProtGenerics_1.30.0         parallel_4.2.0             
 [65] SummarizedExperiment_1.28.0 AnnotationFilter_1.22.0    
 [67] LDlinkR_1.3.0               yaml_2.3.5                 
 [69] curl_4.3.2                  gridExtra_2.3              
 [71] memoise_2.0.1               sass_0.4.1                 
 [73] biomaRt_2.54.1              stringi_1.7.6              
 [75] RSQLite_2.3.1               highr_0.9                  
 [77] S4Vectors_0.36.2            BiocIO_1.8.0               
 [79] GenomicFeatures_1.50.4      BiocGenerics_0.44.0        
 [81] filelock_1.0.2              BiocParallel_1.32.6        
 [83] repr_1.1.4                  GenomeInfoDb_1.34.9        
 [85] rlang_1.1.2                 pkgconfig_2.0.3            
 [87] matrixStats_1.2.0           bitops_1.0-7               
 [89] evaluate_0.15               lattice_0.20-45            
 [91] purrr_1.0.1                 labeling_0.4.2             
 [93] GenomicAlignments_1.34.1    htmlwidgets_1.6.2          
 [95] cowplot_1.1.1               bit_4.0.4                  
 [97] processx_3.5.3              tidyselect_1.2.0           
 [99] magrittr_2.0.3              AMR_2.1.1                  
[101] R6_2.5.1                    IRanges_2.32.0             
[103] generics_0.1.3              DelayedArray_0.24.0        
[105] DBI_1.1.2                   pgenlibr_0.3.6             
[107] pillar_1.9.0                whisker_0.4                
[109] withr_2.5.0                 mixsqp_0.3-48              
[111] KEGGREST_1.38.0             RCurl_1.98-1.12            
[113] tibble_3.2.1                crayon_1.5.1               
[115] utf8_1.2.2                  BiocFileCache_2.6.1        
[117] plotly_4.10.0               tzdb_0.3.0                 
[119] rmarkdown_2.21              progress_1.2.2             
[121] grid_4.2.0                  data.table_1.14.4          
[123] blob_1.2.3                  callr_3.7.0                
[125] git2r_0.30.1                digest_0.6.29              
[127] tidyr_1.3.0                 httpuv_1.6.5               
[129] stats4_4.2.0                munsell_0.5.0              
[131] viridisLite_0.4.0           skimr_2.1.4                
[133] bslib_0.3.1