diff --git a/src/harpy/reports/Leviathan.Rmd b/src/harpy/reports/Leviathan.Rmd index 0f0d3ac26..aca141ad4 100644 --- a/src/harpy/reports/Leviathan.Rmd +++ b/src/harpy/reports/Leviathan.Rmd @@ -1,5 +1,5 @@ --- -title: "Leviathan Structural Variant Calling Summary" +title: "Structural Variant Calling Summary (LEVIATHAN)" date: "`r format(Sys.time(), '%d %b, %Y at %H:%M')`" output: flexdashboard::flex_dashboard: diff --git a/src/harpy/reports/LeviathanPop.Rmd b/src/harpy/reports/LeviathanPop.Rmd index 7a4f41c24..ac9ab3660 100644 --- a/src/harpy/reports/LeviathanPop.Rmd +++ b/src/harpy/reports/LeviathanPop.Rmd @@ -1,5 +1,5 @@ --- -title: "Leviathan Structural Variant Calling Summary" +title: "Structural Variant Calling Summary (LEVIATHAN)" date: "`r format(Sys.time(), '%d %b, %Y at %H:%M')`" output: flexdashboard::flex_dashboard: diff --git a/src/harpy/reports/Naibr.Rmd b/src/harpy/reports/Naibr.Rmd index e75bad485..6ce8b3426 100644 --- a/src/harpy/reports/Naibr.Rmd +++ b/src/harpy/reports/Naibr.Rmd @@ -1,5 +1,5 @@ --- -title: "NAIBR Structural Variant Calling Summary" +title: "Structural Variant Calling Summary (NAIBR)" date: "`r format(Sys.time(), '%d %b, %Y at %H:%M')`" output: flexdashboard::flex_dashboard: @@ -267,12 +267,11 @@ You may click on the plot to expand it in your browser window. Clicking it again out of the zoomed view. ```{r} -justcolors <- c("#4a9fea", "#5a8c84", "#ffd75f") - -data.frame(x = 1, y = 1:3, colour = c("Inversion", "Deletion","Duplication")) %>% +color.palette <- c("deletion" = "#5a8c84", "duplication" = "#ffd75f", "inversion" = "#4a9fea") +data.frame(x = 1, y = 1:3, colour = c("inversion", "deletion","duplication")) %>% ggplot(aes(x, y, fill = colour))+ geom_point(alpha=0, shape = 22, color = "white")+ # completely transparent rectangular point - scale_fill_manual(values=justcolors, drop=FALSE) + + scale_fill_manual(values=color.palette, drop=FALSE) + guides(fill = guide_legend(override.aes = list(alpha=1, size = 25)))+ # showing the point in the legend theme(axis.title = element_blank(), axis.text = element_blank(), @@ -388,36 +387,23 @@ allowing you to hover over a variant to provide additional information, includin number of haplotag barcodes supporting the variant. ```{r colors, echo = FALSE, warning = FALSE, message = FALSE} -color.palette <- c( - "deletion" = "#5a8c84", - "duplication" = "#ffd75f", - "inversion" = "#4a9fea" -) - sv$ystart <- case_when( sv$SV == "inversion" ~ 0.1, sv$SV == "duplication" ~ 1.1, sv$SV == "deletion" ~ 2.1 ) sv$ystop <- sv$ystart + 0.8 + +figheight <- nrow(fa.sizes) * 160 ``` -```{r} -l <- list() -#nplotrows <- 0 -for (i in 1:nrow(fa.sizes)) { - sv.filt <- sv %>% filter(Chr1 == fa.sizes$contig[i]) - sv_stats <- group_by(sv.filt, SV) %>% summarise(n = length(SV)) - if (nrow(sv_stats) == 0) { - next - } - plt <- sv.filt %>% - ggplot() + +```{r interactive_plot, fig.height=figheight} +plt <- ggplot(sv) + geom_rect( alpha = 0.7, aes( - xmin = Break1, - xmax = Break2, + xmin = Break1/1000000, + xmax = Break2/1000000, ymin = ystart, ymax = ystop, fill = SV, @@ -439,28 +425,14 @@ for (i in 1:nrow(fa.sizes)) { strip.text = element_text(color = "grey20"), legend.position = "none", ) + + coord_cartesian(xlim = c(0, NA), expand = F) + scale_x_continuous(labels = scales::comma) + - coord_cartesian(xlim = c(0, fa.sizes$size[i] + 1), expand = F) + scale_y_continuous( breaks = c(0.5, 1.5, 2.5), labels = c("INV", "DUP", "DEL"), limits = c(0,3) ) + - xlab("Position (bp)") - annotations <- list( - x = 0.5, - y = 1.05, - text = as.character(fa.sizes$contig[i]), - xref = "paper", - yref = "paper", - xanchor = "center", - yanchor = "bottom", - showarrow = FALSE - ) - l[[i]] <- subplot(ggplotly(plt, height = 800, tooltip = "text")) -} + xlab("Position (Mbp)") -# remove null -l <- Filter(Negate(is.null), l) -subplot(l, nrows = length(l) , shareX = FALSE, titleX = TRUE) +ggplotly(plt, height = figheight, tooltip = "text", margin = list(l = 50, r = 50, b = 100, t = 100, pad = 1)) ``` \ No newline at end of file diff --git a/src/harpy/reports/NaibrPop.Rmd b/src/harpy/reports/NaibrPop.Rmd index 80c36aab4..8175e474f 100644 --- a/src/harpy/reports/NaibrPop.Rmd +++ b/src/harpy/reports/NaibrPop.Rmd @@ -1,5 +1,5 @@ --- -title: "NAIBR Structural Variant Calling Summary" +title: "Structural Variant Calling Summary (NAIBR)" date: "`r format(Sys.time(), '%d %b, %Y at %H:%M')`" output: flexdashboard::flex_dashboard: