Skip to content

Commit

Permalink
typos
Browse files Browse the repository at this point in the history
  • Loading branch information
phoeguo committed Aug 22, 2018
1 parent f1069bf commit cdc3bb6
Show file tree
Hide file tree
Showing 26 changed files with 213 additions and 152 deletions.
16 changes: 9 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
Package: g3viz
Type: Package
Title: visulize MAF genomic annotation data
Title: Visualize Genomic Mutation Data Using an Interactive Lollipop Diagram
Version: 0.1.0
Author: person("Xin", "Guo", email = "[email protected]", role=c("aut", "cre"))
Description: a warpper of g3viz javascript library to generate interactive "lollipop-style" diagram to visualize mutation data
Maintainer: Xin Guo <[email protected]>
Description: R interface for g3viz Javascript library. Using an interactive `lollipop-diagram` to visualize genomic mutation data.
License: MIT
Encoding: UTF-8
LazyData: true
Depends:
R (>= 3.0.2)
Imports:
jsonlite,
cgdsr
cgdsr,
stringr,
htmlwidgets
Suggests:
shiny (>= 1.0.0),
httpuv (>= 1.4.0)
URL: https://github.com/G3js/g3viz
BugReports: https://github.com/G3js/g3viz/issues
shiny (>= 1.0.0)
URL: https://github.com/G3js/lollipopR
BugReports: https://github.com/G3js/lollipopR/issues
RoxygenNote: 6.1.0
14 changes: 11 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ export(parseProteinChange)
export(readMAF)
export(renderG3Lollipop)
export(uniprot2pfam)
import(cgdsr)
import(htmlwidgets)
import(jsonlite)
importFrom(cgdsr,CGDS)
importFrom(cgdsr,getCaseLists)
importFrom(cgdsr,getGeneticProfiles)
importFrom(cgdsr,getMutationData)
importFrom(htmlwidgets,shinyRenderWidget)
importFrom(htmlwidgets,shinyWidgetOutput)
importFrom(jsonlite,toJSON)
importFrom(stringr,str_extract_all)
importFrom(utils,capture.output)
importFrom(utils,read.table)
importFrom(utils,write.table)
2 changes: 1 addition & 1 deletion R/formatCamelCase.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' format a give string to camel case (e.g., \emph{Abc_Efg})
#' format a give string to camel case (e.g., from \emph{abc_efg} to \emph{Abc_Efg})
#' @param x input string
#' @param sep separator. Default \emph{_}.
#'
Expand Down
20 changes: 11 additions & 9 deletions R/g3Lollipop.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
#' otherwise, use specified. Default \code{NA}.
#' @param plot.options options of lollipop plot in list format
#'
#' @import htmlwidgets
#' @import jsonlite
#' @importFrom jsonlite toJSON
#'
#' @export
g3Lollipop <- function(mutation.dat,
Expand Down Expand Up @@ -59,7 +58,7 @@ g3Lollipop <- function(mutation.dat,
# 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 <- jsonlite::toJSON(snv.data.df, pretty = FALSE, auto_unbox = TRUE)
snv.data.json <- toJSON(snv.data.df, pretty = FALSE, auto_unbox = TRUE)

# get protein domain information
domain.data.json <- hgnc2pfam(gene.symbol, uniprot.id)
Expand All @@ -71,10 +70,10 @@ g3Lollipop <- function(mutation.dat,
factor = factor.col
)

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

# domain data format
domain.data.format = list(
domain.data.format <- list(
length = "length",
domainType = "pfam",
details = list(
Expand All @@ -83,9 +82,9 @@ g3Lollipop <- function(mutation.dat,
name = "hmm.name"
)
)
domain.data.format.json = jsonlite::toJSON(domain.data.format, pretty = FALSE, auto_unbox = TRUE)
domain.data.format.json <- toJSON(domain.data.format, pretty = FALSE, auto_unbox = TRUE)

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

x <- list(
domainData = domain.data.json,
Expand Down Expand Up @@ -120,14 +119,17 @@ g3Lollipop <- function(mutation.dat,
#'
#' @name g3Lollipop-shiny
#'
#' @importFrom htmlwidgets shinyWidgetOutput
#'
#' @export
g3LollipopOutput <- function(outputId, width = '100%', height = '400px'){
htmlwidgets::shinyWidgetOutput(outputId, 'g3Lollipop', width, height, package = 'g3viz')
shinyWidgetOutput(outputId, 'g3Lollipop', width, height, package = 'g3viz')
}

#' @rdname g3Lollipop-shiny
#' @importFrom htmlwidgets shinyRenderWidget
#' @export
renderG3Lollipop <- function(expr, env = parent.frame(), quoted = FALSE) {
if (!quoted) { expr <- substitute(expr) } # force quoted
htmlwidgets::shinyRenderWidget(expr, g3LollipopOutput, env, quoted = TRUE)
shinyRenderWidget(expr, g3LollipopOutput, env, quoted = TRUE)
}
106 changes: 53 additions & 53 deletions R/g3Lollipop.options.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @param chart.width chart width. Default 800.
#' @param chart.type \emph{pie} or \emph{circle}. Default \emph{pie}.
#' @param chart.margin chart margin in \emph{list}. Default \code{list(left = 40, right = 20, top = 15, bottom = 25)}.
#' @param chart.margin specify chart margin in _list_ format. Default \code{list(left = 40, right = 20, top = 15, bottom = 25)}.
#' @param chart.background chart background. Default \emph{transparent}.
#' @param transition.time chart animation transition time in millisecond. Default 600.
#'
Expand Down Expand Up @@ -56,58 +56,58 @@
#'
#' @return a list with g3Lollipop plot options
#' @export
g3Lollipop.options <- function( chart.width = 800,
chart.type = "pie",
chart.margin = list(left = 40, right = 20, top = 15, bottom = 25),
chart.background = "transparent",
transition.time = 600,
# axis
y.axis.label = "mutations",
axis.label.font = "normal 12px Arial",
axis.label.color = "#4f4f4f",
axis.label.alignment = "middle",
axis.label.dy = "-2em",
# legend
legend.margin = list(left = 10, right = 0, top = 5, bottom = 5),
legend.interactive = TRUE,
legend.title = NA,
# lollipop track
lollipop.track.height = 420,
lollipop.track.background = "rgb(244,244,244)",
# pop size
lollipop.pop.min.size = 2,
lollipop.pop.max.size = 12,
lollipop.pop.info.limit = 8,
lollipop.pop.info.color = "#EEE",
lollipop.line.color = "rgb(42,42,42)",
lollipop.line.width = 0.5,
lollipop.circle.color = "wheat",
lollipop.circle.width = 0.5,
lollipop.label.ratio = 1.4,
lollipop.label.min.font.size = 10,
lollipop.color.scheme = "accent",
# title text
title.text = "",
title.font = "normal 16px Arial",
title.color = "#424242",
title.alignment = "middle",
title.dy = "0.35em",
# annotation track
anno.height = 30,
anno.margin = list(top = 4, bottom = 0),
anno.background = "transparent",
anno.bar.fill = "#e5e3e1",
anno.bar.margin = list(top = 2, bottom = 2),
# domain
domain.color.scheme = "category10",
domain.margin = list(top = 0, bottom = 0),
domain.text.font = "normal 11px Arial",
domain.text.color = "#f2f2f2",
# others
legend = TRUE,
tooltip = TRUE,
brush = TRUE,
zoom = TRUE
g3Lollipop.options <- function(chart.width = 800,
chart.type = "pie",
chart.margin = list(left = 40, right = 20, top = 15, bottom = 25),
chart.background = "transparent",
transition.time = 600,
# axis
y.axis.label = "mutations",
axis.label.font = "normal 12px Arial",
axis.label.color = "#4f4f4f",
axis.label.alignment = "middle",
axis.label.dy = "-2em",
# legend
legend.margin = list(left = 10, right = 0, top = 5, bottom = 5),
legend.interactive = TRUE,
legend.title = NA,
# lollipop track
lollipop.track.height = 420,
lollipop.track.background = "rgb(244,244,244)",
# pop size
lollipop.pop.min.size = 2,
lollipop.pop.max.size = 12,
lollipop.pop.info.limit = 8,
lollipop.pop.info.color = "#EEE",
lollipop.line.color = "rgb(42,42,42)",
lollipop.line.width = 0.5,
lollipop.circle.color = "wheat",
lollipop.circle.width = 0.5,
lollipop.label.ratio = 1.4,
lollipop.label.min.font.size = 10,
lollipop.color.scheme = "accent",
# title text
title.text = "",
title.font = "normal 16px Arial",
title.color = "#424242",
title.alignment = "middle",
title.dy = "0.35em",
# annotation track
anno.height = 30,
anno.margin = list(top = 4, bottom = 0),
anno.background = "transparent",
anno.bar.fill = "#e5e3e1",
anno.bar.margin = list(top = 2, bottom = 2),
# domain
domain.color.scheme = "category10",
domain.margin = list(top = 0, bottom = 0),
domain.text.font = "normal 11px Arial",
domain.text.color = "#f2f2f2",
# others
legend = TRUE,
tooltip = TRUE,
brush = TRUE,
zoom = TRUE
){
# plot settings
plot.options <- list(chartWidth = chart.width,
Expand Down
10 changes: 5 additions & 5 deletions R/getDefaultMutationMappingTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#'
#' @description Return the default mapping table between mutation type to mutation class
#' @details
#' Mutation type or variant classificaiton, generally with column named \emph{Variant_Classficiation} or
#' \emph{Mutation_Type} in MAF file, can be classificed as follows
#' Mutation type or variant classification, generally with column named \emph{Variant_Classficiation} or
#' \emph{Mutation_Type} in MAF file, can be classified as follows
#' \enumerate{
#' \item Missense
#' \itemize{
Expand All @@ -27,7 +27,7 @@
#' See \url{https://en.wikipedia.org/wiki/Nonsense_mutation}.
#' \item \emph{Nonstop_Mutation} --- variant removes stop codon.
#' \item \emph{Splice_Site} --- the variant is within two bases of a splice site.
#' \item \emph{Splice_Region} --- the variant is within splice reguion.
#' \item \emph{Splice_Region} --- the variant is within splice region.
#' }
#' \item Other
#' \itemize{
Expand All @@ -38,14 +38,14 @@
#' \item \emph{Fusion} --- gene fusion
#' \item \emph{IGR} --- intergenic region. Does not overlap any transcript.
#' \item \emph{Intron} --- variant lies between exons within the bounds of the chosen transcript.
#' \item \emph{Translation_Start_Site} --- varaint in translation start site.
#' \item \emph{Translation_Start_Site} --- variant in translation start site.
#' \item \emph{De_novo_Start_InFrame} --- New start codon is created by the given variant using the chosen transcript.
#' However, it is in frame relative to the coded protein.
#' \item \emph{De_novo_Start_OutOfFrame} --- New start codon is created by the given variant using the chosen transcript.
#' However, it is out of frame relative to the coded protein.
#' \item \emph{Start_Codon_SNP} --- point mutation that overlaps the start codon.
#' \item \emph{Start_Codon_Ins} --- insertion that overlaps the start codon.
#' \item \emph{Start_Codon_Del} --- seletion that overlaps the start codon.
#' \item \emph{Start_Codon_Del} --- selection that overlaps the start codon.
#' \item \emph{RNA} --- variant lies on one of the RNA transcripts.
#' \item \emph{lincRNA} --- variant lies on one of the lincRNAs.
#' \item \emph{Unknown} --- Unknown
Expand Down
19 changes: 10 additions & 9 deletions R/getMutationsFromCbioportal.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' \code{\link{getDefaultMutationMappingTable}} for details.
#' Default \code{NA}, indicating to use \code{\link{getDefaultMutationMappingTable}}.
#' @examples
#' # list all cbioportal studies
#' # list all studies of cBioPortal
#' library(cgdsr)
#' cgds <- CGDS("http://www.cbioportal.org/public-portal/")
#' all.studies <- getCancerStudies(cgds)
Expand All @@ -18,7 +18,8 @@
#' # pick a primary HGNC gene symbol to query
#' mutation.dat <- getMutationsFromCbioportal("msk_impact_2017", "TP53")
#' mutation.dat <- getMutationsFromCbioportal("all_stjude_2016", "TP53")
#' @import cgdsr
#' @importFrom cgdsr CGDS getGeneticProfiles getCaseLists getMutationData
#' @importFrom utils write.table
#'
#' @return a data frame with columns
#' \itemize{
Expand All @@ -31,8 +32,8 @@
#' \item \emph{End_Position} --- end position
#' \item \emph{Reference_Allele} --- reference allele
#' \item \emph{Variant_Allele} --- variant allele
#' \item \emph{Mutation_Class} --- mutation class (e.g., Truncating/Misense/Inframe/Other)
#' \item \emph{AA_Position} --- amino-acid postion of the variant; if the variant is not in protein-conding region, \code{NA}
#' \item \emph{Mutation_Class} --- mutation class (e.g., Truncating/Missense/Inframe/Other)
#' \item \emph{AA_Position} --- amino-acid position of the variant; if the variant is not in protein-coding region, \code{NA}
#' }
#' @export
getMutationsFromCbioportal <- function(study.id,
Expand All @@ -46,11 +47,11 @@ getMutationsFromCbioportal <- function(study.id,

# ========================
# cgds server
cgds <- cgdsr::CGDS("http://www.cbioportal.org/public-portal/")
cgds <- CGDS("http://www.cbioportal.org/public-portal/")

# ========================
# get study information
genetic.profiles <- cgdsr::getGeneticProfiles(cgds, study.id)
genetic.profiles <- getGeneticProfiles(cgds, study.id)
message("Found study ", study.id)

# ========================
Expand All @@ -65,12 +66,12 @@ getMutationsFromCbioportal <- function(study.id,

# ========================
# get case list
case.list.details <- cgdsr::getCaseLists(cgds, study.id)[mutation.idx, ]
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]])
message(num.case, " cases in this study")

extended.mutation.df <- cgdsr::getMutationData(cgds, mutation.case.list.id, mutation.profile, gene.symbol)
extended.mutation.df <- getMutationData(cgds, mutation.case.list.id, mutation.profile, gene.symbol)
# =========================
# parse mutation data columns
required.colnames <- c("gene_symbol", "amino_acid_change", "case_id", "mutation_type",
Expand Down Expand Up @@ -107,7 +108,7 @@ getMutationsFromCbioportal <- function(study.id,

if(!is.na(output.file)){
message("Write mutation data to ", output.file)
write.table(mutation.df, file = output.file, sep = "\t", quote = FALSE, col.name = TRUE, row.name = FALSE)
write.table(mutation.df, file = output.file, sep = "\t", quote = FALSE, col.names = TRUE, row.names = FALSE)
}

mutation.df
Expand Down
Loading

0 comments on commit cdc3bb6

Please sign in to comment.