Last updated: 2019-05-21

Checks: 5 1

Knit directory: pair_con_select/

This reproducible R Markdown analysis was created with workflowr (version 1.3.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


The R Markdown file has unstaged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20190211) 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! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated.

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:    .Rproj.user/

Untracked files:
    Untracked:  alk_luad_synonymous.csv
    Untracked:  analysis/alk_luad_mutation_bias.Rmd
    Untracked:  analysis/mutation_bias_gist_brca.Rmd
    Untracked:  bias.brca.csv
    Untracked:  bias.gist.csv
    Untracked:  code/alldata_compiler.R
    Untracked:  code/contab_maker.R
    Untracked:  code/mut_excl_genes_datapoints.R
    Untracked:  code/mut_excl_genes_generator.R
    Untracked:  code/quadratic_solver.R
    Untracked:  code/simresults_generator.R
    Untracked:  data/ALKATI_ccle.csv
    Untracked:  data/All_Data_V2.csv
    Untracked:  data/CCLE_NP24.2009_Drug_data_2015.02.24.csv
    Untracked:  data/alkati_growthcurvedata.csv
    Untracked:  data/alkati_growthcurvedata_popdoublings.csv
    Untracked:  data/alkati_melanoma_vemurafenib_figure_data.csv
    Untracked:  data/alkati_simulations_compiled_1000_12319.csv
    Untracked:  data/all_data.csv
    Untracked:  data/gist_expression/
    Untracked:  data/tcga_brca_expression/
    Untracked:  data/tcga_luad_expression/
    Untracked:  data/tcga_skcm_expression/
    Untracked:  docs/figure/Filteranalysis.Rmd/
    Untracked:  mutation_bias_brca_n.pdf
    Untracked:  mutation_bias_brca_probabilities.pdf
    Untracked:  mutation_bias_brca_probabilities2.pdf
    Untracked:  mutation_bias_gist.pdf
    Untracked:  mutation_bias_gist_n.pdf
    Untracked:  mutation_bias_gist_probabilities.pdf
    Untracked:  mutation_bias_gist_probabilities2.pdf
    Untracked:  mutation_bias_luad.pdf
    Untracked:  mutation_bias_luad_deviations.pdf
    Untracked:  mutation_bias_luad_diagnostic.pdf
    Untracked:  mutation_probability.csv
    Untracked:  output/ alkati_subsamplesize_orval_fig1c.pdf
    Untracked:  output/alkati_ccle_tae684_plot.pdf
    Untracked:  output/alkati_filtercutoff_allfilters.csv
    Untracked:  output/alkati_luad_exonimbalance.pdf
    Untracked:  output/alkati_mtn_pval_fig2B.pdf
    Untracked:  output/alkati_skcm_exonimbalance.pdf
    Untracked:  output/alkati_subsamplesize_pval_fig.pdf
    Untracked:  output/alkati_subsamplesize_pval_fig1c.pdf
    Untracked:  output/all_data_luad.csv
    Untracked:  output/all_data_luad_egfr.csv
    Untracked:  output/all_data_skcm.csv
    Untracked:  output/baf3_alkati_figure_deltaadjusted_doublings.pdf
    Untracked:  output/baf3_barplot.pdf
    Untracked:  output/baf3_elisa_barplot.pdf
    Untracked:  output/egfr_luad_exonimbalance.pdf
    Untracked:  output/fig1c_3719_4.pdf
    Untracked:  output/fig2b2_filtercutoff_atinras_totalalk.pdf
    Untracked:  output/fig2b_filtercutoff_atibraf.pdf
    Untracked:  output/fig2b_filtercutoff_atinras.pdf
    Untracked:  output/luad_alk_exon_expression.csv
    Untracked:  output/luad_egfr_exon_expression.csv
    Untracked:  output/melanoma_vemurafenib_fig.pdf
    Untracked:  output/skcm_alk_exon_expression.csv
    Untracked:  output/suppfig1..pdf
    Untracked:  suppfig1..pdf

