Skip to content

Commit

Permalink
handle missing SV file (fixes #176)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdiakumis committed Oct 16, 2024
1 parent 73dd699 commit 1be38b3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
10 changes: 7 additions & 3 deletions R/fusions.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ fusions_table <- function(fusions) {
"fusion_caller"
)
))
tab1 |>
res <- tab1 |>
DT::datatable(
filter = "none", rownames = FALSE, width = 800, height = 490,
escape = FALSE, extensions = c("Buttons", "Scroller"),
Expand All @@ -202,9 +202,13 @@ fusions_table <- function(fusions) {
DT::formatStyle(columns = names(tab1), `font-size` = "12px", "text-align" = "center") |>
##### Highlight rows with fusions involving cancer genes or DNA support from MANTA
DT::formatStyle(columns = "Cancer gene(s)", backgroundColor = DT::styleEqual(c(FALSE, TRUE), c("transparent", "lightgrey"))) |>
DT::formatStyle(columns = "DNA support (A)", backgroundColor = DT::styleEqual(c(FALSE, TRUE), c("transparent", "coral"))) |>
DT::formatStyle(columns = "DNA support (B)", backgroundColor = DT::styleEqual(c(FALSE, TRUE), c("transparent", "coral"))) |>
DT::formatStyle(columns = "Reported fusion", backgroundColor = DT::styleEqual(c(FALSE, TRUE), c("transparent", "lightgreen")))
if (all(c("DNA support (A)", "DNA support (B)") %in% colnames(tab1))) {
res <- res |>
DT::formatStyle(columns = "DNA support (A)", backgroundColor = DT::styleEqual(c(FALSE, TRUE), c("transparent", "coral"))) |>
DT::formatStyle(columns = "DNA support (B)", backgroundColor = DT::styleEqual(c(FALSE, TRUE), c("transparent", "coral")))
}
return(res)
}

#' RCircos HG38 CytoBandIdeogram Object
Expand Down
28 changes: 20 additions & 8 deletions inst/rmd/rnasum.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -1525,8 +1525,15 @@ if (!is.null(add_cancer_group)) {
##### ...gene fusion section: Include only those which are DNA-supported (see Structural variants section) or reported in FusionGDB
ref_genes.list[["summary"]]$Fusion <- NULL
if (runFusionChunk) {
ref_genes.list[["summary"]]$Fusion <- fusions |>
dplyr::filter(.data$reported_fusion | .data$geneA_dna_support | .data$geneB_dna_support) |>
tmp <- NULL
if (runSVsChunk) {
tmp <- fusions |>
dplyr::filter(.data$reported_fusion | .data$geneA_dna_support | .data$geneB_dna_support)
} else {
tmp <- fusions |>
dplyr::filter(.data$reported_fusion)
}
ref_genes.list[["summary"]]$Fusion <- tmp |>
dplyr::select("geneA", "geneB") |>
unlist() |>
unique()
Expand Down Expand Up @@ -2235,7 +2242,7 @@ Fusion genes detected in transcriptome data are reported if **at least one** of

### - Summary

Out of the `r if ( runFusionChunk ) { nrow(fusions) } else { c("0") }` fusion event(s) [**`r if ( runFusionChunk ) { nrow(fusions[ fusions$geneA_dna_support | fusions$geneB_dna_support, ]) } else { c("0") }`**]{style="color:#ff0000"} involve **DNA-supported** fusion genes (see [Structural variants] section), [**`r if ( runFusionChunk ) { nrow(fusions[ fusions$reported_fusion, ]) } else { c("0") }`**]{style="color:#02d653"} are **reported in [FusionGDB](https://ccsm.uth.edu/FusionGDB)** and [**`r if ( runFusionChunk ) { nrow(fusions[ fusions$fusions_cancer, ]) } else { c("0") }`**]{style="color:#767689"} involve **[Cancer genes]**.
Out of the `r if ( runFusionChunk ) { nrow(fusions) } else { c("0") }` fusion event(s) [**`r if ( runFusionChunk && runSVsChunk ) { nrow(fusions[ fusions$geneA_dna_support | fusions$geneB_dna_support, ]) } else { c("0") }`**]{style="color:#ff0000"} involve **DNA-supported** fusion genes (see [Structural variants] section), [**`r if ( runFusionChunk ) { nrow(fusions[ fusions$reported_fusion, ]) } else { c("0") }`**]{style="color:#02d653"} are **reported in [FusionGDB](https://ccsm.uth.edu/FusionGDB)** and [**`r if ( runFusionChunk ) { nrow(fusions[ fusions$fusions_cancer, ]) } else { c("0") }`**]{style="color:#767689"} involve **[Cancer genes]**.

**`r if ( !runFusionChunk ) { c("No fusion genes were detected!") }`**

Expand Down Expand Up @@ -2304,10 +2311,10 @@ Fusion events are ordered by the following columns:

### - Genomic view

[**`r if ( runFusionChunk ) { nrow(fusions[ (fusions$geneA_dna_support | fusions$geneB_dna_support) & fusions$circos, ]) } else { c("0") }`**]{style="color:#ff0000"} **DNA-supported** fusion genes (see [Structural variants] section) and [**`r if ( runFusionChunk ) { nrow(fusions[ fusions$reported_fusion & fusions$circos, ]) } else { c("0") }`**]{style="color:#02d653"} fusions events **reported in [FusionGDB](https://ccsm.uth.edu/FusionGDB)** are presented in the genomic context. [*Red*]{style="color:#ff0000"} is used for links between positions of same chromosomes and [*blue*]{style="color:#0000ff"} for links between different chromosomes. The table at the bottom contains genomic coordinates of individual fusion genes sorted by their genomic location.
[**`r if ( runFusionChunk && runSVsChunk ) { nrow(fusions[ (fusions$geneA_dna_support | fusions$geneB_dna_support) & fusions$circos, ]) } else { c("0") }`**]{style="color:#ff0000"} **DNA-supported** fusion genes (see [Structural variants] section) and [**`r if ( runFusionChunk ) { nrow(fusions[ fusions$reported_fusion & fusions$circos, ]) } else { c("0") }`**]{style="color:#02d653"} fusions events **reported in [FusionGDB](https://ccsm.uth.edu/FusionGDB)** are presented in the genomic context. [*Red*]{style="color:#ff0000"} is used for links between positions of same chromosomes and [*blue*]{style="color:#0000ff"} for links between different chromosomes. The table at the bottom contains genomic coordinates of individual fusion genes sorted by their genomic location.

[NOTE]{style="color:#ff0000"}:
**`r if ( runFusionChunk ) { nrow(fusions[ (fusions$geneA_dna_support | fusions$geneB_dna_support) & fusions$circos, ]) } else { c("0") }`** of such fusions do not have genomic information available and are not presented on the *circos plot* (see *Genomic view* column in the [- Summary] table).
**`r if ( runFusionChunk && runSVsChunk ) { nrow(fusions[ (fusions$geneA_dna_support | fusions$geneB_dna_support) & fusions$circos, ]) } else { c("0") }`** of such fusions do not have genomic information available and are not presented on the *circos plot* (see *Genomic view* column in the [- Summary] table).

`r if ( !runSVsChunk ) { c("Genomic data for this sample is **NOT AVAILABLE**.") }`

Expand Down Expand Up @@ -4510,12 +4517,17 @@ cat(drugsTable_legend)

`r if ( params$drugs && !runFusionChunk ) { c("Fusion genes information for this sample is **NOT AVAILABLE**.") }`

`r if ( params$drugs && runFusionChunk ) { paste0("<span style=\"color:#ff0000\">**", nrow(fusions[ fusions$geneA_dna_support == "Yes" | fusions$geneB_dna_support == "Yes" , ]), "**</span> **DNA-supported** fusion genes (see [Structural variants] section) and <span style=\"color:#02d653\">**", nrow(fusions[ fusions$reported_fusion == "Yes" , ]), "**</span> gene fusions **reported in [FusionGDB](https://ccsm.uth.edu/FusionGDB)** were screened for suitable drugs.") } else if ( params$drugs && !runFusionChunk ) { paste0("<span style=\"color:#ff0000\">**0**</span> involving **DNA-supported** fusion genes (see [Structural variants] section) and <span style=\"color:#02d653\">**0**</span> gene fusions **reported in [FusionGDB](https://ccsm.uth.edu/FusionGDB)** were screened for suitable drugs.") }`
`r if ( params$drugs && runFusionChunk && runSVsChunk ) { paste0("<span style=\"color:#ff0000\">**", nrow(fusions[ fusions$geneA_dna_support == "Yes" | fusions$geneB_dna_support == "Yes" , ]), "**</span> **DNA-supported** fusion genes (see [Structural variants] section) and <span style=\"color:#02d653\">**", nrow(fusions[ fusions$reported_fusion == "Yes" , ]), "**</span> gene fusions **reported in [FusionGDB](https://ccsm.uth.edu/FusionGDB)** were screened for suitable drugs.") } else if ( params$drugs && !runFusionChunk ) { paste0("<span style=\"color:#ff0000\">**0**</span> involving **DNA-supported** fusion genes (see [Structural variants] section) and <span style=\"color:#02d653\">**0**</span> gene fusions **reported in [FusionGDB](https://ccsm.uth.edu/FusionGDB)** were screened for suitable drugs.") }`

```{r drugs_predictive_fusion_genes, comment = NA, message=FALSE, warning=FALSE, eval = runFusionChunk}
##### Generate table with drugs targeting fusion genes
genesA <- as.vector(fusions[fusions_ann$reported_fusion == "Yes" | fusions_ann$geneA_dna_support == "Yes" | fusions_ann$geneB_dna_support == "Yes", ]$geneA)
genesB <- as.vector(fusions[fusions_ann$reported_fusion == "Yes" | fusions_ann$geneA_dna_support == "Yes" | fusions_ann$geneB_dna_support == "Yes", ]$geneB)
if (runSVsChunk) {
genesA <- as.vector(fusions[fusions_ann$reported_fusion == "Yes" | fusions_ann$geneA_dna_support == "Yes" | fusions_ann$geneB_dna_support == "Yes", ]$geneA)
genesB <- as.vector(fusions[fusions_ann$reported_fusion == "Yes" | fusions_ann$geneA_dna_support == "Yes" | fusions_ann$geneB_dna_support == "Yes", ]$geneB)
} else {
genesA <- as.vector(fusions[fusions_ann$reported_fusion == "Yes", ]$geneA)
genesB <- as.vector(fusions[fusions_ann$reported_fusion == "Yes", ]$geneB)
}
drugsTable.fusion_genes <- RNAsum::civicDrugTable(
genes = unique(c(genesA, genesB)),
Expand Down

0 comments on commit 1be38b3

Please sign in to comment.