Articles by R on Guangchuang Yu

First thoughs on R integration in SQL Server 2016

June 23, 2016 | R on Guangchuang Yu

This blog post is a very personal confession, might be delicate but it must be understood as a  proposal or plan for improvement. Update #1: Typing error in title: correct title is First thoughts on R integration in SQL Server 2016 (update: June 24, 2016) Before the start, let me put some background and ...
[Read more...]

Importing CSV data using T-SQL and R

June 18, 2016 | R on Guangchuang Yu

Several ways exists to import CSV (excel) data into your SQL Server Database. One is of course, using SSIS. The other one – similar to SSIS – is using import/export function in SSMS. With wizard, you will be able to import data. Futher on, BULK INSERT (BCP) statement is to all ...
[Read more...]

NEWS of my BioC packages

May 5, 2016 | R on Guangchuang Yu

Today is my birthday and it happened to be the release day of Bioconductor 3.3. It’s again the time to reflect what I’ve done in the past year. ChIPseeker clusterProfiler DOSE ggtree GOSemSim ReactomePA ChIPseeker Although ChIPseeker was designed for ChIP-seq annotation, I am very glad to find that ... [Read more...]

convert biological ID with KEGG API using clusterProfiler

May 3, 2016 | R on Guangchuang Yu

bitr_kegg clusterProfiler can convert biological IDs using OrgDb object via the bitr function. Now I implemented another function, bitr_kegg for converting IDs through KEGG API.
library(clusterProfiler)
data(gcSample)
hg <- gcSample[[1]]
head(hg)

## [1] "4597"  "7111"  "5266"  "2175"  "755"   "23046"

eg2np <- bitr_kegg(hg, fromType='kegg', toType='ncbi-proteinid', organism='hsa')

## Warning in bitr_kegg(hg, fromType = "kegg", toType = "ncbi-proteinid",
## organism = "hsa"): 3.7% of input gene IDs are fail to map...

head(eg2np)

##     kegg ncbi-proteinid
## 1   8326      NP_003499
## 2  58487   NP_001034707
## 3 139081      NP_619647
## 4  59272      NP_068576
## 5    993      NP_001780
## 6   2676      NP_001487

np2up <- bitr_kegg(eg2np[,2], fromType='ncbi-proteinid', toType='uniprot', organism='hsa')

head(np2up)

##   ncbi-proteinid uniprot
## 1      NP_005457  O75586
## 2      NP_005792  P41567
## 3      NP_005792  Q6IAV3
## 4      NP_037536  Q13421
## 5      NP_006054  O60662
## 6   NP_001092002  O95398
The ID type (both fromType & toType) should be one of ‘kegg’, ‘ncbi-geneid’, ‘ncbi-proteinid’ or ‘uniprot’. The ‘kegg’ is the primary ID used ... [Read more...]

KEGG Module Enrichment Analysis

April 13, 2016 | R on Guangchuang Yu