Unstaged changes:
    Modified:   analysis/ALKATI_Filter_Cutoff_Analysis.Rmd
    Modified:   analysis/ALK_ExonImbalance_SKCM_Analysis.Rmd
    Modified:   analysis/TCGA_luad_data_parser.Rmd
    Modified:   analysis/alkati_cell_line_tae684_response.Rmd
    Modified:   analysis/alkati_subsampling_simulations.Rmd
    Modified:   analysis/baf3_alkati_transformations.Rmd
    Modified:   analysis/index.Rmd
    Modified:   analysis/pairwise_comparisons_conditional_selection_simulated_cohorts.Rmd
    Modified:   analysis/practice.Rmd
    Modified:   analysis/tcga_luad_data_parser_egfr.Rmd

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the R Markdown and HTML files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view them.

File Version Author Date Message
html 6744c50 haiderinam 2019-03-06 Build site.
Rmd b7d812d haiderinam 2019-03-06 Published Fig 4 analysis analysis, added statistical test for fig 3 & 4
html aff917b haiderinam 2019-02-20 Build site.
Rmd 6fec622 haiderinam 2019-02-20 Added EGFR Expression Analysis

This code is to look at the EGFR exon imbalance. Therefore, we need the count data, rsem data, and exon data

LUAD Genes RSEM

rsemdatanormalized=read.table("data/tcga_luad_expression/luadrsemdata/gdac.broadinstitute.org_LUAD.Merge_rnaseqv2__illuminahiseq_rnaseqv2__unc_edu__Level_3__RSEM_genes_normalized__data.Level_3.2016012800.0.0/LUAD.rnaseqv2__illuminahiseq_rnaseqv2__unc_edu__Level_3__RSEM_genes_normalized__data.data.txt",sep = "\t",header = T,stringsAsFactors = F)
egfr_rsem=data.frame(t(rsemdatanormalized[grepl("^egfr\\|",rsemdatanormalized$Hybridization.REF,ignore.case = T),])[-1,])
#410 of the 577 patients have an RSEM higher than 410
colnames(egfr_rsem)[1]="RSEM_normalized"
egfr_rsem$Patid=rownames(egfr_rsem)
#Standardizing Patid Names
egfr_rsem$Patid=substring(egfr_rsem$Patid,first = 1,last = 12)
egfr_rsem$Patid=gsub("\\.","-",egfr_rsem$Patid)

# # As Character
egfr_rsem[colnames(egfr_rsem)] <- lapply(egfr_rsem[colnames(egfr_rsem)],as.character)
# # As Numeric: Converting from list to numeric
egfr_rsem$RSEM_normalized=unlist(egfr_rsem$RSEM_normalized)
egfr_rsem$RSEM_normalized=as.numeric(egfr_rsem$RSEM_normalized)

LUAD Count data:

#Non-normalized:
gene_expression_data=read.table("data/tcga_luad_expression/luadgeneexpression/gdac.broadinstitute.org_LUAD.Merge_rnaseq__illuminahiseq_rnaseq__unc_edu__Level_3__gene_expression__data.Level_3.2016012800.0.0/LUAD.rnaseq__illuminahiseq_rnaseq__unc_edu__Level_3__gene_expression__data.data.txt",sep = "\t",header = T,stringsAsFactors = F)
#Normalized
# gene_expression_data=read.table(,sep = "\t",header = T,stringsAsFactors = F)

  #Finding egfr
  egfr_gene_exp=rbind(gene_expression_data[1,],gene_expression_data[grepl("^egfr\\|",gene_expression_data$Hybridization.REF,ignore.case = T),])
  #Removing Columns for Median_length_normalized and RPKM
  t_egfr_gene_exp=data.frame(t(egfr_gene_exp[,grepl("raw_count",egfr_gene_exp[1,])]))
  
  #Counting patients with raw reads >500
  # sum(as.numeric(as.numeric(as.character(t_egfr_gene_exp$X580))>=500))
#ONLY 6 PATIENTS HAVE RAW COUNTS OF >500

LUAD Exon RPKM This creates a .csv file and only needs to be run once.

