Last updated: 2023-07-21

Checks: 7 0

Knit directory: Cardiotoxicity/

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.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

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(20230109) 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 ca7c6c6. 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:    .RData
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/figure/
    Ignored:    data/41588_2018_171_MOESM3_ESMeQTL_ST2_for paper.csv
    Ignored:    data/Arr_GWAS.txt
    Ignored:    data/Arr_geneset.RDS
    Ignored:    data/BC_cell_lines.csv
    Ignored:    data/CADGWASgene_table.csv
    Ignored:    data/CAD_geneset.RDS
    Ignored:    data/CALIMA_Data/
    Ignored:    data/Clamp_Summary.csv
    Ignored:    data/Cormotif_24_k1-5_raw.RDS
    Ignored:    data/DAgostres24.RDS
    Ignored:    data/DAtable1.csv
    Ignored:    data/DDEMresp_list.csv
    Ignored:    data/DDE_reQTL.txt
    Ignored:    data/DDEresp_list.csv
    Ignored:    data/DEG-GO/
    Ignored:    data/DEG_cormotif.RDS
    Ignored:    data/DF_Plate_Peak.csv
    Ignored:    data/DRC48hoursdata.csv
    Ignored:    data/Da24counts.txt
    Ignored:    data/Dx24counts.txt
    Ignored:    data/Dx_reQTL_specific.txt
    Ignored:    data/Ep24counts.txt
    Ignored:    data/Full_LD_rep.csv
    Ignored:    data/GOIsig.csv
    Ignored:    data/GOplots.R
    Ignored:    data/GTEX_setsimple.csv
    Ignored:    data/GTEX_sig24.RDS
    Ignored:    data/GTEx_gene_list.csv
    Ignored:    data/HFGWASgene_table.csv
    Ignored:    data/HF_geneset.RDS
    Ignored:    data/Heart_Left_Ventricle.v8.egenes.txt
    Ignored:    data/Heatmap_mat.RDS
    Ignored:    data/Heatmap_sig.RDS
    Ignored:    data/Hf_GWAS.txt
    Ignored:    data/K_cluster
    Ignored:    data/K_cluster_kisthree.csv
    Ignored:    data/K_cluster_kistwo.csv
    Ignored:    data/LD50_05via.csv
    Ignored:    data/LDH48hoursdata.csv
    Ignored:    data/Mt24counts.txt
    Ignored:    data/NoRespDEG_final.csv
    Ignored:    data/RINsamplelist.txt
    Ignored:    data/Seonane2019supp1.txt
    Ignored:    data/TMMnormed_x.RDS
    Ignored:    data/TOP2Bi-24hoursGO_analysis.csv
    Ignored:    data/TR24counts.txt
    Ignored:    data/Top2biresp_cluster24h.csv
    Ignored:    data/Var_test_list.RDS
    Ignored:    data/Var_test_list24.RDS
    Ignored:    data/Var_test_list24alt.RDS
    Ignored:    data/Var_test_list3.RDS
    Ignored:    data/Viabilitylistfull.csv
    Ignored:    data/allexpressedgenes.txt
    Ignored:    data/allgenes.txt
    Ignored:    data/allmatrix.RDS
    Ignored:    data/allmymatrix.RDS
    Ignored:    data/annotation_data_frame.RDS
    Ignored:    data/averageviabilitytable.RDS
    Ignored:    data/avgLD50.RDS
    Ignored:    data/avg_LD50.RDS
    Ignored:    data/backGL.txt
    Ignored:    data/calcium_data.RDS
    Ignored:    data/clamp_summary.RDS
    Ignored:    data/cormotif_3hk1-8.RDS
    Ignored:    data/cormotif_initalK5.RDS
    Ignored:    data/cormotif_initialK5.RDS
    Ignored:    data/cormotif_initialall.RDS
    Ignored:    data/counts24hours.RDS
    Ignored:    data/cpmcount.RDS
    Ignored:    data/cpmnorm_counts.csv
    Ignored:    data/crispr_genes.csv
    Ignored:    data/ctnnt_results.txt
    Ignored:    data/cvd_GWAS.txt
    Ignored:    data/dat_cpm.RDS
    Ignored:    data/data_outline.txt
    Ignored:    data/drug_noveh1.csv
    Ignored:    data/efit2.RDS
    Ignored:    data/efit2_final.RDS
    Ignored:    data/efit2results.RDS
    Ignored:    data/ensembl_backup.RDS
    Ignored:    data/ensgtotal.txt
    Ignored:    data/filcpm_counts.RDS
    Ignored:    data/filenameonly.txt
    Ignored:    data/filtered_cpm_counts.csv
    Ignored:    data/filtered_raw_counts.csv
    Ignored:    data/filtermatrix_x.RDS
    Ignored:    data/folder_05top/
    Ignored:    data/geneDoxonlyQTL.csv
    Ignored:    data/gene_corr_df.RDS
    Ignored:    data/gene_corr_frame.RDS
    Ignored:    data/gene_prob_tran3h.RDS
    Ignored:    data/gene_probabilityk5.RDS
    Ignored:    data/geneset_24.RDS
    Ignored:    data/gostresTop2bi_ER.RDS
    Ignored:    data/gostresTop2bi_LR
    Ignored:    data/gostresTop2bi_LR.RDS
    Ignored:    data/gostresTop2bi_TI.RDS
    Ignored:    data/gostrescoNR
    Ignored:    data/gtex/
    Ignored:    data/heartgenes.csv
    Ignored:    data/hsa_kegg_anno.RDS
    Ignored:    data/individualDRCfile.RDS
    Ignored:    data/individual_DRC48.RDS
    Ignored:    data/individual_LDH48.RDS
    Ignored:    data/indv_noveh1.csv
    Ignored:    data/kegglistDEG.RDS
    Ignored:    data/kegglistDEG24.RDS
    Ignored:    data/kegglistDEG3.RDS
    Ignored:    data/knowfig4.csv
    Ignored:    data/knowfig5.csv
    Ignored:    data/label_list.RDS
    Ignored:    data/ld50_table.csv
    Ignored:    data/mean_vardrug1.csv
    Ignored:    data/mean_varframe.csv
    Ignored:    data/mymatrix.RDS
    Ignored:    data/new_ld50avg.RDS
    Ignored:    data/nonresponse_cluster24h.csv
    Ignored:    data/norm_LDH.csv
    Ignored:    data/norm_counts.csv
    Ignored:    data/old_sets/
    Ignored:    data/organized_drugframe.csv
    Ignored:    data/plan2plot.png
    Ignored:    data/raw_counts.csv
    Ignored:    data/response_cluster24h.csv
    Ignored:    data/sigVDA24.txt
    Ignored:    data/sigVDA3.txt
    Ignored:    data/sigVDX24.txt
    Ignored:    data/sigVDX3.txt
    Ignored:    data/sigVEP24.txt
    Ignored:    data/sigVEP3.txt
    Ignored:    data/sigVMT24.txt
    Ignored:    data/sigVMT3.txt
    Ignored:    data/sigVTR24.txt
    Ignored:    data/sigVTR3.txt
    Ignored:    data/siglist.RDS
    Ignored:    data/siglist_final.RDS
    Ignored:    data/siglist_old.RDS
    Ignored:    data/slope_table.csv
    Ignored:    data/supp_normLDH48.RDS
    Ignored:    data/supp_pca_all_anno.RDS
    Ignored:    data/table3a.omar
    Ignored:    data/testlist.txt
    Ignored:    data/toplistall.RDS
    Ignored:    data/trtonly_24h_genes.RDS
    Ignored:    data/trtonly_3h_genes.RDS
    Ignored:    data/tvl24hour.txt
    Ignored:    data/tvl24hourw.txt
    Ignored:    data/venn_code.R
    Ignored:    data/viability.RDS

