packages <- c( "tidyverse", "printr", "ggthemes", "readr", "miR34AasRNAproject", "grid", "gtable" ) purrr::walk(packages, library, character.only = TRUE) rm(packages)
Note: in cases where less than 3 samples are in any group, r-estimates and p-values are not reported.
data <- getData("Supplementary Figure 1a") #normalize expression values data <- mutate( data, RP3 = log2(RP3 / max(RP3)), miR34a = log2(miR34a / max(miR34a)) ) #add BRCA subtypes data <- data %>% mutate(PAM50 = if_else(is.na(PAM50), "", PAM50)) %>% mutate(cancer_PAM50 = gsub("BRCA", "BRCA ", paste(cancer, PAM50, sep = ""))) #sort data <- arrange(data, cancer_PAM50, TP53, RP3) #remove infinite data data <- filter(data, !is.infinite(RP3) & !is.infinite(miR34a)) #diploid only data <- filter(data, abs(RP3_cna) < 0.1) #rename TP53 data <- mutate(data, TP53 = if_else(TP53 == 1, "TP53mut", "TP53wt")) #diploid only correlation analysis #calculate correlation for all samples per cancer type all <- data %>% filter(RP3_cna < 0.1) %>% group_by(cancer_PAM50) %>% summarize( n = n(), `all p` = cor.test(RP3, miR34a, method = "spearman")$p.value, `all rho` = cor.test(RP3, miR34a, method = "spearman")$estimate ) %>% mutate( `all p` = format(`all p`, scientific = TRUE, digits = 3), `all rho` = format(`all rho`, scientific = FALSE, digits = 2) ) #calculate correlation for p53 wt and mut samples per cancer type p53 <- data %>% group_by(cancer_PAM50, TP53) %>% filter(n() > 3) %>% summarize( n = n(), p = cor.test(RP3, miR34a, method = "spearman")$p.value, rho = cor.test(RP3, miR34a, method = "spearman")$estimate ) %>% ungroup() %>% mutate( p = format(p, scientific = TRUE, digits = 3), rho = format(rho, scientific = FALSE, digits = 1) ) %>% gather(metric, value, -(cancer_PAM50:TP53)) %>% unite(temp, TP53, metric, sep = " ") %>% spread(temp, value) table <- full_join(all, p53, by = "cancer_PAM50") %>% rename(cancer = cancer_PAM50, `all n` = n) %>% select( cancer, `all n`, `all rho`, `all p`, `TP53wt n`, `TP53wt rho`, `TP53wt p`, `TP53mut n`, `TP53mut rho`, `TP53mut p` ) table #add abbreviation definitions def <- tibble( fullName = c( "Adrenocortical carcinoma", "Bladder Urothelial Carcinoma", "Breast invasive carcinoma", "Breast invasive carcinoma", "Breast invasive carcinoma", "Breast invasive carcinoma", "Cervical squamous cell carcinoma and\nendocervical adenocarcinoma", "Head and Neck squamous cell carcinoma", "Kidney Chromophobe", "Kidney renal clear cell carcinoma", "Kidney renal papillary cell carcinoma", "Brain Lower Grade Glioma", "Liver hepatocellular carcinoma", "Lung adenocarcinoma", "Lung squamous cell carcinoma", "Ovarian serous cystadenocarcinoma", "Prostate adenocarcinoma", "Skin Cutaneous Melanoma", "Stomach adenocarcinoma", "Thyroid carcinoma" ), cancer = c( "ACC", "BLCA", "BRCA Basal", "BRCA Her2", "BRCA LumA", "BRCA LumB", "CESC", "HNSC", "KICH", "KIRC", "KIRP", "LGG", "LIHC", "LUAD", "LUSC", "OV", "PRAD", "SKCM", "STAD", "THCA" ) ) table <- def %>% full_join(table, by = "cancer") %>% mutate(finalName = case_when( fullName == "Breast invasive carcinoma" ~ paste(fullName, gsub("BRCA", "(BRCA)", cancer), sep = " "), TRUE ~ paste(fullName, "(", cancer, ")", sep = " ") )) %>% select(-fullName, -cancer) %>% rename(cancer = finalName) %>% select(cancer, `all n`, `all rho`, `all p`, `TP53wt n`, `TP53wt rho`, `TP53wt p`, `TP53mut n`, `TP53mut rho`, `TP53mut p`) #save figure # path <- file.path("~/GitHub/miR34a_asRNA_project/inst", fileMap(type = "pdf")["Figure 1-Supplement 1a"][[1]]) # pdf(file = path, width = 13, height = 6.1) # gridExtra::grid.table(table, rows = NULL) # invisible(dev.off())
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.