gheatmap binary data

414 views
Skip to first unread message

Breanna Sipley

unread,
Jul 11, 2018, 6:11:54 AM7/11/18
to ggtree
Hi there,

I have a circular tree & presence/absence data for each tip.  I would like to map this data onto my tree.  


It seems my code generates the skeleton of the map but does not successfully populate it. 

Here's my code:
tree <- read.tree("tree.tre")
dd
<- read.csv("data.txt",
                sep
= "\t",
                col
.names = c("tipLabel", "dat"),
                header
= FALSE,
                stringsAsFactors
= TRUE)
dd
.sub <- subset(dd, tipLabel %in% tree$tip.label)
dd
.sub$dat <- ifelse(dd.sub$dat=="YES","present","absent")
row
.names(dd.sub) <- NULL

circ
<- ggtree(tree, layout="circular", branch.length = "none")
p
<- gheatmap(circ, dd.sub["dat"], offset=0.1, width=0.02,
              low
="salmon",high="black", color="purple") +
  scale_fill_manual
(values=c("salmon","black")) +
  coord_polar
(theta='y')

png
("error.png")
plot
(p)
dev
.off()


Which returns this:

Some more info:
# I'm pretty sure I've set up my dataframe ok

> head(dd.sub["dat"])
      dat
1 present
2  absent
3 present
4  absent
5  absent
6  absent

# Data consists of "present" or "absent" only

> summary(factor(dd.sub$dat))
 absent present
     
88     185

# There's a 1:1 between my tips & binary data

> summary(dd.sub$tipLabel %in% tree$tip.label)
   
Mode    TRUE
logical    
273


Any advice?

Cheers,
Breanna

Yu, Guangchuang

unread,
Jul 12, 2018, 4:14:19 AM7/12/18
to Breanna Sipley, ggtree
any reproducible example? If you want to keep your data confidential, you can send the file to me instead of posting on the group.


--
G Yu, DK Smith, H Zhu, Y Guan, TTY Lam*. ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data, Methods in Ecology and Evolution, 2017, 8(1):28-36. doi:10.1111/2041-210X.12628
 
Homepage: https://guangchuangyu.github.io/software/ggtree
---
You received this message because you are subscribed to the Google Groups "ggtree" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bioc-ggtree+unsubscribe@googlegroups.com.
To post to this group, send email to bioc-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bioc-ggtree/4da1c3a0-6b8a-46ec-a7e2-89fcdf48300c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
--~--~---------~--~----~------------~-------~--~----~
Guangchuang Yu PhD
Postdoc researcher
State Key Laboratory of Emerging Infectious Diseases
School of Public Health
The University of Hong Kong
Hong Kong SAR, China
-~----------~----~----~----~------~----~------~--~---

Yu, Guangchuang

unread,
Jul 12, 2018, 4:18:29 AM7/12/18
to Breanna Sipley, ggtree

maybe you should try color = NULL to disable drawing cell borders. It seems that the color we can see on the plot are all ‘purple` that you specifying for the cell border.

Reply all
Reply to author
Forward
0 new messages