# rm(list=ls())#Clears workspace
exondatacomb=read.table("data/tcga_luad_expression/luadexondatacomb/gdac.broadinstitute.org_LUAD.Merge_rnaseq__illuminahiseq_rnaseq__unc_edu__Level_3__exon_expression__data.Level_3.2016012800.0.0/LUAD.rnaseq__illuminahiseq_rnaseq__unc_edu__Level_3__exon_expression__data.data.txt",stringsAsFactors=FALSE,header=TRUE, sep="\t",fill=TRUE)
# head(exondatacomb)

# Obtained EGFR data from here: https://useast.ensembl.org/Homo_sapiens/Gene/Summary?db=core;g=ENSG00000146648;r=7:55019021-55211628

#Chromosome 7
exondatachr7=exondatacomb[grep("^chr7:",exondatacomb$Hybridization.REF),] #i.e. it starts with chromosome 7
#EGFR within Chromosome 7
exondatachr7egfr=exondatacomb[c(90511:90542),]
exondatachr7egfr=exondatachr7egfr[grep(":\\+",exondatachr2egfr$Hybridization.REF),] #i.e. it is only on +ive strand
exondatachr7egfr=exondatachr7egfr[c(-4,-16,-17),]
exondatachr7egfr$exon=c(27:1)
alldataegfr=exondatachr7egfr[,c(488,c(2:487))]
#Switching up order
alldataegfr2=alldataegfr[c(27:1),]
#Making the dataframe of a numeric type so that analysis can be carried out on it.
# As Character
alldataegfr[colnames(alldataegfr)] <- lapply(alldataegfr[colnames(alldataegfr)],as.character)
# As Numeric
alldataegfr[colnames(alldataegfr)] <- lapply(alldataegfr[colnames(alldataegfr)],as.numeric)

#Getting the correct column names for alldataegfr
colnames_exondata=exondatacomb[1,]
colnames(colnames_exondata)=colnames(alldataegfr)

alldataegfr=rbind(colnames_exondata,alldataegfr) #Adding first row that contains names of measurements such as RPKM, RSEM, Counts
write.table(alldataegfr,'output/luad_egfr_exon_expression.csv')

Obtaining RPKM, Count data from LUAD Exon Data. Followed by merging with RSEM data

Note that we’re not concerned with the mutation data of EGFR so we don’t use it here

alldataegfr=read.csv("output/luad_egfr_exon_expression.csv",stringsAsFactors = F,header = T,sep = "",fill = T)
#Getting Count Data
alldataegfr_count=cbind(alldataegfr$exon,alldataegfr[,grepl("raw_counts",alldataegfr[1,])])[-1,]
# As Character
alldataegfr_count[colnames(alldataegfr_count)] <-lapply(alldataegfr_count[colnames(alldataegfr_count)],as.character)
# As Numeric
alldataegfr_count[colnames(alldataegfr_count)] <- lapply(alldataegfr_count[colnames(alldataegfr_count)],as.numeric)
#Sum exons 1:27
egfr_count_data=data.frame(t(data.frame(lapply(alldataegfr_count[c(1:27),],sum))[,-1])) #Not sure if lapply is the right thing to use here. Really messed up way of summing indices in dataframe
colnames(egfr_count_data)="mRNA_count"

alldataegfr_medianlength=cbind(alldataegfr$exon,alldataegfr[,grepl("median_length",alldataegfr[1,])])
# As Character
alldataegfr_medianlength=alldataegfr_medianlength[-1,] #Removing the first row. May be unnecessary in the future
alldataegfr_medianlength[colnames(alldataegfr_medianlength)] <- lapply(alldataegfr_medianlength[colnames(alldataegfr_medianlength)],as.character)
# As Numeric
alldataegfr_medianlength[colnames(alldataegfr_medianlength)] <- lapply(alldataegfr_medianlength[colnames(alldataegfr_medianlength)],as.numeric)
#Sum exons 1:27
egfr_medianlength_data=data.frame(t(data.frame(lapply(alldataegfr_medianlength[c(1:27),],sum))[,-1])) #Removing sum of exons lol
colnames(egfr_medianlength_data)="medianlength"

