Skip to content

Commit

Permalink
Merge branch 'release/0.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhshah committed Jul 24, 2020
2 parents a8f85d7 + 892e7a0 commit 8bd5447
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 53 deletions.
5 changes: 4 additions & 1 deletion R/SV_incorporation.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ SV_incorporation = function(
}else{
# dummy df if there is no DMP fusion found
DMP.sv <- data.frame(matrix(nrow = 0,ncol = ncol(DMP.fusion)))
colnames(DMP.sv) <- colnames(DMP.fusion)
colnames(DMP.sv) <- colnames(total.sv)
}
print('done with reading in')
print(colnames(total.sv))
print(colnames(DMP.sv))

# event desc. reconciliating possible DMP vs manta ------------------------
rbind(total.sv,DMP.sv) %>%
Expand Down
193 changes: 142 additions & 51 deletions R/plot_all_events.R
Original file line number Diff line number Diff line change
Expand Up @@ -199,74 +199,165 @@ 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)
# print("###Date Presentation:####")
# 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)
# print(transform.vector)
}
tmp.table$Tumor_Sample_Barcode <- transform.vector[tmp.table$Tumor_Sample_Barcode]
print(tmp.table)
#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))
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", 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")
)
print(SNV.SV.plot)
if (all(!is.na(as.Date(transform.vector, "%m/%d/%y")))) {
colourCount <- nrow(unique(tmp.table[, .(Hugo_Symbol, HGVSp_Short)]))
getPalette <- colorRampPalette(brewer.pal(8, "Set3"))
SNV.SV.plot.log <- 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 (weeks)", y = "log10(variant allele frequency)") +
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", 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")
)
print(SNV.SV.plot.log)
SNV.SV.plot.linear <- 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 (weeks)", y = "variant allele frequency") +
scale_shape_manual(values = status_id, name = "Call Status") +
scale_color_manual(values = getPalette(colourCount), name = "Alteration") +
theme_minimal() +
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")
)
print(SNV.SV.plot.linear)

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]

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, "Set3"))
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 (weeks)", y = "absolute fold-change") +
scale_fill_manual(values = getPalette(colourCount), name = "Alteration") +
theme_minimal() +
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)

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") +
pdf(paste0(output.dir, "/", x, "_all_events.pdf"), width = 16, height = 8)
print(ggarrange(SNV.SV.plot.log, SNV.SV.plot.linear, CNA.plot, CNA.plot, ncol = 2, nrow = 2, heights = c(2, 2, 1, 1)))
dev.off()
} else {
pdf(paste0(output.dir, "/", x, "_all_events.pdf"), width = 16, height = 8)
print(ggarrange(SNV.SV.plot.log, SNV.SV.plot.linear, ncol = 2, heights = c(2, 2)))
dev.off()
}
}
else {
colourCount <- nrow(unique(tmp.table[, .(Hugo_Symbol, HGVSp_Short)]))
getPalette <- colorRampPalette(brewer.pal(8, "Set3"))
SNV.SV.plot.log <- 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 = "log10(variant allele frequency)") +
scale_shape_manual(values = status_id, name = "Call Status") +
scale_color_manual(values = getPalette(colourCount), name = "Alteration") +
theme_minimal() +
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)
scale_y_log10() +
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.log)
SNV.SV.plot.linear <- 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 = "variant allele frequency") +
scale_shape_manual(values = status_id, name = "Call Status") +
scale_color_manual(values = getPalette(colourCount), name = "Alteration") +
theme_minimal() +
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.linear)

pdf(paste0(output.dir, "/", x, "_all_events.pdf"), width = 10, height = 7)
print(ggarrange(SNV.SV.plot, CNA.plot, ncol = 1, heights = c(2, 1)))
dev.off()
} else {
pdf(paste0(output.dir, "/", x, "_all_events.pdf"), width = 10, height = 7)
print(SNV.SV.plot)
dev.off()
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, "Set3"))
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 fold-change") +
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 = 16, height = 8)
print(ggarrange(SNV.SV.plot.log, SNV.SV.plot.linear, CNA.plot, CNA.plot, ncol = 2, nrow = 2, heights = c(2, 2, 1, 1)))
dev.off()
} else {
pdf(paste0(output.dir, "/", x, "_all_events.pdf"), width = 16, height = 8)
print(ggarrange(SNV.SV.plot.log, SNV.SV.plot.linear, ncol = 2, heights = c(2, 2)))
dev.off()
}
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ Scripts for downstream analysis plotting of pipeline output

## Documentation

https://msk-access.gitbook.io/access-data-analysis-v1/analysis/compile-reads
https://msk-access.gitbook.io/access-data-analysis-v1/

0 comments on commit 8bd5447

Please sign in to comment.