Skip to content

Commit

Permalink
version 1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
phoeguo committed Aug 24, 2020
1 parent 5c0b1fa commit 52cef28
Show file tree
Hide file tree
Showing 28 changed files with 3,877 additions and 67 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: g3viz
Type: Package
Title: Interactively Visualize Genetic Mutation Data using a Lollipop-Diagram
Version: 1.1.2
Version: 1.1.3
Authors@R: c(
person("Xin", "Guo", email = "[email protected]", role = c("aut", "cre"))
)
Expand All @@ -25,5 +25,5 @@ Suggests:
kableExtra
URL: https://github.com/G3viz/g3viz
BugReports: https://github.com/G3viz/g3viz/issues
RoxygenNote: 6.1.1
RoxygenNote: 7.1.1
VignetteBuilder: knitr
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export(hgnc2pfam)
export(hgnc2uniprot)
export(mapMutationTypeToMutationClass)
export(parseProteinChange)
export(proteinDomain)
export(readMAF)
export(renderG3Lollipop)
export(uniprot2pfam)
Expand Down
40 changes: 25 additions & 15 deletions R/g3Lollipop.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ g3Lollipop <- function(mutation.dat,
# legend factor
factor.col = "Mutation_Class",
plot.options = g3Lollipop.options(),
# ---------------------
domain.info = NULL,
# ---------------------
save.png.btn = TRUE,
save.svg.btn = TRUE,
btn.style = NA,
Expand Down Expand Up @@ -96,23 +99,15 @@ g3Lollipop <- function(mutation.dat,
stop("Some columns are missing in mutation data: ", paste(missing.columns, collapse = ", "))
}

# get mutation data for the given gene
snv.data.df <- mutation.dat[mutation.dat[, gene.symbol.col] == gene.symbol
& !is.na(mutation.dat[, aa.pos.col]), ]
snv.data.json <- toJSON(snv.data.df, pretty = FALSE, auto_unbox = TRUE)

# =======================================
# version 1.2.0
# (1) custom domain information
# Require: domain
# (2) custom domain information format
# Require
# get protein domain information
domain.data.json <- hgnc2pfam(hgnc.symbol = gene.symbol,
uniprot.id = uniprot.id)

# read in data
snv.data.format <- list(
x = aa.pos.col,
y = protein.change.col,
factor = factor.col
)

snv.data.format.json <- toJSON(snv.data.format, pretty = FALSE, auto_unbox = TRUE)
uniprot.id = uniprot.id)

# domain data format
domain.data.format <- list(
Expand All @@ -125,6 +120,21 @@ g3Lollipop <- function(mutation.dat,
)
)
domain.data.format.json <- toJSON(domain.data.format, pretty = FALSE, auto_unbox = TRUE)
# =======================================

# get mutation data for the given gene
snv.data.df <- mutation.dat[mutation.dat[, gene.symbol.col] == gene.symbol
& !is.na(mutation.dat[, aa.pos.col]), ]
snv.data.json <- toJSON(snv.data.df, pretty = FALSE, auto_unbox = TRUE)

# read in data
snv.data.format <- list(
x = aa.pos.col,
y = protein.change.col,
factor = factor.col
)

snv.data.format.json <- toJSON(snv.data.format, pretty = FALSE, auto_unbox = TRUE)

plot.options.json <- toJSON(plot.options, pretty = FALSE, auto_unbox = TRUE)