#Getting RPKM
alldataegfr_RPKM=cbind(alldataegfr$exon,alldataegfr[,grepl("RPKM",alldataegfr[1,])])
# As Character
alldataegfr_RPKM=alldataegfr_RPKM[-1,] #Removing the first row. May be unnecessary in the future
alldataegfr_RPKM[colnames(alldataegfr_RPKM)] <- lapply(alldataegfr_RPKM[colnames(alldataegfr_RPKM)],as.character)
# As Numeric
alldataegfr_RPKM[colnames(alldataegfr_RPKM)] <- lapply(alldataegfr_RPKM[colnames(alldataegfr_RPKM)],as.numeric)
egfr_RPKM_data=data.frame(cbind(lapply(alldataegfr_RPKM[c(1:17),],mean),lapply(alldataegfr_RPKM[c(18:24),],mean))[-1,])
colnames(egfr_RPKM_data)=c("mean_RPKM_1.17","mean_RPKM_18.24")
# As Character
egfr_RPKM_data[colnames(egfr_RPKM_data)] <- lapply(egfr_RPKM_data[colnames(egfr_RPKM_data)],as.character)
# As Numeric
egfr_RPKM_data[colnames(egfr_RPKM_data)] <- lapply(egfr_RPKM_data[colnames(egfr_RPKM_data)],as.numeric)
#  Calculating Ratios of exon RPKM means
egfr_RPKM_data$Ratio18.24=egfr_RPKM_data$mean_RPKM_18.24/egfr_RPKM_data$mean_RPKM_1.17

#Changing rownames (patient_ids) to become the same between each other
rownames(egfr_RPKM_data)=substring(rownames(egfr_RPKM_data),first=1,last=28)
rownames(egfr_medianlength_data)=substring(rownames(egfr_medianlength_data),first=1,last=28)
egfr_RPKM_data$Patid=rownames(egfr_RPKM_data)
egfr_medianlength_data$Patid=rownames(egfr_medianlength_data)
egfr_count_data$Patid=rownames(egfr_count_data)

mergetemp=merge(egfr_RPKM_data,egfr_count_data,by="Patid")
egfr_exon_data=merge(mergetemp,egfr_medianlength_data,by="Patid")
#Transforming the Patids so that they're compatible with the Patids in the mutation data
egfr_exon_data$Patid=substring(egfr_exon_data$Patid,first = 1,last = 12)
#Since the names for exon data are not the same format as the mutation data, we're gonna change that here
egfr_exon_data$Patid=gsub("\\.","-",egfr_exon_data$Patid)

egfr_merged_data=merge(egfr_exon_data,egfr_rsem,by="Patid",all=T)

write.csv(egfr_merged_data,"output/all_data_luad_egfr.csv")

Making EGFR Expression the plots:

egfr_merged_data=read.csv("output/all_data_luad_egfr.csv")

plotly=ggplot(egfr_merged_data,aes(x=mean_RPKM_1.17, y=mean_RPKM_18.24))+
  geom_abline(size=1)+
  geom_point(size=1)+
  scale_x_continuous(trans = "log10",name="Exon 1:17 RPKM",breaks=c(1e-2,1e0,1e2),labels = parse(text = c("10^-2","10^0","10^2")),limits = c(1e-3,1e3))+
  scale_y_continuous(trans = "log10",name="Exon 20:24 RPKM",breaks=c(1e-2,1e0,1e2),labels = parse(text = c("10^-2","10^0","10^2")),limits = c(1e-3,1e3))+
  cleanup+
  theme(plot.title = element_text(hjust=.5),
        text = element_text(size=11,face = "bold"),
        axis.title = element_text(face="bold",size="11"),
        axis.text=element_text(face="bold",size="11",colour = "black"))+
  theme(legend.key.size = unit(30,"pt"))
ggplotly(plotly)
ggsave("output/egfr_luad_exonimbalance.pdf",width =3 ,height =2.5 ,units = "in",useDingbats=F)
Warning: Removed 389 rows containing missing values (geom_point).
###We observed an insignificant difference between the distribution for the 1-17 exons and the 20-24 exons.

