Skip to content

Commit

Permalink
Add highlightTaxon parameter to plot.gbt()
Browse files Browse the repository at this point in the history
  • Loading branch information
kbseah committed Feb 19, 2016
1 parent 352bb17 commit c6d4f78
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 18 deletions.
Binary file added R_source_package/gbtools_2.5.2.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions gbtools/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: gbtools
Type: Package
Version: 2.5.1
Version: 2.5.2
Title: Interactive visualization of metagenome assemblies in R
Date: 2016-02-15
Date: 2016-02-19
Author: Brandon Seah
Maintainer: Brandon Seah <kbseah@mpi-bremen.de>
Description: gbtools lets you visualize metagenome assemblies by GC-coverage or differential coverage plots, and interactively bin them
Expand Down
35 changes: 29 additions & 6 deletions gbtools/R/plot.gbt.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@
#' @param slice For plotting coverage data, which sample to use? (see
#' Details section below)
#' @param cutoff Minimum length to plot contigs (numeric, default 1000)
#' @param taxon Taxonomic level for coloring the taxonomic markers, e.g.
#' @param taxonLevel Taxonomic level for coloring the taxonomic markers, e.g.
#' "Class" or "Phylum". (default "Class")
#' @param assemblyName Name of the metagenome, for plot title
#' @param marker Color plot by taxon markers? (logical, default TRUE)
#' @param marksource Specify which marker set to plot (default: first supplied)
#' @param markCutoff Length x coverage weight cutoff for colored markers (default: 0.8)
#' @param highlightTaxon Color markers affiliated to specified taxon only (default: "")
#' @param gc Color plot by GC% instead of taxon markers? Only used for
#' differential coverage plots, i.e. when two values are supplied
#' to the slice parameter. (logical, default FALSE)
Expand Down Expand Up @@ -62,7 +63,9 @@
plot.gbt <- function(x, # Object of class gbt
slice=1, # Which coverage values to plot?
cutoff=1000, # Minimum contig length to plot
taxon="Class", # Taxonomic level for coloring markers
taxon="Class", # Taxonomic level for coloring markers (keep for legacy compatibility)
taxonLevel="", # Alias for parameter "taxon"
highlightTaxon="", # Overlay colored markers for this specific taxon only
assemblyName="", # Assembly name, for plot title only
marker=TRUE, # Display marker color overlay
marksource="", # Which marker source to plot; if empty - default first
Expand All @@ -85,6 +88,15 @@ plot.gbt <- function(x, # Object of class gbt
symbolScaleParam=100, # Scaling parameter for the plot symbols
...) {
## Plot method for gbt objects
## Process "taxonLevel" alias for "taxon" parameter
if (taxonLevel != taxon) {
if (taxonLevel == "" && taxon != "") {
taxonLevel <- taxon
} else {
taxon <- taxonLevel
}
}
## Catch missing "slice" parameter
if (is.na(slice[1]) || !is.numeric(slice)) {
cat("gbtools ERROR: Please supply valid value for slice option\n")
}
Expand Down Expand Up @@ -261,6 +273,7 @@ plot.gbt <- function(x, # Object of class gbt
...)
## Add marker taxonomy overlay ########################################
if (marker && !is.na(x$markTab)) {
## If marksource not specified, use first marker set by default
if (marksource == "") {
marksource <- x$markSource[1] # Default: Display markers from first source
} else if (is.character (marksource)
Expand All @@ -279,8 +292,16 @@ plot.gbt <- function(x, # Object of class gbt
} else {
cat ("gbtools ERROR: Please check marksource argument\n")
}
## Overlay markers ###############################################
markTabTemp <- subset(x$markTab,source==marksource)
mark.stats <- generatePlotColors2(X,markTabTemp,taxon,consensus,markCutoff)
if (highlightTaxon != "") { ## Highlight specific taxon ##############
# Subset mark.stats to keep only the specified taxon
mark.stats <- mark.stats[which(mark.stats$taxon==highlightTaxon),]
if (dim(mark.stats)[1] == 0) { # If mark.stats contains no rows, warning
cat ("gbtools WARNING: Taxon specified by highlightTaxon matches none!\n")
}
}
points(x=mark.stats$xVals,
y=mark.stats$yVals,
pch=20,cex=cexScaling(mark.stats$Length,
Expand All @@ -297,12 +318,14 @@ plot.gbt <- function(x, # Object of class gbt
)
names(colorframe) <- c("taxon","colors")
colorframe <- subset(colorframe,colors!="grey50")
newrow <- c("(below cutoff)","grey50")
new.colorframe <-rbind (colorframe,newrow)
if (highlightTaxon == "") { # Don't add "below cutoff" to legend if only highlighting one taxon
newrow <- c("(below cutoff)","grey50")
colorframe <-rbind (colorframe,newrow)
}
legend("topright",
legend=new.colorframe$taxon,
legend=colorframe$taxon,
cex=0.6,
fill=as.character(new.colorframe$colors))
fill=as.character(colorframe$colors))
}
}
}
Expand Down
13 changes: 8 additions & 5 deletions gbtools/man/plot.gbt.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
\title{Plot object of class gbt or gbtbin}
\usage{
\method{plot}{gbt}(x, slice = 1, cutoff = 1000, taxon = "Class",
assemblyName = "", marker = TRUE, marksource = "", markCutoff = 0.8,
gc = FALSE, ssu = FALSE, trna = FALSE, consensus = TRUE,
legend = FALSE, textlabel = FALSE, userAxis = NA, col = "grey",
log = "default", main = "default", xlab = "default", ylab = "default",
taxonLevel = "", highlightTaxon = "", assemblyName = "",
marker = TRUE, marksource = "", markCutoff = 0.8, gc = FALSE,
ssu = FALSE, trna = FALSE, consensus = TRUE, legend = FALSE,
textlabel = FALSE, userAxis = NA, col = "grey", log = "default",
main = "default", xlab = "default", ylab = "default",
symbolScale = "area", symbolScaleParam = 100, ...)
}
\arguments{
Expand All @@ -19,9 +20,11 @@ Details section below)}

\item{cutoff}{Minimum length to plot contigs (numeric, default 1000)}

\item{taxon}{Taxonomic level for coloring the taxonomic markers, e.g.
\item{taxonLevel}{Taxonomic level for coloring the taxonomic markers, e.g.
"Class" or "Phylum". (default "Class")}

\item{highlightTaxon}{Color markers affiliated to specified taxon only (default: "")}

\item{assemblyName}{Name of the metagenome, for plot title}

\item{marker}{Color plot by taxon markers? (logical, default TRUE)}
Expand Down
13 changes: 8 additions & 5 deletions gbtools/man/plot.gbtbin.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
\title{Plot object of class gbtbin}
\usage{
\method{plot}{gbtbin}(x, slice = 1, cutoff = 1000, taxon = "Class",
assemblyName = "", marker = TRUE, marksource = "", markCutoff = 0.8,
gc = FALSE, ssu = FALSE, trna = FALSE, consensus = TRUE,
legend = FALSE, textlabel = FALSE, userAxis = NA, col = "grey",
log = "default", main = "default", xlab = "default", ylab = "default",
taxonLevel = "", highlightTaxon = "", assemblyName = "",
marker = TRUE, marksource = "", markCutoff = 0.8, gc = FALSE,
ssu = FALSE, trna = FALSE, consensus = TRUE, legend = FALSE,
textlabel = FALSE, userAxis = NA, col = "grey", log = "default",
main = "default", xlab = "default", ylab = "default",
symbolScale = "area", symbolScaleParam = 100, ...)
}
\arguments{
Expand All @@ -19,9 +20,11 @@ Details section below)}

\item{cutoff}{Minimum length to plot contigs (numeric, default 1000)}

\item{taxon}{Taxonomic level for coloring the taxonomic markers, e.g.
\item{taxonLevel}{Taxonomic level for coloring the taxonomic markers, e.g.
"Class" or "Phylum". (default "Class")}

\item{highlightTaxon}{Color markers affiliated to specified taxon only (default: "")}

\item{assemblyName}{Name of the metagenome, for plot title}

\item{marker}{Color plot by taxon markers? (logical, default TRUE)}
Expand Down

0 comments on commit c6d4f78

Please sign in to comment.