From 7ba6b1e5c7e6f152465eb6027e8cbca751151cfa Mon Sep 17 00:00:00 2001 From: Ronak Shah Date: Tue, 21 Jul 2020 11:32:03 -0400 Subject: [PATCH 01/11] Update plot_all_events.R --- R/plot_all_events.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/plot_all_events.R b/R/plot_all_events.R index 97a5d01..bbb9d51 100644 --- a/R/plot_all_events.R +++ b/R/plot_all_events.R @@ -200,7 +200,7 @@ plot_all_events <- function( names = master.ref[cmo_patient_id == x]$cmo_sample_id_plasma) print(transform.vector) tmp.table$Tumor_Sample_Barcode = factor(transform.vector[tmp.table$Tumor_Sample_Barcode], levels = sort(transform.vector)) - + print(tmp.table) if(nrow(tmp.table) == 0 | all(tmp.table$t_alt_count == 0)){ print('skiping to the next') if(nrow(tmp.cna)) stop(paste0('Need to make CNA only file for: ',x)) From 7a170858dfd2502f7f179ad4b44d2a69586f5085 Mon Sep 17 00:00:00 2001 From: Ronak Shah Date: Tue, 21 Jul 2020 11:45:50 -0400 Subject: [PATCH 02/11] Update plot_all_events.R --- R/plot_all_events.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/plot_all_events.R b/R/plot_all_events.R index bbb9d51..1e46ce8 100644 --- a/R/plot_all_events.R +++ b/R/plot_all_events.R @@ -196,7 +196,7 @@ plot_all_events <- function( })) - transform.vector = structure(as.numeric(master.ref[cmo_patient_id == x]$collection_date), + transform.vector = structure(as.date(master.ref[cmo_patient_id == x]$collection_date,'%m/%d/%Y'), names = master.ref[cmo_patient_id == x]$cmo_sample_id_plasma) print(transform.vector) tmp.table$Tumor_Sample_Barcode = factor(transform.vector[tmp.table$Tumor_Sample_Barcode], levels = sort(transform.vector)) @@ -216,7 +216,7 @@ plot_all_events <- function( color = paste0(Hugo_Symbol,' ',ifelse(grepl('^p\\.',HGVSp_Short),HGVSp_Short,'')),shape = call_confidence),size = 1.5) + labs(title=x,x='Time Point', y='VAF') + scale_shape_manual(values=status_id,name = 'Call Status') + scale_color_manual(values = getPalette(colourCount),name = 'Alteration') + - theme_minimal() + scale_y_log10() + + theme_minimal() + scale_y_log10() + scale_x_date(date_minor_breaks = "1 day") + theme(panel.grid.major = element_blank(),legend.position="top",legend.box = "vertical", axis.text.x = element_text(angle=45, hjust=1, face = 'bold')) print(SNV.SV.plot) From 535721eb80f1d940d40368b7b1b84fec01bad62e Mon Sep 17 00:00:00 2001 From: Ronak Shah Date: Tue, 21 Jul 2020 11:46:59 -0400 Subject: [PATCH 03/11] Update plot_all_events.R --- R/plot_all_events.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/plot_all_events.R b/R/plot_all_events.R index 1e46ce8..59d50f8 100644 --- a/R/plot_all_events.R +++ b/R/plot_all_events.R @@ -196,7 +196,7 @@ plot_all_events <- function( })) - transform.vector = structure(as.date(master.ref[cmo_patient_id == x]$collection_date,'%m/%d/%Y'), + transform.vector = structure(as.Date(master.ref[cmo_patient_id == x]$collection_date,'%m/%d/%Y'), names = master.ref[cmo_patient_id == x]$cmo_sample_id_plasma) print(transform.vector) tmp.table$Tumor_Sample_Barcode = factor(transform.vector[tmp.table$Tumor_Sample_Barcode], levels = sort(transform.vector)) From 1cd381cc450b187aca8e0d97f85dc2cfce9beec1 Mon Sep 17 00:00:00 2001 From: Ronak Shah Date: Tue, 21 Jul 2020 12:00:45 -0400 Subject: [PATCH 04/11] Update plot_all_events.R --- R/plot_all_events.R | 84 ++++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 32 deletions(-) diff --git a/R/plot_all_events.R b/R/plot_all_events.R index 59d50f8..2bf70d8 100644 --- a/R/plot_all_events.R +++ b/R/plot_all_events.R @@ -194,48 +194,68 @@ plot_all_events <- function( tmp.cna <- do.call(rbind, lapply(master.ref[cmo_patient_id == x]$cmo_sample_id_plasma, function(y) { fread(paste0(results.dir, "/CNA_final_call_set/", y, "_cna_final_call_set.txt")) })) - - transform.vector = structure(as.Date(master.ref[cmo_patient_id == x]$collection_date,'%m/%d/%Y'), - names = master.ref[cmo_patient_id == x]$cmo_sample_id_plasma) - print(transform.vector) - tmp.table$Tumor_Sample_Barcode = factor(transform.vector[tmp.table$Tumor_Sample_Barcode], levels = sort(transform.vector)) + if (all(!is.na(as.Date(master.ref[cmo_patient_id == x]$collection_date, "%m/%d/%y")))) { + transform.vector <- structure(as.Date(master.ref[cmo_patient_id == x]$collection_date, "%m/%d/%y"), + names = master.ref[cmo_patient_id == x]$cmo_sample_id_plasma + ) + print(transform.vector) + } + else { + transform.vector <- structure(as.character(master.ref[cmo_patient_id == x]$collection_date), + names = master.ref[cmo_patient_id == x]$cmo_sample_id_plasma + ) + print(transform.vector) + } + tmp.table$Tumor_Sample_Barcode <- factor(transform.vector[tmp.table$Tumor_Sample_Barcode], levels = sort(transform.vector)) print(tmp.table) - if(nrow(tmp.table) == 0 | all(tmp.table$t_alt_count == 0)){ - print('skiping to the next') - if(nrow(tmp.cna)) stop(paste0('Need to make CNA only file for: ',x)) + if (nrow(tmp.table) == 0 | all(tmp.table$t_alt_count == 0)) { + print("skiping to the next") + if (nrow(tmp.cna)) stop(paste0("Need to make CNA only file for: ", x)) return() } - - colourCount = nrow(unique(tmp.table[,.(Hugo_Symbol,HGVSp_Short)])) - getPalette = colorRampPalette(brewer.pal(8, "Set2")) - SNV.SV.plot = ggplot(tmp.table) + - geom_line(aes(x = Tumor_Sample_Barcode, y = ifelse(t_total_count == 0, 0, as.numeric(t_alt_count/t_total_count)), - color = paste0(Hugo_Symbol,' ',ifelse(grepl('^p\\.',HGVSp_Short),HGVSp_Short,'')),group = paste0(Hugo_Symbol,'_',HGVSp_Short))) + - geom_point(aes(x = Tumor_Sample_Barcode, y = ifelse(t_total_count == 0, 0, as.numeric(t_alt_count/t_total_count)), - color = paste0(Hugo_Symbol,' ',ifelse(grepl('^p\\.',HGVSp_Short),HGVSp_Short,'')),shape = call_confidence),size = 1.5) + - labs(title=x,x='Time Point', y='VAF') + - scale_shape_manual(values=status_id,name = 'Call Status') + scale_color_manual(values = getPalette(colourCount),name = 'Alteration') + - theme_minimal() + scale_y_log10() + scale_x_date(date_minor_breaks = "1 day") + - theme(panel.grid.major = element_blank(),legend.position="top",legend.box = "vertical", - axis.text.x = element_text(angle=45, hjust=1, face = 'bold')) + + colourCount <- nrow(unique(tmp.table[, .(Hugo_Symbol, HGVSp_Short)])) + getPalette <- colorRampPalette(brewer.pal(8, "Set2")) + SNV.SV.plot <- ggplot(tmp.table) + + geom_line(aes( + x = Tumor_Sample_Barcode, y = ifelse(t_total_count == 0, 0, as.numeric(t_alt_count / t_total_count)), + color = paste0(Hugo_Symbol, " ", ifelse(grepl("^p\\.", HGVSp_Short), HGVSp_Short, "")), group = paste0(Hugo_Symbol, "_", HGVSp_Short) + )) + + geom_point(aes( + x = Tumor_Sample_Barcode, y = ifelse(t_total_count == 0, 0, as.numeric(t_alt_count / t_total_count)), + color = paste0(Hugo_Symbol, " ", ifelse(grepl("^p\\.", HGVSp_Short), HGVSp_Short, "")), shape = call_confidence + ), size = 1.5) + + labs(title = x, x = "Time Point", y = "VAF") + + scale_shape_manual(values = status_id, name = "Call Status") + + scale_color_manual(values = getPalette(colourCount), name = "Alteration") + + theme_minimal() + + scale_y_log10() + + scale_x_date(date_minor_breaks = "1 day") + + theme( + panel.grid.major = element_blank(), legend.position = "top", legend.box = "vertical", + axis.text.x = element_text(angle = 45, hjust = 1, face = "bold") + ) print(SNV.SV.plot) if (nrow(tmp.cna) > 0) { tmp.cna <- tmp.cna %>% mutate(Tumor_Sample_Barcode = factor(Tumor_Sample_Barcode, unique(tmp.sample.sheets[Sample_Type == "duplex"]$Sample_Barcode))) %>% # expand table on all empty samples without any calls - data.table() %>% dcast.data.table(Hugo_Symbol + CNA ~ Tumor_Sample_Barcode,drop = c(TRUE, FALSE),fill = 0,value.var = 'fc') %>% - melt.data.table(id.vars = c('Hugo_Symbol','CNA'),variable.name = 'Tumor_Sample_Barcode',value.name = 'fc') %>% data.table() - tmp.cna$Tumor_Sample_Barcode = transform.vector[tmp.cna$Tumor_Sample_Barcode] - - colourCount = nrow(unique(tmp.cna[,.(Hugo_Symbol,CNA)])) - getPalette = colorRampPalette(brewer.pal(8, "Set2")) - CNA.plot = ggplot(tmp.cna) + - geom_bar(aes(x = Tumor_Sample_Barcode,y = abs(fc),fill = paste0(Hugo_Symbol,'_',CNA)),position="dodge", stat="identity") + - labs(x='Time Point', y='Absolute fc') + - scale_fill_manual(values = getPalette(colourCount),name = 'Alteration') + - theme_minimal() + theme(panel.grid.major = element_blank(),legend.position="bottom",axis.text.x = element_text(angle=45, hjust=1,face = 'bold')) + data.table() %>% + dcast.data.table(Hugo_Symbol + CNA ~ Tumor_Sample_Barcode, drop = c(TRUE, FALSE), fill = 0, value.var = "fc") %>% + melt.data.table(id.vars = c("Hugo_Symbol", "CNA"), variable.name = "Tumor_Sample_Barcode", value.name = "fc") %>% + data.table() + tmp.cna$Tumor_Sample_Barcode <- transform.vector[tmp.cna$Tumor_Sample_Barcode] + + colourCount <- nrow(unique(tmp.cna[, .(Hugo_Symbol, CNA)])) + getPalette <- colorRampPalette(brewer.pal(8, "Set2")) + CNA.plot <- ggplot(tmp.cna) + + geom_bar(aes(x = Tumor_Sample_Barcode, y = abs(fc), fill = paste0(Hugo_Symbol, "_", CNA)), position = "dodge", stat = "identity") + + labs(x = "Time Point", y = "Absolute fc") + + scale_fill_manual(values = getPalette(colourCount), name = "Alteration") + + theme_minimal() + + theme(panel.grid.major = element_blank(), legend.position = "bottom", axis.text.x = element_text(angle = 45, hjust = 1, face = "bold")) print(CNA.plot) pdf(paste0(output.dir, "/", x, "_all_events.pdf"), width = 10, height = 7) From 0da85b84a1417f43ebe01c5575ec29d12c4c0c20 Mon Sep 17 00:00:00 2001 From: Ronak Shah Date: Tue, 21 Jul 2020 12:23:50 -0400 Subject: [PATCH 05/11] Update plot_all_events.R --- R/plot_all_events.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/plot_all_events.R b/R/plot_all_events.R index 2bf70d8..ee23317 100644 --- a/R/plot_all_events.R +++ b/R/plot_all_events.R @@ -199,6 +199,7 @@ plot_all_events <- function( transform.vector <- structure(as.Date(master.ref[cmo_patient_id == x]$collection_date, "%m/%d/%y"), names = master.ref[cmo_patient_id == x]$cmo_sample_id_plasma ) + print("###Date Presentation:####") print(transform.vector) } else { From 6382d5b72a824c242f50780e004f40120b40d90e Mon Sep 17 00:00:00 2001 From: Ronak Shah Date: Tue, 21 Jul 2020 12:25:58 -0400 Subject: [PATCH 06/11] Update plot_all_events.R --- R/plot_all_events.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/plot_all_events.R b/R/plot_all_events.R index ee23317..3451ae9 100644 --- a/R/plot_all_events.R +++ b/R/plot_all_events.R @@ -208,7 +208,7 @@ plot_all_events <- function( ) print(transform.vector) } - tmp.table$Tumor_Sample_Barcode <- factor(transform.vector[tmp.table$Tumor_Sample_Barcode], levels = sort(transform.vector)) + tmp.table$Tumor_Sample_Barcode <- transform.vector[tmp.table$Tumor_Sample_Barcode] print(tmp.table) if (nrow(tmp.table) == 0 | all(tmp.table$t_alt_count == 0)) { print("skiping to the next") From b008222cfde2247a42bb3fe8f8ee6763e7422d2e Mon Sep 17 00:00:00 2001 From: Ronak Shah Date: Tue, 21 Jul 2020 12:32:53 -0400 Subject: [PATCH 07/11] Update plot_all_events.R --- R/plot_all_events.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/plot_all_events.R b/R/plot_all_events.R index 3451ae9..9ce497e 100644 --- a/R/plot_all_events.R +++ b/R/plot_all_events.R @@ -232,7 +232,7 @@ plot_all_events <- function( scale_color_manual(values = getPalette(colourCount), name = "Alteration") + theme_minimal() + scale_y_log10() + - scale_x_date(date_minor_breaks = "1 day") + + scale_x_date(date_minor_breaks = "1 day", date_major_breaks = "1 week", date_labels = "%d") + theme( panel.grid.major = element_blank(), legend.position = "top", legend.box = "vertical", axis.text.x = element_text(angle = 45, hjust = 1, face = "bold") @@ -256,6 +256,7 @@ plot_all_events <- function( labs(x = "Time Point", y = "Absolute fc") + scale_fill_manual(values = getPalette(colourCount), name = "Alteration") + theme_minimal() + + scale_x_date(date_minor_breaks = "1 day", date_major_breaks = "1 week", date_labels = "%d") + theme(panel.grid.major = element_blank(), legend.position = "bottom", axis.text.x = element_text(angle = 45, hjust = 1, face = "bold")) print(CNA.plot) From 7be1f4660b9536f443f19fdaa53fce3abc597ac0 Mon Sep 17 00:00:00 2001 From: Ronak Shah Date: Tue, 21 Jul 2020 12:34:43 -0400 Subject: [PATCH 08/11] Update plot_all_events.R --- R/plot_all_events.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/plot_all_events.R b/R/plot_all_events.R index 9ce497e..243ac70 100644 --- a/R/plot_all_events.R +++ b/R/plot_all_events.R @@ -232,7 +232,7 @@ plot_all_events <- function( scale_color_manual(values = getPalette(colourCount), name = "Alteration") + theme_minimal() + scale_y_log10() + - scale_x_date(date_minor_breaks = "1 day", date_major_breaks = "1 week", date_labels = "%d") + + scale_x_date(date_minor_breaks = "1 day", date_breaks = "1 week", date_labels = "%d") + theme( panel.grid.major = element_blank(), legend.position = "top", legend.box = "vertical", axis.text.x = element_text(angle = 45, hjust = 1, face = "bold") @@ -256,7 +256,7 @@ plot_all_events <- function( labs(x = "Time Point", y = "Absolute fc") + scale_fill_manual(values = getPalette(colourCount), name = "Alteration") + theme_minimal() + - scale_x_date(date_minor_breaks = "1 day", date_major_breaks = "1 week", date_labels = "%d") + + scale_x_date(date_minor_breaks = "1 day", date_breaks = "1 week", date_labels = "%d") + theme(panel.grid.major = element_blank(), legend.position = "bottom", axis.text.x = element_text(angle = 45, hjust = 1, face = "bold")) print(CNA.plot) From cf5eaa7fd94c0d51bab40f8e510727559b95b28b Mon Sep 17 00:00:00 2001 From: Ronak Shah Date: Tue, 21 Jul 2020 12:38:17 -0400 Subject: [PATCH 09/11] Update plot_all_events.R --- R/plot_all_events.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/plot_all_events.R b/R/plot_all_events.R index 243ac70..7ecedcc 100644 --- a/R/plot_all_events.R +++ b/R/plot_all_events.R @@ -232,7 +232,7 @@ plot_all_events <- function( scale_color_manual(values = getPalette(colourCount), name = "Alteration") + theme_minimal() + scale_y_log10() + - scale_x_date(date_minor_breaks = "1 day", date_breaks = "1 week", date_labels = "%d") + + scale_x_date(date_minor_breaks = "1 day", date_breaks = "1 week", date_labels = "%b %d") + theme( panel.grid.major = element_blank(), legend.position = "top", legend.box = "vertical", axis.text.x = element_text(angle = 45, hjust = 1, face = "bold") @@ -256,7 +256,7 @@ plot_all_events <- function( labs(x = "Time Point", y = "Absolute fc") + scale_fill_manual(values = getPalette(colourCount), name = "Alteration") + theme_minimal() + - scale_x_date(date_minor_breaks = "1 day", date_breaks = "1 week", date_labels = "%d") + + scale_x_date(date_minor_breaks = "1 day", date_breaks = "1 week", date_labels = "%b %d") + theme(panel.grid.major = element_blank(), legend.position = "bottom", axis.text.x = element_text(angle = 45, hjust = 1, face = "bold")) print(CNA.plot) From 43a7e9a5ea81075e2e73d50259a90347c0eb5896 Mon Sep 17 00:00:00 2001 From: Ronak Shah Date: Tue, 21 Jul 2020 12:42:58 -0400 Subject: [PATCH 10/11] Update filter_calls.R --- R/filter_calls.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/filter_calls.R b/R/filter_calls.R index ac1e8fb..42486de 100644 --- a/R/filter_calls.R +++ b/R/filter_calls.R @@ -39,7 +39,7 @@ filter_calls = function( # for each patient produce the correct results ---------------------------- # x <- unique(master.ref$cmo_patient_id)[1] - all.fillout.dim <- lapply(unique(master.ref[cmo_patient_id == 'C-DFJ7RT']$cmo_patient_id),function(x){ + all.fillout.dim <- lapply(unique(master.ref[cmo_patient_id]$cmo_patient_id),function(x){ print(paste0('Processing patient ',x)) # Inputs and sanity checks ------------------------------------------------ fillouts.filenames <- list.files(paste0(results.dir,'/',x,'/'),'ORG-STD_genotyped.maf|ORG-SIMPLEX-DUPLEX_genotyped.maf',full.names = T) From 7241c343b9132afe43ebee3d79c1427c41c4d67b Mon Sep 17 00:00:00 2001 From: Ronak Shah Date: Tue, 21 Jul 2020 12:44:42 -0400 Subject: [PATCH 11/11] Update filter_calls.R --- R/filter_calls.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/filter_calls.R b/R/filter_calls.R index 42486de..acd4535 100644 --- a/R/filter_calls.R +++ b/R/filter_calls.R @@ -39,7 +39,7 @@ filter_calls = function( # for each patient produce the correct results ---------------------------- # x <- unique(master.ref$cmo_patient_id)[1] - all.fillout.dim <- lapply(unique(master.ref[cmo_patient_id]$cmo_patient_id),function(x){ + all.fillout.dim <- lapply(unique(master.ref$cmo_patient_id),function(x){ print(paste0('Processing patient ',x)) # Inputs and sanity checks ------------------------------------------------ fillouts.filenames <- list.files(paste0(results.dir,'/',x,'/'),'ORG-STD_genotyped.maf|ORG-SIMPLEX-DUPLEX_genotyped.maf',full.names = T)