diff --git a/DESCRIPTION b/DESCRIPTION index 96d0688..63211c7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -46,5 +46,6 @@ Suggests: knitr, BiocStyle, htmltools, - BSgenome.Hsapiens.UCSC.hg19 + BSgenome.Hsapiens.UCSC.hg19, + graphics VignetteBuilder: knitr diff --git a/README.Rmd b/README.Rmd index d1f393f..b10a4ce 100644 --- a/README.Rmd +++ b/README.Rmd @@ -24,14 +24,14 @@ knitr::opts_chunk$set( * **Load the data**: `ggcoverage` can load BAM, BigWig (.bw), BedGraph files from various NGS data, including WGS, RNA-seq, ChIP-seq, ATAC-seq, et al. * **Create genome coverage plot** * **Add annotations**: `ggcoverage` supports six different annotations: - * **Base and amino acid annotaion**: Visualize genome coverage at single-nucleotide level with bases and amino acids. + * **base and amino acid annotaion**: Visualize genome coverage at single-nucleotide level with bases and amino acids. * **GC annotation**: Visualize genome coverage with GC content * **gene annotation**: Visualize genome coverage across whole gene * **transcription annotation**: Visualize genome coverage across different transcripts * **ideogram annotation**: Visualize the region showing on whole chromosome * **peak annotation**: Visualize genome coverage and peak identified -`ggcoverage` utilizes `ggplot2` plotting system, so its usage is ggplot2-style! +`ggcoverage` utilizes `ggplot2` plotting system, so its usage is **ggplot2-style**! ## Installation @@ -188,6 +188,50 @@ track.df <- LoadTrackFile( head(track.df) ``` +#### Default color scheme +For base and amino acid annotation, we have following default color schemes, you can change with `nuc.color` and `aa.color` parameters. + +Default color scheme for base annotation is `Clustal-style`, more popular color schemes is available [here](https://www.biostars.org/p/171056/). +```{r base_color_scheme, warning=FALSE, fig.height = 2, fig.width = 6, fig.align = "center"} +# color scheme +nuc.color = c("A" = "#ff2b08", "C" = "#009aff", "G" = "#ffb507", "T" = "#00bc0d") +# create plot +graphics::par(mar = c(1, 5, 1, 1)) +graphics::image( + 1:length(nuc.color), 1, as.matrix(1:length(nuc.color)), + col = nuc.color, + xlab = "", ylab = "", xaxt = "n", yaxt = "n", bty = "n" +) +graphics::text(1:length(nuc.color), 1, names(nuc.color)) +graphics::mtext( + text = "Base", adj = 1, las = 1, + side = 2 +) +``` + +Default color scheme for amino acid annotation is from [Residual colours: a proposal for aminochromography](https://academic.oup.com/peds/article/10/7/743/1593029?login=false): +```{r aa_color_scheme, warning=FALSE, fig.height = 9, fig.width = 10, fig.align = "center"} +aa.color = c( + "D" = "#FF0000", "S" = "#FF2400", "T" = "#E34234", "G" = "#FF8000", "P" = "#F28500", + "C" = "#FFFF00", "A" = "#FDFF00", "V" = "#E3FF00", "I" = "#C0FF00", "L" = "#89318C", + "M" = "#00FF00", "F" = "#50C878", "Y" = "#30D5C8", "W" = "#00FFFF", "H" = "#0F2CB3", + "R" = "#0000FF", "K" = "#4b0082", "N" = "#800080", "Q" = "#FF00FF", "E" = "#8F00FF", + "*" = "#FFC0CB", " " = "#FFFFFF", " " = "#FFFFFF", " " = "#FFFFFF", " " = "#FFFFFF" +) + +graphics::par(mar = c(1, 5, 1, 1)) +graphics::image( + 1:5, 1:5, matrix(1:length(aa.color),nrow=5), + col = rev(aa.color), + xlab = "", ylab = "", xaxt = "n", yaxt = "n", bty = "n" +) +graphics::text(expand.grid(1:5,1:5), names(rev(aa.color))) +graphics::mtext( + text = "Amino acids", adj = 1, las = 1, + side = 2 +) +``` + #### Add base and amino acid annotation ```{r base_aa_coverage, warning=FALSE, fig.height = 10, fig.width = 12, fig.align = "center"} ggcoverage(data = track.df, color = "grey", range.position = "out", single.nuc=T, rect.color = "white") + diff --git a/README.md b/README.md index 8e822f3..d04ff37 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ coverage. It contains three main parts: - **Create genome coverage plot** - **Add annotations**: `ggcoverage` supports six different annotations: - - **Base and amino acid annotaion**: Visualize genome coverage at + - **base and amino acid annotaion**: Visualize genome coverage at single-nucleotide level with bases and amino acids. - **GC annotation**: Visualize genome coverage with GC content - **gene annotation**: Visualize genome coverage across whole gene @@ -28,7 +28,7 @@ coverage. It contains three main parts: identified `ggcoverage` utilizes `ggplot2` plotting system, so its usage is -ggplot2-style! +**ggplot2-style**! ## Installation @@ -276,6 +276,62 @@ head(track.df) #> 6 chr4 62474240 62474241 6 tumorA tumorA ``` +#### Default color scheme + +For base and amino acid annotation, we have following default color +schemes, you can change with `nuc.color` and `aa.color` parameters. + +Default color scheme for base annotation is `Clustal-style`, more +popular color schemes is available +[here](https://www.biostars.org/p/171056/). + +``` r +# color scheme +nuc.color = c("A" = "#ff2b08", "C" = "#009aff", "G" = "#ffb507", "T" = "#00bc0d") +# create plot +graphics::par(mar = c(1, 5, 1, 1)) +graphics::image( + 1:length(nuc.color), 1, as.matrix(1:length(nuc.color)), + col = nuc.color, + xlab = "", ylab = "", xaxt = "n", yaxt = "n", bty = "n" +) +graphics::text(1:length(nuc.color), 1, names(nuc.color)) +graphics::mtext( + text = "Base", adj = 1, las = 1, + side = 2 +) +``` + + + +Default color scheme for amino acid annotation is from [Residual +colours: a proposal for +aminochromography](https://academic.oup.com/peds/article/10/7/743/1593029?login=false): + +``` r +aa.color = c( + "D" = "#FF0000", "S" = "#FF2400", "T" = "#E34234", "G" = "#FF8000", "P" = "#F28500", + "C" = "#FFFF00", "A" = "#FDFF00", "V" = "#E3FF00", "I" = "#C0FF00", "L" = "#89318C", + "M" = "#00FF00", "F" = "#50C878", "Y" = "#30D5C8", "W" = "#00FFFF", "H" = "#0F2CB3", + "R" = "#0000FF", "K" = "#4b0082", "N" = "#800080", "Q" = "#FF00FF", "E" = "#8F00FF", + "*" = "#FFC0CB", " " = "#FFFFFF", " " = "#FFFFFF", " " = "#FFFFFF", " " = "#FFFFFF" +) + +graphics::par(mar = c(1, 5, 1, 1)) +graphics::image( + 1:5, 1:5, matrix(1:length(aa.color),nrow=5), + col = rev(aa.color), + xlab = "", ylab = "", xaxt = "n", yaxt = "n", bty = "n" +) +graphics::text(expand.grid(1:5,1:5), names(rev(aa.color))) +graphics::mtext( + text = "Amino acids", adj = 1, las = 1, + side = 2 +) +``` + + + #### Add base and amino acid annotation ``` r diff --git a/man/figures/README-aa_color_scheme-1.png b/man/figures/README-aa_color_scheme-1.png new file mode 100644 index 0000000..f833829 Binary files /dev/null and b/man/figures/README-aa_color_scheme-1.png differ diff --git a/man/figures/README-base_color_scheme-1.png b/man/figures/README-base_color_scheme-1.png new file mode 100644 index 0000000..bf66892 Binary files /dev/null and b/man/figures/README-base_color_scheme-1.png differ diff --git a/vignettes/ggcoverage.Rmd b/vignettes/ggcoverage.Rmd index f3f47b9..9e68e08 100644 --- a/vignettes/ggcoverage.Rmd +++ b/vignettes/ggcoverage.Rmd @@ -55,6 +55,7 @@ Once `ggcoverage` is installed, it can be loaded by the following command. ```{r library, message=FALSE, warning=FALSE} library("rtracklayer") +library("graphics") library("ggcoverage") ``` @@ -73,7 +74,7 @@ library("ggcoverage") * **ideogram annotation**: Visualize the region showing on whole chromosome * **peak annotation**: Visualize genome coverage and peak identified -`ggcoverage` utilizes `ggplot2` plotting system, so its usage is ggplot2-style! +`ggcoverage` utilizes `ggplot2` plotting system, so its usage is **ggplot2-style**! ------------- @@ -219,6 +220,50 @@ track.df <- LoadTrackFile( head(track.df) ``` +### Default color scheme +For base and amino acid annotation, we have following default color schemes, you can change with `nuc.color` and `aa.color` parameters. + +Default color scheme for base annotation is `Clustal-style`, more popular color schemes is available [here](https://www.biostars.org/p/171056/). +```{r base_color_scheme, warning=FALSE, fig.height = 2, fig.width = 6, fig.align = "center"} +# color scheme +nuc.color = c("A" = "#ff2b08", "C" = "#009aff", "G" = "#ffb507", "T" = "#00bc0d") +# create plot +graphics::par(mar = c(1, 5, 1, 1)) +graphics::image( + 1:length(nuc.color), 1, as.matrix(1:length(nuc.color)), + col = nuc.color, + xlab = "", ylab = "", xaxt = "n", yaxt = "n", bty = "n" +) +graphics::text(1:length(nuc.color), 1, names(nuc.color)) +graphics::mtext( + text = "Base", adj = 1, las = 1, + side = 2 +) +``` + +Default color scheme for amino acid annotation is from [Residual colours: a proposal for aminochromography](https://academic.oup.com/peds/article/10/7/743/1593029?login=false): +```{r aa_color_scheme, warning=FALSE, fig.height = 9, fig.width = 10, fig.align = "center"} +aa.color = c( + "D" = "#FF0000", "S" = "#FF2400", "T" = "#E34234", "G" = "#FF8000", "P" = "#F28500", + "C" = "#FFFF00", "A" = "#FDFF00", "V" = "#E3FF00", "I" = "#C0FF00", "L" = "#89318C", + "M" = "#00FF00", "F" = "#50C878", "Y" = "#30D5C8", "W" = "#00FFFF", "H" = "#0F2CB3", + "R" = "#0000FF", "K" = "#4b0082", "N" = "#800080", "Q" = "#FF00FF", "E" = "#8F00FF", + "*" = "#FFC0CB", " " = "#FFFFFF", " " = "#FFFFFF", " " = "#FFFFFF", " " = "#FFFFFF" +) + +graphics::par(mar = c(1, 5, 1, 1)) +graphics::image( + 1:5, 1:5, matrix(1:length(aa.color),nrow=5), + col = rev(aa.color), + xlab = "", ylab = "", xaxt = "n", yaxt = "n", bty = "n" +) +graphics::text(expand.grid(1:5,1:5), names(rev(aa.color))) +graphics::mtext( + text = "Amino acids", adj = 1, las = 1, + side = 2 +) +``` + ### Add base and amino acid annotation ```{r base_aa_coverage, warning=FALSE, fig.height = 10, fig.width = 12, fig.align = "center"} ggcoverage(data = track.df, color = "grey", range.position = "out", single.nuc=T, rect.color = "white") +