Untracked files:
    Untracked:  .RDataTmp
    Untracked:  .RDataTmp1
    Untracked:  .RDataTmp2
    Untracked:  Doxorubicin_vehicle_3_24.csv
    Untracked:  Doxtoplist.csv
    Untracked:  GWAS_list_of_interest.xlsx
    Untracked:  KEGGpathwaylist.R
    Untracked:  OmicNavigator_learn.R
    Untracked:  SigDoxtoplist.csv
    Untracked:  analysis/DRC_analysist.Rmd
    Untracked:  analysis/ciFIT.R
    Untracked:  analysis/enricher.Rmd
    Untracked:  analysis/export_to_excel.R
    Untracked:  analysis/untitled1.R
    Untracked:  code/DRC_plotfigure1.png
    Untracked:  code/constantcode.R
    Untracked:  code/cpm_boxplot.R
    Untracked:  code/extracting_ggplot_data.R
    Untracked:  code/fig1plot.png
    Untracked:  code/figurelegeddrc.png
    Untracked:  code/movingfilesto_ppl.R
    Untracked:  code/pearson_extract_func.R
    Untracked:  code/pearson_tox_extract.R
    Untracked:  code/plot1C.fun.R
    Untracked:  code/spearman_extract_func.R
    Untracked:  code/venndiagramcolor_control.R
    Untracked:  cormotif_probability_genelist.csv
    Untracked:  individual-legenddark2.png
    Untracked:  installed_old.rda
    Untracked:  motif_ER.txt
    Untracked:  motif_LR.txt
    Untracked:  motif_NR.txt
    Untracked:  motif_TI.txt
    Untracked:  output/DNRvenn.RDS
    Untracked:  output/DOXvenn.RDS
    Untracked:  output/EPIvenn.RDS
    Untracked:  output/Figures/
    Untracked:  output/MTXvenn.RDS
    Untracked:  output/Volcanoplot_10
    Untracked:  output/Volcanoplot_10.RDS
    Untracked:  output/allfinal_sup10.RDS
    Untracked:  output/gene_corr_fig9.RDS
    Untracked:  output/legend_b.RDS
    Untracked:  output/motif_ERrep.RDS
    Untracked:  output/motif_LRrep.RDS
    Untracked:  output/motif_NRrep.RDS
    Untracked:  output/motif_TI_rep.RDS
    Untracked:  output/output-old/
    Untracked:  output/supplementary_motif_list_GO.RDS
    Untracked:  output/toptablebydrug.RDS
    Untracked:  output/x_counts.RDS
    Untracked:  reneebasecode.R