KEGG MODULE is a collection of manually defined functional units, called KEGG modules and identified by the M numbers, used for annotation and biological interpretation of sequenced genomes. There are four types of KEGG modules: pathway modules – representing tight functional units in KEGG metabolic pathway maps, such as M00002 (Glycolysis, ... [Read more...]

embed images in ggplot2 via subview and annotate a phylogenetic tree with images using inset function

March 19, 2016 | R on Guangchuang Yu

I extended the subview function to support embed image file in a ggplot object.
set.seed(123)
d = data.frame(x=rnorm(10), y=rnorm(10))

imgfile <- tempfile(, fileext=".png")
download.file("https://avatars1.githubusercontent.com/u/626539?v=3&u=e731426406dd3f45a73d96dd604bc45ae2e7c36f&s=140",
              destfile=imgfile, mode='wb')

p = ggplot(d, aes(x, y))
subview(p, imgfile, x=d$x[1], y=d$y[1]) + geom_point(size=5)
In previous post, I have introduced using annotation_image function for annotating tips with local images. Now with the updated subview function, we can use inset function to annotate nodes/tips with image files and/... [Read more...]

Font Awesome supported in emojifont

March 14, 2016 | R on Guangchuang Yu

emojifont is available in CRAN, you can use the following command to install it.
install.packages("emojifont")
An example of using emoji font in R plot is showed below: More example can be found in the post and online vignette. I found FontAwesome is quite interesting especially in technical world. In emojifont (... [Read more...]

tweets of ggtree

February 22, 2016 | R on Guangchuang Yu

Treespace visualization of a heuristic best tree search in #R package #ggtree #phylogenetics pic.twitter.com/hnSJpIABql— Alex Damián (@antropoteuthis) January 29, 2016 @guangchuangyu Updated to latest #ggtree and #ggplot2 and very impressed! Any ideas on using geom_label with tip labels to add box/fill?— Jo Williams-Newkirk (@ajwnewkirk) January 25, 2016 ggtree ... [Read more...]

ggtree supports phylip tree format

January 14, 2016 | R on Guangchuang Yu

Phylip is also a widely used tree format, which contains taxa sequences with Newick tree text. In ggtree, we can use read.phylip() function to parse the file and use ggtree() to visualize the tree.
library(ggtree)
phyfile <- system.file("extdata", "sample.phy", package="ggtree")
phylip <- read.phylip(phyfile)
phylip

## 'phylip' S4 object that stored information of
##   '/Users/guangchuangyu/Library/R/3.2/library/ggtree/extdata/sample.phy'.
## 
## ...@ tree: 
## Phylogenetic tree with 15 tips and 13 internal nodes.
## 
## Tip labels:
##  K, N, D, L, J, G, ...
## 
## Unrooted; no branch lengths.
## 
## with sequence alignment available (15 sequences of length 2148)

ggtree(phylip) + geom_tiplab()
User can view the sequence alignment with the tree via msaplot() function.
msaplot(phylip, offset=1)
[Read more...]

label edge number in ggtree

January 12, 2016 | R on Guangchuang Yu

This is a question from ggtree user. In ape and phytools, it’s easy to label edge using the edgelabels function.
set.seed(1)
tr = rtree(30)
library(ape)
plot(tr, main="ape")
edgelabels()
I don’t see any necessity to label edge numbers, as they are meaningless. The number is labeled as the row index of tr$edge, and edge can ...
[Read more...]

GO analysis using clusterProfiler

January 3, 2016 | R on Guangchuang Yu

clusterProfiler supports over-representation test and gene set enrichment analysis of Gene Ontology. It supports GO annotation from OrgDb object, GMT file and user’s own data. support many species In github version of clusterProfiler, enrichGO and gseGO functions removed the parameter organism and add another parameter OrgDb, so that any ...
[Read more...]

News of ggtree

December 30, 2015 | R on Guangchuang Yu

A new version of ggtree that works with ggplot2 (version __= 2.0.0) is now availabel. new layers Some functions, add_legend, hilight, annotation_clade and annotation_clade2 were removed. Instead we provide layer functions, geom_treescale, geom_hi...
[Read more...]

use emoji font in R

December 15, 2015 | R on Guangchuang Yu

I have played with emoji in R for a while. My solution of using it is different from what implemented in emoGG. emoGG is a good attemp to add emoji in ggplot2. It render emoji picture (png) and creat a layer, geom_emoji, to add emoji. In my opinion, emoji ...
[Read more...]

R kernel in Jupyter notebook 3

November 29, 2015 | R on Guangchuang Yu

I followed the post, Installing an R kernel for IPython/jupyter notebook 3 on OSX, to install jupyter with python3 and R kernels in my iMac. I have elementaryOS on my Macbook Pro and also want to have jupyter on it. The installation process is quite similar. Read More: 824 Words Totally
[Read more...]

phylomoji with ggtree

November 8, 2015 | R on Guangchuang Yu

If you search the hashtag, #phylomoji, in twitter, you can find many creative phylogenetic tree constructed with emoji. #phylomoji with Darwin's water bears! @OxyEvo 🌱 🐟 🐻 🐋 | | |_____| | |_____| |_____| | Read More: 744 Words Totally [Read more...]
1 2 3 4 5 8

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)