Statistical test to see if ALK kinase domain expression was significantly higher than other domains

#Testing if both kinase and ALK expression are different
ks.test(egfr_merged_data$mean_RPKM_1.17,egfr_merged_data$mean_RPKM_18.24)
Warning in ks.test(egfr_merged_data$mean_RPKM_1.17,
egfr_merged_data$mean_RPKM_18.24): p-value will be approximate in the
presence of ties

    Two-sample Kolmogorov-Smirnov test

data:  egfr_merged_data$mean_RPKM_1.17 and egfr_merged_data$mean_RPKM_18.24
D = 0.38397, p-value = 1.332e-15
alternative hypothesis: two-sided
###We observed a significant difference between the distribution for the 20-29 exons and the 1-19 exons The reported p-value was 2-16.
###The p-value from a Chi-sq test was 2.2e-16 too
    #for all ALK data, not ALKATI
ov_expr_obs=c(sum(as.numeric(egfr_merged_data$Ratio18.24>1),na.rm = T),
              dim(egfr_merged_data)[1]-sum(as.numeric(egfr_merged_data$Ratio18.24>1),na.rm = T))
ov_expr_expected=c(round(dim(egfr_merged_data)[1]/2),
                   round(dim(egfr_merged_data)[1]/2))
overexpression=data.frame(rbind(ov_expr_obs,ov_expr_expected))
# overexpression=data.frame(rbind(c(338,13),c(176,176)))
colnames(overexpression)=c("Yes","No")
chisq.test(overexpression)

    Pearson's Chi-squared test with Yates' continuity correction

data:  overexpression
X-squared = 18.24, df = 1, p-value = 1.947e-05

sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.5

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] ggsignif_0.5.0      usethis_1.5.0       devtools_2.0.2     
 [4] RColorBrewer_1.1-2  reshape2_1.4.3      doParallel_1.0.14  
 [7] iterators_1.0.10    foreach_1.4.4       dplyr_0.8.1        
[10] VennDiagram_1.6.20  futile.logger_1.4.3 workflowr_1.3.0    
[13] tictoc_1.0          knitr_1.23          plotly_4.9.0       
[16] ggplot2_3.1.1      

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1           tidyr_0.8.3          prettyunits_1.0.2   
 [4] ps_1.3.0             assertthat_0.2.1     rprojroot_1.3-2     
 [7] digest_0.6.19        mime_0.6             R6_2.4.0            
[10] plyr_1.8.4           futile.options_1.0.1 backports_1.1.4     
[13] evaluate_0.13        httr_1.4.0           pillar_1.4.0        
[16] rlang_0.3.4          lazyeval_0.2.2       data.table_1.12.2   
[19] whisker_0.3-2        callr_3.2.0          rmarkdown_1.12      
[22] desc_1.2.0           stringr_1.4.0        htmlwidgets_1.3     
[25] munsell_0.5.0        shiny_1.3.2          httpuv_1.5.1        
[28] compiler_3.5.2       xfun_0.7             pkgconfig_2.0.2     
[31] pkgbuild_1.0.3       htmltools_0.3.6      tidyselect_0.2.5    
[34] tibble_2.1.1         codetools_0.2-16     viridisLite_0.3.0   
[37] later_0.8.0          crayon_1.3.4         withr_2.1.2         
[40] xtable_1.8-4         jsonlite_1.6         gtable_0.3.0        
[43] git2r_0.25.2         magrittr_1.5         formatR_1.6         
[46] scales_1.0.0         cli_1.1.0            stringi_1.4.3       
[49] promises_1.0.1       fs_1.3.1             remotes_2.0.4       
[52] lambda.r_1.2.3       tools_3.5.2          glue_1.3.1          
[55] purrr_0.3.2          crosstalk_1.0.0      processx_3.3.1      
[58] pkgload_1.0.2        yaml_2.2.0           colorspace_1.4-1    
[61] sessioninfo_1.1.1    memoise_1.1.0