Skip to content

Commit

Permalink
rescue parseCSQToGRanges from ensemblVEP
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrue committed Jul 4, 2024
1 parent ddaaabe commit 8c109fa
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 59 deletions.
50 changes: 27 additions & 23 deletions .github/workflows/check-bioc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ jobs:
fail-fast: false
matrix:
config:
- { os: ubuntu-latest, r: '4.1', bioc: '3.14', cont: "bioconductor/bioconductor_docker:devel", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
- { os: macOS-latest, r: '4.1', bioc: '3.14'}
##- { os: windows-latest, r: '4.1', bioc: '3.14'}
- { os: ubuntu-latest, r: 'devel', bioc: '3.20', cont: "bioconductor/bioconductor_docker:devel", rspm: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest" }
- { os: macOS-latest, r: 'devel', bioc: '3.20'}
# - { os: windows-latest, r: 'devel', bioc: '3.20'}
## Check https://github.com/r-lib/actions/tree/master/examples
## for examples using the http-user-agent
env:
Expand All @@ -79,20 +79,20 @@ jobs:
## https://github.com/r-lib/actions/blob/master/examples/check-standard.yaml
## If they update their steps, we will also need to update ours.
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v3

## R is already included in the Bioconductor docker images
- name: Setup R from r-lib
if: runner.os != 'Linux'
uses: r-lib/actions/setup-r@master
uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}

## pandoc is already included in the Bioconductor docker images
- name: Setup pandoc from r-lib
if: runner.os != 'Linux'
uses: r-lib/actions/setup-pandoc@master
uses: r-lib/actions/setup-pandoc@v2

- name: Query dependencies
run: |
Expand All @@ -102,19 +102,19 @@ jobs:

- name: Restore R package cache
if: "!contains(github.event.head_commit.message, '/nocache') && runner.os != 'Linux'"
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-4.1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-4.1-
key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel-

- name: Cache R packages on Linux
if: "!contains(github.event.head_commit.message, '/nocache') && runner.os == 'Linux' "
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: /home/runner/work/_temp/Library
key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-4.1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-4.1-
key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel-

- name: Install Linux system dependencies
if: runner.os == 'Linux'
Expand Down Expand Up @@ -143,6 +143,9 @@ jobs:
## Required for tcltk
brew install xquartz --cask
## Required for terra
brew install gdal
- name: Install Windows system dependencies
if: runner.os == 'Windows'
run: |
Expand Down Expand Up @@ -176,7 +179,7 @@ jobs:
gha_repos <- if(
.Platform$OS.type == "unix" && Sys.info()["sysname"] != "Darwin"
) c(
"AnVIL" = "https://bioconductordocker.blob.core.windows.net/packages/3.14/bioc",
"AnVIL" = "https://bioconductordocker.blob.core.windows.net/packages/3.20/bioc",
BiocManager::repositories()
) else BiocManager::repositories()
Expand Down Expand Up @@ -210,15 +213,15 @@ jobs:
shell: Rscript {0}

- name: Install covr
if: github.ref == 'refs/heads/master' && env.run_covr == 'true' && runner.os == 'Linux'
if: github.ref == 'refs/heads/devel' && env.run_covr == 'true' && runner.os == 'Linux'
run: |
remotes::install_cran("covr")
shell: Rscript {0}

- name: Install pkgdown
if: github.ref == 'refs/heads/master' && env.run_pkgdown == 'true' && runner.os == 'Linux'
if: github.ref == 'refs/heads/devel' && env.run_pkgdown == 'true' && runner.os == 'Linux'
run: |
remotes::install_github("r-lib/pkgdown")
remotes::install_cran("pkgdown")
shell: Rscript {0}

- name: Session info
Expand Down Expand Up @@ -259,27 +262,28 @@ jobs:
run: |
BiocCheck::BiocCheck(
dir('check', 'tar.gz$', full.names = TRUE),
`quit-with-status` = TRUE,
`quit-with-status` = FALSE,
`no-check-R-ver` = TRUE,
`no-check-bioc-help` = TRUE
)
shell: Rscript {0}

- name: Test coverage
if: github.ref == 'refs/heads/master' && env.run_covr == 'true' && runner.os == 'Linux'
if: github.ref == 'refs/heads/devel' && env.run_covr == 'true' && runner.os == 'Linux'
run: |
covr::codecov()
shell: Rscript {0}

- name: Install package
if: github.ref == 'refs/heads/master' && env.run_pkgdown == 'true' && runner.os == 'Linux'
if: github.ref == 'refs/heads/devel' && env.run_pkgdown == 'true' && runner.os == 'Linux'
run: R CMD INSTALL .

- name: Build and deploy pkgdown site
if: github.ref == 'refs/heads/master' && env.run_pkgdown == 'true' && runner.os == 'Linux'
if: github.ref == 'refs/heads/devel' && env.run_pkgdown == 'true' && runner.os == 'Linux'
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "[email protected]"
git config --global --add safe.directory /__w/kevinrue/TVTB
Rscript -e "pkgdown::deploy_to_branch(new_process = FALSE)"
shell: bash {0}
## Note that you need to run pkgdown::deploy_to_branch(new_process = FALSE)
Expand All @@ -291,7 +295,7 @@ jobs:
if: failure()
uses: actions/upload-artifact@master
with:
name: ${{ runner.os }}-biocversion-devel-r-4.1-results
name: ${{ runner.os }}-biocversion-devel-r-devel-results
path: check

- uses: docker/build-push-action@v1
Expand Down
50 changes: 38 additions & 12 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: TVTB
Type: Package
Title: TVTB: The VCF Tool Box
Version: 1.31.0
Date: 2021-08-30
Version: 1.31.1
Date: 2024-07-04
Authors@R: person("Kevin", "Rue-Albrecht", role = c("aut", "cre"),
email = "[email protected]")
Description: The package provides S4 classes and methods to filter,
Expand All @@ -14,20 +14,47 @@ Description: The package provides S4 classes and methods to filter,
Shiny Variant Explorer (tSVE).
License: Artistic-2.0
Depends: R (>= 3.4), methods, utils, stats
Imports: AnnotationFilter, BiocGenerics (>= 0.25.1), BiocParallel, Biostrings,
ensembldb, ensemblVEP, GenomeInfoDb, GenomicRanges, GGally, ggplot2, Gviz,
limma, IRanges (>= 2.21.6), reshape2, Rsamtools, S4Vectors (>= 0.25.14),
SummarizedExperiment, VariantAnnotation (>= 1.19.9)
Imports:
AnnotationFilter,
BiocGenerics (>= 0.25.1),
BiocParallel,
Biostrings,
ensembldb,
GenomeInfoDb,
GenomicRanges,
GGally,
ggplot2,
Gviz,
limma,
IRanges (>= 2.21.6),
reshape2,
Rsamtools,
S4Vectors (>= 0.25.14),
SummarizedExperiment,
VariantAnnotation (>= 1.19.9)
Suggests: EnsDb.Hsapiens.v75 (>= 0.99.7), shiny (>= 0.13.2.9005), DT
(>= 0.1.67), rtracklayer, BiocStyle (>= 2.5.19), knitr (>= 1.12),
rmarkdown, testthat, covr, pander
biocViews: Software, Genetics, GeneticVariability, GenomicVariation,
DataRepresentation, GUI, Genetics, DNASeq, WholeGenome,
Visualization, MultipleComparison, DataImport,
VariantAnnotation, Sequencing, Coverage, Alignment,
biocViews:
Software,
Genetics,
GeneticVariability,
GenomicVariation,
DataRepresentation,
GUI,
Genetics,
DNASeq,
WholeGenome,
Visualization,
MultipleComparison,
DataImport,
VariantAnnotation,
Sequencing,
Coverage,
Alignment,
SequenceMatching
Collate: utils.R tSVE.R AllClasses.R AllGenerics.R Genotypes-class.R
TVTBparam-class.R VcfFilterRules-class.R countGenos-methods.R
TVTBparam-class.R VcfFilterRules-class.R parseCSQToGRanges.R countGenos-methods.R
autodetectGenotypes.R addCountGenos-methods.R addFrequencies-methods.R
addOverallFrequencies-methods.R
addPhenoLevelFrequencies-methods.R dropInfo.R readVcf-methods.R
Expand All @@ -36,4 +63,3 @@ Collate: utils.R tSVE.R AllClasses.R AllGenerics.R Genotypes-class.R
VignetteBuilder: knitr
URL: https://github.com/kevinrue/TVTB
BugReports: https://github.com/kevinrue/TVTB/issues
RoxygenNote: 7.1.1
8 changes: 6 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ importFrom(
"vcfSamples<-", "vcfWhich<-", "vcfFixed<-", "vcfInfo<-", "vcfGeno<-"
)

importFrom("ensemblVEP", "parseCSQToGRanges")

importFrom(
"ggplot2",
"ggplot", "aes_string", "facet_wrap",
Expand All @@ -96,6 +94,12 @@ importFrom(
"reshape2",
"melt", "dcast")

importFrom(
"GenomeInfoDb",
"genome",
"genome<-"
)

#exportPattern("^[[:alpha:]]+")

# runShinyApp.R ----
Expand Down
7 changes: 7 additions & 0 deletions R/AllGenerics.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,10 @@ setGeneric(
function(x, value)
standardGeneric("svp<-")
)

# ensemblVEP ----

setGeneric("parseCSQToGRanges", signature = "x",
function(x, VCFRowID=TRUE, ...)
standardGeneric("parseCSQToGRanges")
)
41 changes: 41 additions & 0 deletions R/parseCSQToGRanges.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
setMethod("parseCSQToGRanges", "VCF",
function(x, VCFRowID=character(), ..., info.key="CSQ")
{
## no 'info.key'
if (!info.key %in% names(info(x)))
return(rowRanges(x))

hdr <- info(header(x))[info.key, "Description"]
nms <- unlist(strsplit(strsplit(hdr, "Format: ")[[1]][2], "\\|"))
ulst <- unlist(info(x)[[info.key]], use.names=FALSE)
## 'info.key' without data
if (all(is.na(ulst))) {
gr <- rowRanges(x)
csq <-
DataFrame(setNames(replicate(length(nms), character(0)), nms))
} else {
## 'info.key' with data
elt <- elementNROWS(info(x)[[info.key]])
raw <- strsplit(ulst, "\\|")
csq <- matrix(nrow=length(ulst), ncol=length(nms))
for (i in 1:nrow(csq))
csq[i, 1:length(raw[[i]])] <- raw[[i]]
csq[!nzchar(csq)] <- NA
colnames(csq) <- nms
csq <- data.frame(csq, stringsAsFactors=FALSE)

rd <- rowRanges(x)
gr <- rd[rep(seq_along(rd), elt)]
if (length(VCFRowID)) {
if (any(no_match <- !VCFRowID %in% rownames(x)))
warning(paste0("rownames not found in 'x' : ",
paste(VCFRowID[no_match], collapse=",")))
VCFRowID <- rep(match(rownames(x), VCFRowID), elt)
csq <- DataFrame(VCFRowID=VCFRowID, csq)
}
}
mcols(gr) <- csq
genome(gr) <- genome(x)
gr
}
)
8 changes: 8 additions & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
\name{TVTB-NEWS}
\title{NEWS: The VCF Tool Box}

\section{Changes in version 1.31.1 2024-07-04}{
\subsection{Bug fix}{
\itemize{
\item Copy \code{parseCSQToGRanges} from \code{ensemblVEP}
}
}
}

\section{Changes in version 1.19.1 2021-08-30}{
\subsection{Bug fix}{
\itemize{
Expand Down
34 changes: 12 additions & 22 deletions man/VcfBasicRules-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ decribed in this help page, except when specified otherwise.
}

\section{Constructors}{
\describe{}{
\code{VcfFixedRules(exprs = list(), ..., active = TRUE)}

\code{VcfInfoRules(exprs = list(), ..., active = TRUE)}
Expand All @@ -123,32 +122,23 @@ which is recycled as necessary.

See the constructor of \code{FilterRules} for more details.
}
}

\section{Subsetting and Replacement}{
In the following code snippets \code{x} and \code{value}
are objects from any of the classes described in this help page.

\describe{
\item{}{
\code{x[i]}: Subsets the filter rules using the same interface as for
\code{\linkS4class{List}}.
}
\item{}{
\code{x[[i]]}: Extracts an expression or function via the same interface
as for \code{\linkS4class{List}}.
}
\item{}{
\code{x[i] <- value}: Replaces a filter rule by one of the
\strong{same} class.
The active state(s) and name(s) are transferred from \code{value} to
\code{x}.
}
\item{}{
\code{x[[i]] <- value}:
The same interface as for \code{\linkS4class{List}}.
The default active state for new rules is TRUE.
}
\itemize{
\item{\code{x[i]}: Subsets the filter rules using the same interface as for
\code{\linkS4class{List}}.}
\item{\code{x[[i]]}: Extracts an expression or function via the same interface
as for \code{\linkS4class{List}}.}
\item{\code{x[i] <- value}: Replaces a filter rule by one of the
\strong{same} class.
The active state(s) and name(s) are transferred from \code{value} to
\code{x}.}
\item{\code{x[[i]] <- value}:
The same interface as for \code{\linkS4class{List}}.
The default active state for new rules is TRUE.}
}
}

Expand Down

0 comments on commit 8c109fa

Please sign in to comment.