Expand Down
84 changes: 84 additions & 0 deletions R/proteinDomain.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#' Map from Hugo symbol to Pfam domains
#'
#' @description Mapping from Hugo symbol to Pfam-A domain composition.
#' If the given Hugo symbol has multiple UniProt ID mappings,
#' and \code{guess == TRUE},
#' the longest UniProt protein is selected. Return is either a list of a JSON.
#' @examples
#' # general usage
#' hgnc2pfam("TP53")
#' hgnc2pfam("TP53", output.format = "json")
#' hgnc2pfam("TP53", output.format = "list")
#' hgnc2pfam("TP53", output.format = "json", uniprot.id = "P04637") # OK
#'
#' # for gene mapping to multiple UniProt enties
#' hgnc2pfam("GNAS", guess = TRUE)
#' hgnc2pfam("GNAS", guess = FALSE)
#' hgnc2pfam("GNAS", output.format = "list")
#' hgnc2pfam("GNAS", output.format = "list", uniprot.id = "P84996")
#' \dontrun{
#' hgnc2pfam("GNAS", output.format = "list", uniprot.id = "P84997") # not exists, returns FALSE
#' }
#'
#' hgnc2pfam("PRAMEF9", output.format = "list") # no Pfam mappings
#'
#' @param hgnc.symbol primary Hugo symbol
#' @param output.format output format: JSON or list
#' @param uniprot.id UniProt ID, in case that gene symbol maps to multiple UniProt entries.
#' @param guess if the given Hugo symbol links to multiple UniProt IDs,
#' choose the longest one (\code{guess == TRUE});
#' otherwise \code{NA} (\code{guess == FALSE}). Default \code{TRUE}.
#' @return A list or a JSON with attributes:
#' \emph{symbol}, \emph{uniprot}, \emph{length}, and a list of \emph{Pfam} entries, including
#' \emph{hmm.acc}, \emph{hmm.name}, \emph{start}, \emph{end}, and \emph{type}.
#'
#' @importFrom utils capture.output
#' @importFrom jsonlite toJSON
#' @export
proteinDomain <- function(protein.length,
domain.df,
domain.name.col = "Name",
domain.start.col = "Start",
domain.end.col = "End"){

if(is.na(protein.length)){
stop("Please provide the length of protein")
}

if(!domain.name.col %in% colnames(domain.df)){
stop("domain.name.col ", domain.name.col, " not exists")
}
if(!domain.start.col %in% colnames(domain.df)){
stop("domain.start.col ", domain.start.col, " not exists")
}
if(!domain.end.col %in% colnames(domain.df)){
stop("domain.end.col ", domain.end.col, " not exists")
}

#--
protein.length <- 393
domain.fn = "data-raw/TP53_P04637_interpro.csv"
domain.df = read.csv(domain.fn)
domain.name.col = "Name"
domain.start.col = "Start"
domain.end.col = "End"
#--



domain.list <- list(
length = protein.length,
details = domain.list
)

# domain data format
domain.default.format <- list(
length = "length",
details = list(
start = "start",
end = "end",
name = "name"
)
)

}
2 changes: 1 addition & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.onAttach <- function(libname, pkgname){
packageStartupMessage("g3viz: visualizing gene/genome/gentics data for fun.\nAny questions, please send emails to <[email protected]>")
packageStartupMessage("g3viz: visualizing gene/genome/gentics data for fun.\nAny questions, please send emails to <[email protected]> or post on GitHub <https://github.com/G3viz/g3viz/issues>.")
}
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

[![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)
[![CRAN_monthly_download](https://cranlogs.r-pkg.org/badges/g3viz)](https://cran.r-project.org/package=g3viz)

## Check [introduction (live demo)](https://g3viz.github.io/g3viz/)
## Check [g3viz chart themes (live demo)](https://g3viz.github.io/g3viz/chart_themes.html)
## Live demo
1. [Short introduction](https://g3viz.github.io/g3viz/)
1. [Chart themes](https://g3viz.github.io/g3viz/chart_themes.html)
1. [An example of showing multiple genes in a shiny app](https://g3viz.github.io/g3viz/shiny_app.html)

## Introduction

Expand Down Expand Up @@ -41,3 +42,9 @@ if("devtools" %in% rownames(installed.packages()) == FALSE){
devtools::install_github("g3viz/g3viz")
```


## What's new

1.1.3 Update Pfam version 33.1 (dated: 2020-08-24)
Update UniProt to 2020-08-24
For [Issues #5](https://github.com/G3viz/g3viz/issues/5)
Binary file modified data/hgnc2pfam.df.rda
Binary file not shown.
23 changes: 23 additions & 0 deletions examples/custom_domain_information.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
library(g3viz)

#maf.file <- system.file("extdata", "TCGA.BRCA.varscan.somatic.maf.gz", package = "g3viz")
#mutation.dat <- readMAF(maf.file)


domain.fn <- "data-raw/TP53_P04637_interpro.csv"
domain.df <- read.csv(domain.fn)

Start.col = "Start"
End.col = "End"
Domain.ID = "Name"

all(c(Start.col, End.col, Domain.ID) %in% colnames(domain.df))

hgnc2pfam("TP53", output.format = "list")

library(biomaRt)

# select human ensembl
ensembl = useMart("ensembl",dataset="hsapiens_gene_ensembl")

#
19 changes: 14 additions & 5 deletions man/g3Lollipop.Rd

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

76 changes: 51 additions & 25 deletions man/g3Lollipop.options.Rd

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

8 changes: 6 additions & 2 deletions man/g3Lollipop.theme.Rd

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

9 changes: 7 additions & 2 deletions man/getMutationsFromCbioportal.Rd

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

3 changes: 1 addition & 2 deletions man/hgnc2pfam.Rd

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

Loading

0 comments on commit 52cef28

Please sign in to comment.