Skip to content

Commit

Permalink
Merge branch 'unit-test'
Browse files Browse the repository at this point in the history
  • Loading branch information
federicomarini committed Mar 9, 2021
2 parents c8aec4a + 470ee1d commit ae9ca90
Show file tree
Hide file tree
Showing 88 changed files with 1,701 additions and 86,735 deletions.
22 changes: 18 additions & 4 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
fail-fast: false
matrix:
config:
- { os: windows-latest, r: 'release', bioc: '3.11'}
- { os: macOS-latest, r: 'release', bioc: '3.11'}
- { os: macOS-latest, r: 'release', bioc: 'devel'}
- { os: windows-latest, r: 'devel', bioc: 'devel'}
- { os: macOS-latest, r: 'release', bioc: '3.12'}
- { os: macOS-latest, r: 'devel', bioc: 'devel', curlConfigPath: '/usr/bin/'}
- { os: ubuntu-latest, r: 'release', image: 'bioconductor/bioconductor_docker:devel'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
CRAN: ${{ matrix.config.cran }}
Expand Down Expand Up @@ -66,6 +66,19 @@ jobs:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-r-${{ matrix.config.r }}-bioc-${{ matrix.config.bioc }}-${{ hashFiles('depends.Rds') }}
restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-bioc-${{ matrix.config.bioc }}-

- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install harfbuzz
brew install fribidi
- name: Set up gfortran symlinks (macOS)
if: runner.os == 'macOS'
run: |
set -x
sudo ln -s /usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8 /usr/local/gfortran/lib
gfortran --version
- name: Install system dependencies
if: runner.os == 'Linux'
Expand All @@ -83,6 +96,7 @@ jobs:
deps <- remotes::dev_package_deps(dependencies = TRUE, repos = BiocManager::repositories())
BiocManager::install(local_deps[local_deps %in% deps$package[deps$diff != 0]], Ncpu = 2L)
remotes::install_cran('rcmdcheck', Ncpu = 2L)
BiocManager::install("federicomarini/annoFuseData")
shell: Rscript {0}

- name: Session info
Expand Down
8 changes: 7 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.1
Depends:
annoFuseData
Imports:
reshape2,
dplyr,
tidyr,
tidyselect,
purrr,
ggplot2,
qdapRegex,
Expand All @@ -49,7 +52,10 @@ Imports:
rmarkdown,
methods
Suggests:
knitr
knitr,
testthat
Remotes:
federicomarini/annoFuseData
VignetteBuilder: knitr
NeedsCompilation: no
biocViews:
Expand Down
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export(samplecount_fusion_calls)
export(shinyFuse)
export(theme_publication)
export(zscored_annotation)
import(annoFuseData)
import(rintrojs)
import(shiny, except = c(renderDataTable, dataTableOutput))
import(shinydashboard)
Expand Down Expand Up @@ -109,9 +110,9 @@ importFrom(tibble,column_to_rownames)
importFrom(tibble,remove_rownames)
importFrom(tibble,rownames_to_column)
importFrom(tidyr,gather)
importFrom(tidyr,one_of)
importFrom(tidyr,separate)
importFrom(tidyr,unnest)
importFrom(tidyselect,one_of)
importFrom(utils,browseURL)
importFrom(utils,head)
importFrom(utils,read.delim)
50 changes: 27 additions & 23 deletions R/aggregate_fusion_calls.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#' Function to aggregate Caller and read support per fusions calls
#'
#' @param standardFusioncalls A dataframe from star fusion or arriba standardized
#' @param standardFusioncalls A dataframe from star fusion or arriba standardized
#' to run through the filtering steps
#' @param removeother TRUE to remove Fusion_Type="other" and keep only in-frame and
#' @param removeother TRUE to remove Fusion_Type="other" and keep only in-frame and
#' frameshift Default: FALSE
#' @param filterAnnots regex to remove from annots column eg.
#' LOCAL_REARRANGEMENT|LOCAL_INVERSION
#' @param filterAnnots regex to remove from annots column eg.
#' LOCAL_REARRANGEMENT|LOCAL_INVERSION
#' ## TODO: should this mentioned above be e.g. the default value?
#'
#' @export
Expand All @@ -15,33 +15,37 @@
#' @examples
#' # standardize
#' fusionfileArriba <- read_arriba_calls(
#' system.file("extdata", "arriba_example.tsv", package = "annoFuse"))
#' system.file("extdata", "arriba_example.tsv", package = "annoFuseData")
#' )
#' fusionfileStarFusion <- read_starfusion_calls(
#' system.file("extdata", "starfusion_example.tsv", package = "annoFuse"))
#' system.file("extdata", "starfusion_example.tsv", package = "annoFuseData")
#' )
#' formattedArriba <- fusion_standardization(fusionfileArriba,
#' caller = "ARRIBA",
#' tumorID = "tumorID")
#' caller = "ARRIBA",
#' tumorID = "tumorID"
#' )
#' formattedStarFusion <- fusion_standardization(fusionfileStarFusion,
#' caller = "STARFUSION",
#' tumorID = "tumorID")
#' caller = "STARFUSION",
#' tumorID = "tumorID"
#' )
#' # merge standardized fusion calls
#' standardFusioncalls <- as.data.frame(rbind(formattedStarFusion, formattedArriba))
#' fusionQCFiltered <- fusion_filtering_QC(
#' standardFusioncalls = standardFusioncalls,
#' standardFusioncalls = standardFusioncalls,
#' readingFrameFilter = "in-frame|frameshift|other",
#' artifactFilter = "GTEx_Recurrent|DGD_PARALOGS|Normal|BodyMap|ConjoinG",
#' junctionReadCountFilter = 1,
#' spanningFragCountFilter = 10,
#' readthroughFilter = TRUE)
#' # aggregate calls
#' aggregate_fusion_calls(fusionQCFiltered)
#'
#' readthroughFilter = TRUE
#' )
#' # aggregate calls
#' aggregate_fusion_calls(fusionQCFiltered)
aggregate_fusion_calls <- function(standardFusioncalls,
removeother = FALSE,
filterAnnots) {
standardFusioncalls <- .check_annoFuse_calls(standardFusioncalls)
stopifnot(is.logical(removeother))

if (removeother) {
# aggregate caller per FusionName, Sample and Fusion_Type
fusion_caller.summary <- standardFusioncalls %>%
Expand All @@ -50,20 +54,20 @@ aggregate_fusion_calls <- function(standardFusioncalls,
group_by(.data$FusionName, .data$Sample, .data$Fusion_Type) %>%
unique() %>%
dplyr::mutate(CalledBy = toString(.data$Caller), caller_count = n())

if (!missing(filterAnnots)) {
# remove fusion within local rearrangement if required for your project
standardFusioncalls <- standardFusioncalls %>%
# remove local rearrangement/adjacent genes use "LOCAL_REARRANGEMENT|LOCAL_INVERSION"
dplyr::filter(!grepl(filterAnnots, .data$annots))
}

# to add aggregated caller from fusion_caller.summary
standardFusioncalls <- standardFusioncalls %>%
dplyr::filter(.data$Fusion_Type != "other") %>%
left_join(fusion_caller.summary, by = (c("Sample", "FusionName", "Fusion_Type", "Caller"))) %>%
unique()

return(standardFusioncalls)
}
else {
Expand All @@ -73,19 +77,19 @@ aggregate_fusion_calls <- function(standardFusioncalls,
group_by(.data$FusionName, .data$Sample, .data$Fusion_Type) %>%
unique() %>%
dplyr::mutate(CalledBy = toString(.data$Caller), caller_count = n())

if (!missing(filterAnnots)) {
# remove fusion within local rearrangement if required for your project
standardFusioncalls <- standardFusioncalls %>%
# remove local rearrangement/adjacent genes use "LOCAL_REARRANGEMENT|LOCAL_INVERSION"
dplyr::filter(!grepl(filterAnnots, .data$annots))
}

# to add aggregated caller from fusion_caller.summary
standardFusioncalls <- standardFusioncalls %>%
left_join(fusion_caller.summary, by = (c("Sample", "FusionName", "Fusion_Type", "Caller"))) %>%
unique()

return(standardFusioncalls)
}
}
}
8 changes: 5 additions & 3 deletions R/annoFuse-pkg.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@
#' @importFrom reshape2 colsplit dcast melt
#' @importFrom stats na.omit
#' @importFrom stringr str_detect str_replace
#' @importFrom tibble add_column column_to_rownames remove_rownames
#' @importFrom tibble add_column column_to_rownames remove_rownames
#' rownames_to_column
#' @importFrom tidyr gather separate unnest one_of
#' @importFrom tidyr gather separate unnest
#' @importFrom tidyselect one_of
#' @importFrom utils head read.delim browseURL
#' @importFrom EnsDb.Hsapiens.v86 EnsDb.Hsapiens.v86
#' @importFrom ensembldb genes
#' @importFrom purrr is_empty
#' @importFrom rmarkdown render
#' @importFrom methods is
#' @importFrom shinycssloaders withSpinner
#' @import annoFuseData
#'
#' @name annoFuse-pkg
#' @docType package
Expand All @@ -40,7 +42,7 @@ globalVariables(c(
"gene_biotype", "Type.ct", "NAME", "Sample", "Domain",
"Gene1A_DOMAIN_RETAINED_IN_FUSION", "Gene1B_DOMAIN_RETAINED_IN_FUSION",
"Gene1A_anno", "Gene1B_anno", "Annot", "Annot.ct", "Annotation",
"JunctionReadCount", "PROT_FUSION_TYPE" ,"SpanningFragCount",
"JunctionReadCount", "PROT_FUSION_TYPE", "SpanningFragCount",
"pfam_id", "LeftBreakpoint", "LeftBreakpointChr", "RightBreakpoint",
"RightBreakpointChr"
))
37 changes: 19 additions & 18 deletions R/annoFuse-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@

.check_annoFuse_calls <- function(standardFusioncalls) {
stopifnot(is(standardFusioncalls, "data.frame"))

# with a minimal set of columns to be there...
cols_fusioncalls <- c("Sample", "LeftBreakpoint", "RightBreakpoint", "FusionName",
"Gene1A", "Gene1B")

cols_fusioncalls <- c(
"Sample", "LeftBreakpoint", "RightBreakpoint", "FusionName",
"Gene1A", "Gene1B"
)

stopifnot(all(cols_fusioncalls %in% colnames(standardFusioncalls)))

invisible(standardFusioncalls)
}


#' Read in fusion calls from Arriba v1.1.0
#' Read in fusion calls from Arriba v1.1.0
#'
#' @param arriba_calls Please refer to software documenation [fusions.tsv](https://arriba.readthedocs.io/en/latest/output-files/)
#'
Expand All @@ -23,12 +25,11 @@
#'
#' @examples
#' fusionfileArriba <- read_arriba_calls(
#' system.file("extdata", "arriba_example.tsv", package = "annoFuse"))
#'

read_arriba_calls <- function(arriba_calls){
#' system.file("extdata", "arriba_example.tsv", package = "annoFuseData")
#' )
read_arriba_calls <- function(arriba_calls) {
# set col types
col_types = readr::cols(
col_types <- readr::cols(
`#gene1` = readr::col_character(),
gene2 = readr::col_character(),
`strand1(gene/fusion)` = readr::col_character(),
Expand All @@ -54,8 +55,8 @@ read_arriba_calls <- function(arriba_calls){
peptide_sequence = readr::col_character(),
read_identifiers = readr::col_character()
)
arriba_calls<-read_tsv(arriba_calls, col_types = col_types)

arriba_calls <- read_tsv(arriba_calls, col_types = col_types)
return(arriba_calls)
}

Expand All @@ -68,11 +69,11 @@ read_arriba_calls <- function(arriba_calls){
#'
#' @examples
#' fusionfileStarFusion <- read_starfusion_calls(
#' system.file("extdata", "starfusion_example.tsv", package = "annoFuse"))
#'
#' system.file("extdata", "starfusion_example.tsv", package = "annoFuseData")
#' )
read_starfusion_calls <- function(starfusion_calls) {
# set col types
col_types = readr::cols(
col_types <- readr::cols(
`#FusionName` = readr::col_character(),
JunctionReadCount = readr::col_integer(),
SpanningFragCount = readr::col_integer(),
Expand All @@ -99,8 +100,8 @@ read_starfusion_calls <- function(starfusion_calls) {
PFAM_LEFT = readr::col_character(),
PFAM_RIGHT = readr::col_character()
)
starfusion_calls<- read_tsv(starfusion_calls,col_types = col_types)

starfusion_calls <- read_tsv(starfusion_calls, col_types = col_types)
return(starfusion_calls)
}

Expand Down
Loading

0 comments on commit ae9ca90

Please sign in to comment.