Unstaged changes:
    Modified:   analysis/DEG-GO_analysis.Rmd
    Modified:   analysis/DRC_analysis.Rmd
    Modified:   analysis/Figure2.Rmd
    Modified:   analysis/Figure5.Rmd
    Modified:   analysis/Figure9.Rmd
    Modified:   analysis/Knowles2019.Rmd
    Modified:   analysis/Supplementary_figures.Rmd
    Modified:   analysis/other_analysis.Rmd
    Modified:   analysis/run_all_analysis.Rmd
    Modified:   analysis/variance_scrip.Rmd
    Modified:   output/DNRmeSNPs.RDS
    Modified:   output/DNRreQTLs.RDS
    Modified:   output/DOXmeSNPs.RDS
    Modified:   output/DOXreQTLs.RDS
    Modified:   output/EPImeSNPs.RDS
    Modified:   output/EPIreQTLs.RDS
    Modified:   output/GOI_genelist.txt
    Modified:   output/MTXmeSNPs.RDS
    Modified:   output/MTXreQTLs.RDS
    Modified:   output/TNNI_LDH_RNAnormlist.txt
    Modified:   output/daplot.RDS
    Modified:   output/dxplot.RDS
    Modified:   output/epplot.RDS
    Modified:   output/mtplot.RDS
    Modified:   output/plan2plot.png
    Modified:   output/toplistall.csv
    Modified:   output/trplot.RDS
    Modified:   output/veplot.RDS

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/GOI_plots.Rmd) and HTML (docs/GOI_plots.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 ca7c6c6 reneeisnowhere 2023-07-21 added plots individually
html 3db5216 reneeisnowhere 2023-07-20 Build site.
Rmd d68fa43 reneeisnowhere 2023-07-20 adding variance top 24h gene plots
html ad58c4d reneeisnowhere 2023-07-18 Build site.
Rmd 4cc1c40 reneeisnowhere 2023-07-18 updating pearson correlation plots for each GOI
html a48eda5 reneeisnowhere 2023-06-26 Build site.
Rmd 4b1a17b reneeisnowhere 2023-06-26 fixing SLC corr plot
html 554ef92 reneeisnowhere 2023-06-23 Build site.
Rmd b327d60 reneeisnowhere 2023-06-23 fix images not loading
html 995ce68 reneeisnowhere 2023-06-23 Build site.
Rmd 26afd1e reneeisnowhere 2023-06-23 adding heatmaps
Rmd c1d667f reneeisnowhere 2023-06-23 updating the codes at Friday start.
html 924262d reneeisnowhere 2023-06-16 Build site.
Rmd eab6c68 reneeisnowhere 2023-06-16 update on code moving
Rmd 3d4ca64 reneeisnowhere 2023-06-16 updates on Friday

cpm_boxplot <-function(cpmcounts, GOI,brewer_palette, fill_colors, ylab) {
    ##GOI needs to be ENTREZID
  df <- cpmcounts
  df_plot <- df %>% 
      dplyr::filter(rownames(.)== GOI) %>%
      pivot_longer(everything(),
                   names_to = "treatment",
                   values_to = "counts") %>%
      separate(treatment, c("drug","indv","time")) %>%
      mutate(time = factor(time, levels= c("3h","24h"), labels = c("3 hours","24 hours"))) %>% 
      mutate(indv=factor(indv, levels = c(1,2,3,4,5,6))) %>%
      mutate(drug =case_match(drug, "Da"~"DNR",
                            "Do"~"DOX",
                            "Ep"~"EPI",
                            "Mi"~"MTX",
                            "Tr"~"TRZ",
                            "Ve"~"VEH", .default = drug)) %>% 
      mutate(drug=factor(drug, levels = c('DOX','EPI','DNR','MTX','TRZ','VEH'))) 
  
    plot <- ggplot2::ggplot(df_plot, aes(x=drug, y=counts))+
      geom_boxplot(position="identity",aes(fill=drug))+
      geom_point(aes(col=indv, size=2, alpha=0.5))+
      guides(alpha= "none", size= "none")+
      scale_color_brewer(palette = brewer_palette, guide = "none")+
      scale_fill_manual(values=fill_colors)+
      facet_wrap(~time, nrow=1, ncol=2)+
      theme_bw()+
      ylab(ylab)+
      xlab("")+
      # ggtitle("24 hours")+
      theme(strip.background = element_rect(fill = "white",linetype=1, linewidth = 0.5),
          plot.title = element_text(size=12,hjust = 0.5,face="bold"),
          axis.title = element_text(size = 10, color = "black"),
          axis.ticks = element_line(linewidth = 1.0),
          panel.background = element_rect(colour = "black", size=1),
          axis.text.x = element_blank(),
          strip.text.x = element_text(margin = margin(2,0,2,0, "pt"),face = "bold"))
    print(plot)
}

pearson_extract <- function(corr_df,ENTREZID) {
  ld50_plot <- corr_df %>%
    dplyr::filter(entrezgene_id == ENTREZID) %>%
    ggplot(., aes(x=LD50, y=counts))+
    geom_point(aes(col=indv))+
    geom_smooth(method="lm")+
    facet_wrap(hgnc_symbol~Drug, scales="free")+
    theme_classic()+
    stat_cor(method="pearson",
             aes(label = paste(..r.label.., ..p.label.., sep = "~`,`~")),
             color = "red",
             label.x.npc = 0,
             label.y.npc=1,
             size = 3)

  tnni_plot <-  corr_df %>%
    dplyr::filter(entrezgene_id == ENTREZID) %>%
    ggplot(., aes(x=rtnni, y=counts))+
    geom_point(aes(col=indv))+
    geom_smooth(method="lm")+
    facet_wrap(hgnc_symbol~Drug, scales="free")+
    theme_classic()+
    stat_cor(method="pearson",
             aes(label = paste(..r.label.., ..p.label.., sep = "~`,`~")),
             color = "red",
             label.x.npc = 0,
             label.y.npc=1,
             size = 3)

  ldh_plot <-   corr_df %>%
    dplyr::filter(entrezgene_id == ENTREZID) %>%
    ggplot(., aes(x=rldh, y=counts))+
    geom_point(aes(col=indv))+
    geom_smooth(method="lm")+
    facet_wrap(hgnc_symbol~Drug, scales="free")+
    theme_classic()+
    stat_cor(method="pearson",
             aes(label = paste(..r.label.., ..p.label.., sep = "~`,`~")),
             color = "red",
             label.x.npc = 0,
             label.y.npc=1,
             size = 3)

  ##ggbuild to get model:
  ld50_build <- ggplot_build(ld50_plot)
  ld50_data <- data.frame('rho_LD50'= c(ld50_build$data[[3]]$r,NA,NA),
                          'sig_LD50'=c(ld50_build$data[[3]]$p.value,NA,NA),
                          'rowname'=c("DOX","EPI","DNR","MTX", "TRZ", "VEH"))

  tnni_build <- ggplot_build(tnni_plot)
  tnni_data <- data.frame('rho_tnni'= c(tnni_build$data[[3]]$r),
                          'sig_tnni'=c(tnni_build$data[[3]]$p.value),
                          'rowname'=c("DOX","EPI","DNR","MTX", "TRZ", "VEH"))
  ldh_build <- ggplot_build(ldh_plot)
  ldh_data <- data.frame('rho_ldh'= c(ldh_build$data[[3]]$r),
                         'sig_ldh'=c(ldh_build$data[[3]]$p.value),
                         'rowname'=c("DOX","EPI","DNR","MTX", "TRZ", "VEH"))

  results <- cbind(ldh_data,tnni_data[,1:2],ld50_data[,1:2])

  return(results)

}
library(ComplexHeatmap)
library(tidyverse)
library(ggsignif)
library(RColorBrewer)
library(scales)
library(sjmisc)
library(kableExtra)
library(broom)
library(ggstats)
library(Hmisc)
library(ggpubr)
<environment: R_GlobalEnv>
<environment: R_GlobalEnv>

Genes of Interest log2 cpm

TOP2B

Top2a

CDKN1a

ATM

### ATR

RARG

KAT6b

cpm_boxplot(cpmcounts,GOI='23522',"Dark2",drug_pal_vehend,
  ylab=(expression(atop(" ",italic("KAT6B")~log[2]~"cpm "))))

KDM4b

cpm_boxplot(cpmcounts,GOI='23030',"Dark2",drug_pal_vehend,
  ylab=(expression(atop(" ",italic("KDM4B")~log[2]~"cpm "))))

## expression correlation:

first, will do expression the following GOIs:

Significant (adj. P value of <0.05) Genes of interest by treatment
time id ENTREZID SYMBOL adj.P.Val
23371…1 24_hours DNR 23371 TNS2 0.0000011
23254…2 24_hours DNR 23254 KAZN 0.0000165
283337…3 24_hours DNR 283337 ZNF740 0.0001526
23030…4 24_hours DNR 23030 KDM4B 0.0003429
51020…5 24_hours DNR 51020 HDDC2 0.0013039
10818…6 24_hours DNR 10818 FRS2 0.0019914
5916…7 24_hours DNR 5916 RARG 0.0070726
80010…8 24_hours DNR 80010 RMI1 0.0403160
23371…9 24_hours DOX 23371 TNS2 0.0000007
10818…10 24_hours DOX 10818 FRS2 0.0001291
23254…11 24_hours DOX 23254 KAZN 0.0001461
23030…12 24_hours DOX 23030 KDM4B 0.0017905
51020…13 24_hours DOX 51020 HDDC2 0.0057312
283337…14 24_hours DOX 283337 ZNF740 0.0111769
64078…15 24_hours DOX 64078 SLC28A3 0.0298732
80010…16 24_hours DOX 80010 RMI1 0.0357673
23371…17 24_hours EPI 23371 TNS2 0.0000025
10818…18 24_hours EPI 10818 FRS2 0.0002169
23254…19 24_hours EPI 23254 KAZN 0.0003003
51020…20 24_hours EPI 51020 HDDC2 0.0014213
283337…21 24_hours EPI 283337 ZNF740 0.0071182
5916…22 24_hours EPI 5916 RARG 0.0147965
64078…23 24_hours EPI 64078 SLC28A3 0.0170798
23030…24 24_hours EPI 23030 KDM4B 0.0209094
80010…25 24_hours MTX 80010 RMI1 0.0066041

24 hour TNNI to cpm

# # now I have the long dataframe, time to combine with other data snf limit to just the GOIs
# gene_corr_frame <- gene_corr_df %>%
#     filter(entrezgene_id %in% GOI_genelist$entrezgene_id) %>%
#     left_join(., GOI_join, by=c("Drug","indv")) %>%
#     dplyr::select(indv, Drug,entrezgene_id,counts, rldh,rtnni,LD50,tox) %>%
#     mutate(Drug=factor(Drug)) %>%
#     full_join(.,GOI_genelist, by="entrezgene_id")
#
#   saveRDS(gene_corr_df,"data/gene_corr_df.RDS")
# saveRDS(gene_corr_frame,"data/gene_corr_frame.RDS")
gene_corr_frame <- readRDS("data/gene_corr_frame.RDS")
   gene_corr_df <- readRDS("data/gene_corr_df.RDS")
   
## remove nas!

   
for (gene in GOI_genelist$entrezgene_id){
    gene_plot <- gene_corr_frame %>% 
      dplyr::filter(entrezgene_id == gene) %>%
      ggplot(., aes(x=rtnni, y=counts))+
      geom_point(aes(col=indv))+
      geom_smooth(method="lm")+
      facet_wrap(hgnc_symbol~Drug, scales="free")+
      theme_classic()+
      xlab("troponin I expression") +
      ylab("Gene counts in log2 cpm") +
      ggtitle(expression(paste("Correlation between counts and troponin I by drug")))+
      scale_color_brewer(palette = "Dark2",name = "Individual", label = c("1","2","3","4","5","6"))+
     ggpubr:: stat_cor(method="pearson",
                       cor.coef.name="rho",
               aes(label = paste(..r.label.., ..p.label.., sep = "~`,\n`~")),
               color = "red",
               label.x.npc = 0.01,
               label.y.npc=0.01, 
               size = 3)+
      theme(plot.title = element_text(size = rel(1.5), hjust = 0.5,face = "bold"),
            axis.title = element_text(size = 15, color = "black"),
            axis.ticks = element_line(size = 1.5),
            axis.text = element_text(size = 8, color = "black", angle = 20),
            strip.text.x = element_text(size = 12, color = "black", face = "italic"))
   print(gene_plot)
   
  }

24 hour LDH to cpm

## ggplot by drug for ldh
 
  
  for (gene in GOI_genelist$entrezgene_id){
    gene_plot <- gene_corr_frame %>% 
      dplyr::filter(entrezgene_id == gene) %>%
      ggplot(., aes(x=rldh, y=counts))+
      geom_point(aes(col=indv))+
      geom_smooth(method="lm")+
      facet_wrap(hgnc_symbol~Drug, scales="free")+
      theme_classic()+
      xlab("troponin I expression") +
      ylab("Gene counts in log2 cpm") +
      ggtitle(expression(paste("Correlation between counts and LDH by drug")))+
      scale_color_brewer(palette = "Dark2",name = "Individual", label = c("1","2","3","4","5","6"))+
      stat_cor(method="pearson",
               cor.coef.name="rho",
               aes(label = paste(..r.label.., ..p.label.., sep = "~`,`~")),
               color = "red",
               label.x.npc = 0.01,
               label.y.npc=0.01, 
               size = 3)+
      theme(plot.title = element_text(size = rel(1.5), hjust = 0.5,face = "bold"),
            axis.title = element_text(size = 15, color = "black"),
            axis.ticks = element_line(size = 1.5),
            axis.text = element_text(size = 8, color = "black", angle = 20),
            strip.text.x = element_text(size = 12, color = "black", face = "italic"))
   print(gene_plot)
   
  }

Toxicity for GOI

 for (gene in GOI_genelist$entrezgene_id){
    gene_plot <- gene_corr_frame %>% 
      dplyr::filter(entrezgene_id == gene) %>%
      ggplot(., aes(x=tox, y=counts))+
      geom_point(aes(col=indv))+
      geom_smooth(method="lm")+
      facet_wrap(hgnc_symbol~Drug, scales="free")+
      theme_classic()+
      xlab("Toxicity score") +
      ylab("Gene counts in log2 cpm") +
      ggtitle(expression(paste("Correlation between counts and toxicity by drug")))+
      scale_color_brewer(palette = "Dark2",name = "Individual", label = c("1","2","3","4","5","6"))+
      stat_cor(method="pearson",
               cor.coef.name="rho",
               aes(label = paste(..r.label.., ..p.label.., sep = "~`,`~")),
               color = "red",
               label.x.npc = 0.01,
               label.y.npc=0.01, 
               size = 3)+
      theme(plot.title = element_text(size = rel(1.5), hjust = 0.5,face = "bold"),
            axis.title = element_text(size = 15, color = "black"),
            axis.ticks = element_line(size = 1.5),
            axis.text = element_text(size = 8, color = "black", angle = 20),
            strip.text.x = element_text(size = 12, color = "black", face = "italic"))
   print(gene_plot)
   
 }

Fig9 expression correlation

##add in list of ldh,tnni and ld50
avg_LD50 <- readRDS("data/avg_LD50.RDS")

gene_corr_frame <- readRDS("data/gene_corr_frame.RDS")
   gene_corr_df <- readRDS("data/gene_corr_df.RDS")



GOI_join <- RNAnormlist %>% 
  mutate(indv=factor(indv,levels = level_order2)) %>% 
  mutate(indv=as.numeric(indv)) %>%
  mutate(indv=factor(indv)) %>% 
  mutate(Drug = factor(Drug, levels = c("DNR", 
                                       "DOX",
                                       "EPI",
                                       "MTX",
                                       "TRZ",
                                       "VEH"))) %>% 
  dplyr::select(indv, Drug,rldh,rtnni) %>% 
  full_join(.,avg_LD50,by=c("Drug"="sDrug","indv"="indv")) %>% 
  rename("LD50"="name")
##now we have the frame, time to limit df of GOI_genelist to fig 9 genes
Fig9_genes <- GOI_genelist %>% 
  filter(hgnc_symbol %in% list("RARG", "ZNF740", "TNS2", "SLC28A3","RMI1"))
##joining to counts

gene_corr_fig9 <- gene_corr_df %>%
    filter(entrezgene_id %in% Fig9_genes$entrezgene_id) %>%
    left_join(., GOI_join, by=c("Drug","indv")) %>%
    mutate(Drug=factor(Drug, levels = c("DOX","EPI","DNR", "MTX", "TRZ", "VEH"))) %>%
    full_join(.,GOI_genelist, by="entrezgene_id")
  
  # saveRDS(gene_corr_fig9,"output/gene_corr_fig9.RDS")

GOI from variance

DOX examples

Vargenes <- readRDS("data/geneset_24.RDS")
expressedgenes <- read.csv("data/backGL.txt")
top_genes <- sapply(Vargenes,head,4)
top_genes_df<-  top_genes %>% as.data.frame() %>% 
pivot_longer(everything(),names_to="combo",values_to = "ENTREZID") %>% 
  separate(combo, into = c("drug",NA,NA)) %>% 
  mutate(ENTREZID=as.numeric(ENTREZID)) %>% 
  inner_join(., expressedgenes, by="ENTREZID") %>% as.data.frame()


for (g in seq(1:4)){
  datafilter <- top_genes_df %>% filter(drug=="DOX")
  a <- datafilter[g,3]
  # b <- datafilter[g,1]
  cpm_boxplot(cpmcounts,GOI=datafilter[g,2],
              "Dark2",
              drug_pal_fact,
              ylab=bquote(~italic(.(a))~log[2]~"cpm "))
  
}

EPI examples

for (g in seq(1:4)){
  datafilter <- top_genes_df %>% filter(drug =="EPI")
  a <- datafilter[g,3]
  # b <- datafilter[g,1]
  cpm_boxplot(cpmcounts,GOI=datafilter[g,2],
              "Dark2",
              drug_pal_fact,
              ylab=bquote(~italic(.(a))~log[2]~"cpm "))
  
}

DNR examples

for (g in seq(1:4)){
  datafilter <- top_genes_df %>% filter(drug =="DNR")
  a <- datafilter[g,3]
  # b <- datafilter[g,1]
  cpm_boxplot(cpmcounts,GOI=datafilter[g,2],
              "Dark2",
              drug_pal_fact,
              ylab=bquote(~italic(.(a))~log[2]~"cpm "))
  
}

MTX examples

for (g in seq(1:4)){
  datafilter <- top_genes_df %>% filter(drug =="MTX")
  a <- datafilter[g,3]
  # b <- datafilter[g,1]
  cpm_boxplot(cpmcounts,GOI=datafilter[g,2],
              "Dark2",
              drug_pal_fact,
              ylab=bquote(~italic(.(a))~log[2]~"cpm "))
  
}

TRZ examples

for (g in seq(1:4)){
  datafilter <- top_genes_df %>% filter(drug =="TRZ")
  a <- datafilter[g,3]
  # b <- datafilter[g,1]
  cpm_boxplot(cpmcounts,GOI=datafilter[g,2],
              "Dark2",
              drug_pal_fact,
              ylab=bquote(~italic(.(a))~log[2]~"cpm "))
  
}


sessionInfo()
R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8 
[2] LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/Chicago
tzcode source: internal

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

other attached packages:
 [1] ggpubr_0.6.0          Hmisc_5.1-0           ggstats_0.3.0        
 [4] broom_1.0.5           kableExtra_1.3.4      sjmisc_2.8.9         
 [7] scales_1.2.1          RColorBrewer_1.1-3    ggsignif_0.6.4       
[10] lubridate_1.9.2       forcats_1.0.0         stringr_1.5.0        
[13] dplyr_1.1.2           purrr_1.0.1           readr_2.1.4          
[16] tidyr_1.3.0           tibble_3.2.1          ggplot2_3.4.2        
[19] tidyverse_2.0.0       ComplexHeatmap_2.16.0 workflowr_1.7.0      

loaded via a namespace (and not attached):
  [1] gridExtra_2.3       rlang_1.1.1         magrittr_2.0.3     
  [4] clue_0.3-64         GetoptLong_1.0.5    git2r_0.32.0       
  [7] matrixStats_1.0.0   compiler_4.3.1      mgcv_1.9-0         
 [10] getPass_0.2-2       png_0.1-8           systemfonts_1.0.4  
 [13] callr_3.7.3         vctrs_0.6.3         rvest_1.0.3        
 [16] pkgconfig_2.0.3     shape_1.4.6         crayon_1.5.2       
 [19] fastmap_1.1.1       backports_1.4.1     labeling_0.4.2     
 [22] utf8_1.2.3          promises_1.2.0.1    rmarkdown_2.23     
 [25] tzdb_0.4.0          ps_1.7.5            xfun_0.39          
 [28] cachem_1.0.8        jsonlite_1.8.7      highr_0.10         
 [31] later_1.3.1         parallel_4.3.1      cluster_2.1.4      
 [34] R6_2.5.1            bslib_0.5.0         stringi_1.7.12     
 [37] car_3.1-2           rpart_4.1.19        jquerylib_0.1.4    
 [40] Rcpp_1.0.11         iterators_1.0.14    knitr_1.43         
 [43] base64enc_0.1-3     IRanges_2.34.1      Matrix_1.6-0       
 [46] splines_4.3.1       httpuv_1.6.11       nnet_7.3-19        
 [49] timechange_0.2.0    tidyselect_1.2.0    abind_1.4-5        
 [52] rstudioapi_0.15.0   yaml_2.3.7          doParallel_1.0.17  
 [55] codetools_0.2-19    sjlabelled_1.2.0    processx_3.8.1     
 [58] lattice_0.21-8      withr_2.5.0         evaluate_0.21      
 [61] foreign_0.8-84      xml2_1.3.5          circlize_0.4.15    
 [64] pillar_1.9.0        carData_3.0-5       whisker_0.4.1      
 [67] checkmate_2.2.0     foreach_1.5.2       stats4_4.3.1       
 [70] insight_0.19.3      generics_0.1.3      rprojroot_2.0.3    
 [73] S4Vectors_0.38.1    hms_1.1.3           munsell_0.5.0      
 [76] glue_1.6.2          tools_4.3.1         data.table_1.14.8  
 [79] webshot_0.5.5       fs_1.6.2            colorspace_2.1-0   
 [82] nlme_3.1-162        htmlTable_2.4.1     Formula_1.2-5      
 [85] cli_3.6.1           fansi_1.0.4         viridisLite_0.4.2  
 [88] svglite_2.1.1       gtable_0.3.3        rstatix_0.7.2      
 [91] sass_0.4.6          digest_0.6.33       BiocGenerics_0.46.0
 [94] farver_2.1.1        rjson_0.2.21        htmlwidgets_1.6.2  
 [97] htmltools_0.5.5     lifecycle_1.0.3     httr_1.4.6         
[100] GlobalOptions_0.1.2