Skip to content

Commit

Permalink
update version 1.1.5
Browse files Browse the repository at this point in the history
-Remove and replace Dependency cgdsr

-Updated the data file: hgnc2pfam
  • Loading branch information
zhangrener committed Sep 22, 2022
1 parent 80e5986 commit 599e301
Show file tree
Hide file tree
Showing 23 changed files with 117 additions and 100 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
^\.DS_Store$
^examples$
^R/proteinDomain.R$
^LICENSE\.md$
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sudo: false
cache: packages

install:
- R -e 'install.packages(c("jsonlite", "cgdsr", "stringr", "htmlwidgets", "knitr", "rmarkdown", "kableExtra", "shiny"))'
- R -e 'install.packages(c("jsonlite", "cBioPortalData", "stringr", "htmlwidgets", "knitr", "rmarkdown", "kableExtra", "shiny"))'

script:
- R CMD build .
Expand Down
16 changes: 9 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
Package: g3viz
Type: Package
Title: Interactively Visualize Genetic Mutation Data using a Lollipop-Diagram
Version: 1.1.3
Version: 1.1.5
Authors@R: c(
person("Xin", "Guo", email = "[email protected]", role = c("aut", "cre"))
person("Xin", "Guo", email = "[email protected]", role = c("aut","cre")),
person("Rener", "Zhang", email = "[email protected]", role = c("ctb"))
)
Maintainer: Xin Guo <[email protected]>
Description: R interface for 'g3-lollipop' JavaScript library.
Visualize genetic mutation data using an interactive lollipop diagram in RStudio or your browser.
Description: Interface for 'g3-lollipop' JavaScript library.
Visualize genetic mutation data using an interactive lollipop diagram in Studio or your browser.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Depends:
R (>= 3.0.0)
R (>= 3.5.0)
biocViews:
Imports:
jsonlite,
cgdsr,
stringr,
cBioPortalData,
htmlwidgets
Suggests:
shiny (>= 1.0.0),
Expand All @@ -25,5 +27,5 @@ Suggests:
kableExtra
URL: https://github.com/G3viz/g3viz
BugReports: https://github.com/G3viz/g3viz/issues
RoxygenNote: 7.1.1
RoxygenNote: 7.2.0
VignetteBuilder: knitr
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
YEAR: 2018-2019
YEAR: 2022
COPYRIGHT HOLDER: Xin Guo <[email protected]>
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2022 g3viz authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 5 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ export(parseProteinChange)
export(readMAF)
export(renderG3Lollipop)
export(uniprot2pfam)
importFrom(cgdsr,CGDS)
importFrom(cgdsr,getCaseLists)
importFrom(cgdsr,getGeneticProfiles)
importFrom(cgdsr,getMutationData)
importFrom(cBioPortalData,cBioPortal)
importFrom(cBioPortalData,getDataByGenes)
importFrom(cBioPortalData,molecularProfiles)
importFrom(cBioPortalData,sampleLists)
importFrom(cBioPortalData,samplesInSampleLists)
importFrom(htmlwidgets,shinyRenderWidget)
importFrom(htmlwidgets,shinyWidgetOutput)
importFrom(jsonlite,toJSON)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Version 1.15 (2022/06/30)
- Updated `hgnc2pfam.df.rda` data
- Remove cgdsr dependencies; add cBioPortalData as the substitution
- Updated getMutationsFromCbioportal.R ([issue 16](https://github.com/G3viz/g3viz/issues/16)).

## Version 1.1.3 (2020/08/24)
- Updated Pfam version 33.1 (date: 2020-08-24)
- Updated UniProt (date: 2020-08-24)
Expand Down
4 changes: 4 additions & 0 deletions R/g3Lollipop.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#' two built-in styles, \emph{blue} or \emph{gray}. Default \code{NA},
#' indicating browser default.
#' @param output.filename Specify output file name.
#' @return lollipop diagram for the given mutation data. The chart is interactive
#' within either Shiny applications or Rmd documents under the bindings.
#'
#' @examples
#'
Expand Down Expand Up @@ -170,6 +172,8 @@ g3Lollipop <- function(mutation.dat,
#' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This
#' is useful if you want to save an expression in a variable.
#'
#' @return No value returned. It is the binding which enables interactive functions
#' within Shiny applications and Rmd documents.
#' @name g3Lollipop-shiny
#'
#' @importFrom htmlwidgets shinyWidgetOutput
Expand Down
88 changes: 42 additions & 46 deletions R/getMutationsFromCbioportal.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,31 @@
#' @param mutation.type.to.class.df mapping table from mutation type to class.
#' See \code{\link{mapMutationTypeToMutationClass}} for details. Default
#' \code{NA}, which indicates to use default mappings.
#' @param cgds.url the URL for the public CGDS server (Cancer Genomic Data
#' Server). Default is \url{http://www.cbioportal.org/}. Check
#' \emph{cgdsr} R-package for details.
#' @param test.cgds if test CGDS connection. Default is \code{FALSE}
#' @examples
#' \dontrun{
#' # Usage:
#' # Connection to CGDS (Cange Genomic Data Server). Internet access required.
#' # Note: this may need more than 10 seconds, and sometimes it may fail.
#' library(cgdsr)
#' cgds <- CGDS("http://www.cbioportal.org/")
#'
#' # test if connection is OK (warning: sometimes it may fail)
#' test(cgds)
#' # cBioPortalData has officially replaced the defunct cgdsr.
#' # Search online for cgdsrMigration.html if interested.
#' library(cBioPortalData)
#' cbio <- cBioPortal()
#'
#' # list all studies of cBioPortal
#' all.studies <- getCancerStudies(cgds)
#' all.studies <- getStudies(cbio, buildReport = FALSE)
#'
#' # First, select a cancer study that contains mutation data set ("caner_study_id")
#' # then, query genomic mutation data using a HGNC gene symbol,
#' # for example
#' mutation.dat <- getMutationsFromCbioportal("msk_impact_2017", "TP53")
#' mutation.dat <- getMutationsFromCbioportal("all_stjude_2016", "TP53")
#' }
#' @importFrom cgdsr CGDS getGeneticProfiles getCaseLists getMutationData
#' @importFrom cBioPortalData cBioPortal molecularProfiles sampleLists getDataByGenes
#' samplesInSampleLists
#' @importFrom utils write.table
#'
#' @return a data frame with columns
#' \describe{
#' \item{Hugo_Symbol}{Hugo gene symbol}
#' \item{Protein_Change}{Protein change information (cBioprotal uses \emph{HGVSp} format)}
#' \item{Protein_Change}{Protein change information (cBioportal uses \emph{HGVSp} format)}
#' \item{Sample_ID}{Sample ID}
#' \item{Mutation_Type}{mutation type, aka, variant classification.}
#' \item{Chromosome}{chromosome}
Expand All @@ -55,52 +49,53 @@
getMutationsFromCbioportal <- function(study.id,
gene.symbol,
output.file = NA,
mutation.type.to.class.df = NA,
cgds.url = "http://www.cbioportal.org/",
test.cgds = FALSE){
# =============================
# define mutation columns
aa.pos.col <- "AA_Position"
mutation.class.col <- "Mutation_Class"
mutation.type.to.class.df = NA){

# ========================
# cgds server
cgds <- cgdsr::CGDS(cgds.url)

# ========================
# test cgds
if(test.cgds){
cgdsr::test(cgds)
}
# server
cbio <- cBioPortal()

# ========================
# get study information
genetic.profiles <- getGeneticProfiles(cgds, study.id)
genetic.profiles <- molecularProfiles(cbio,studyId = study.id)
message("Found study ", study.id)

# ========================
# check if mutation informaiton is available in the study
profile.col <- "genetic_profile_id"
mutation.idx <- grep(pattern = 'mutations$', x = genetic.profiles[, profile.col], fixed = FALSE)
# check if mutation information is available in the study
profile.col <- "molecularProfileId"
mutation.idx <- grep(pattern = 'mutations$', x = genetic.profiles$molecularProfileId, fixed = FALSE)
if(is.integer(mutation.idx) && length(mutation.idx) == 0L){
stop("Can not find mutation information in ", study.id, " study")
}
mutation.profile <- genetic.profiles[mutation.idx, profile.col]
mutation.profile <- genetic.profiles$molecularProfileId[mutation.idx]
message("Found mutation data set ", mutation.profile)

# ========================
# get case list
case.list.details <- getCaseLists(cgds, study.id)[mutation.idx, ]
mutation.case.list.id <- case.list.details$case_list_id
num.case <- length(strsplit(case.list.details$case_ids, " ")[[1]])

case.list.details <- sampleLists(cbio, study.id)

mutation.case.list.id <- case.list.details$sampleListId

mutation.case.list.all <- mutation.case.list.id[grep(pattern = '_sequenced$',x = mutation.case.list.id)]
num.case <- length(samplesInSampleLists(cbio,mutation.case.list.id)[[mutation.case.list.all]])
message(num.case, " cases in this study")

extended.mutation.df <- getMutationData(cgds, mutation.case.list.id, mutation.profile, gene.symbol)
### Download mutation data on certain gene from study
df <- getDataByGenes(
cbio,
studyId = study.id,
genes = gene.symbol,
by = "hugoGeneSymbol",
molecularProfileIds = mutation.profile
)[[1]]

extended.mutation.df <- cbind(rep(gene.symbol,nrow(df)),df)
colnames(extended.mutation.df) <- c("gene_symbol",colnames(df))
# =========================
# parse mutation data columns
required.colnames <- c("gene_symbol", "amino_acid_change", "case_id", "mutation_type",
"chr", "start_position", "end_position",
"reference_allele", "variant_allele")
required.colnames <- c("gene_symbol", "proteinChange", "sampleId", "mutationType",
"chr", "startPosition", "endPosition",
"referenceAllele", "variantAllele")

mapped.colnames <- c("Hugo_Symbol", "Protein_Change", "Sample_ID", "Mutation_Type",
"Chromosome", "Start_Position", "End_Position",
Expand All @@ -117,17 +112,18 @@ getMutationsFromCbioportal <- function(study.id,
mutation.df <- extended.mutation.df[, required.colnames]
colnames(mutation.df) <- mapped.colnames


# =============================
# map from mutation type to mutation class
mutation.df[, mutation.class.col] <- mapMutationTypeToMutationClass(mutation.df[, "Mutation_Type"],
mutation.df[, "Mutation_Class"] <- mapMutationTypeToMutationClass(mutation.df[, "Mutation_Type"],
mutation.type.to.class.df)

# =============================
# parse amino acid position
mutation.df[, aa.pos.col] <- parseProteinChange(mutation.df[, "Protein_Change"],
mutation.df[, mutation.class.col])
mutation.df[, "AA_Position"] <- parseProteinChange(mutation.df[, "Protein_Change"],
mutation.df[, "Mutation_Class"])

mutation.df <- mutation.df[order(mutation.df[, aa.pos.col],
mutation.df <- mutation.df[order(mutation.df[, "AA_Position"],
mutation.df[, "Protein_Change"], decreasing = FALSE), ]

if(!is.na(output.file)){
Expand Down
2 changes: 1 addition & 1 deletion R/parseProteinChange.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ parseProteinChange <- function(protein.change.vec, mutation.class.vec) {

if(!(is.na(d.mc) || d.mc == "Other" || d.mc == "")){
# extract the first numeric value
aa.pos.vec[idx] = as.numeric(str_extract_all(d.pc, "[0-9]+")[[1]])[1]
aa.pos.vec[idx] <- as.numeric(str_extract_all(d.pc, "[0-9]+")[[1]])[1]
}
# cat(d.pc, " ==> ", aa.pos.vec[idx], "\n")
}
Expand Down
2 changes: 1 addition & 1 deletion R/uniprot2pfam.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' From UniProt ID to Pfam-A domain composition
#'
#' @description Map from UniProt ID to Pfam-A domain compostion.
#' @description Map from UniProt ID to Pfam-A domain composition.
#' @param uniprot.id UniProt ID
#' @return a data frame with columns
#' \itemize{
Expand Down
2 changes: 1 addition & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
packageStartupMessage(
"g3viz: visualizing gene/genome/gentics data for fun.
- Pfam (v33.1)
- UniProt (date: 2020/08/24)\n
- UniProt (date: 2022/07/01)\n
Any questions, please send emails to <[email protected]> or post on GitHub <https://github.com/G3viz/g3viz/issues>."
)
}
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# <a name="top"></a>G3viz: an R package to interactively visualize genetic mutation data using a lollipop-diagram

**Date: 2022-08-19**
**Date: 2022-06-30**

[![Build Status](https://travis-ci.org/G3viz/g3viz.svg?branch=master)](https://travis-ci.org/G3viz/g3viz)
[![CRAN_version](http://www.r-pkg.org/badges/version/g3viz)](https://cran.r-project.org/package=g3viz)
Expand Down Expand Up @@ -48,12 +48,7 @@ Guo, X., *et al*. (2020). G3viz: an R package to interactively visualize genetic

## What's new

1.1.3
- [x] Updated Pfam version 33.1 (date: 2020-08-24)
- [x] Updated UniProt (date: 2020-08-24)
- [x] add "prepare_data" folder to instruct how to create `hgnc2pfam.df.rda` data

1.1.5
1.1.5
- [x] Updated getMutationsFromCbioportal (date: 2022-06-23)
- [x] Remove Dependency cgdsr; Add Dependency cBioPortalData (date: 2022-06-23)
- [x] Updated `hgnc2pfam.df.rda` (date: 2022-06-24)
Binary file added build/vignette.rds
Binary file not shown.
Binary file modified data/hgnc2pfam.df.rda
Binary file not shown.
4 changes: 4 additions & 0 deletions man/g3Lollipop-shiny.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions man/g3Lollipop.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 7 additions & 18 deletions man/getMutationsFromCbioportal.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 599e301

Please sign in to comment.