Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in gheatmap (not exact match to tip names) #182

Closed
7 of 8 tasks
vmikk opened this issue May 22, 2018 · 2 comments
Closed
7 of 8 tasks

Bug in gheatmap (not exact match to tip names) #182

vmikk opened this issue May 22, 2018 · 2 comments

Comments

@vmikk
Copy link
Contributor

vmikk commented May 22, 2018

Prerequisites

  • Have you read Feedback and follow the guide?
    • make sure your are using the latest release version
    • read the documents
    • google your quesion/issue

Describe you issue

  • Make a reproducible example (e.g. 1)
  • your code should contain comments to describe the problem (e.g. what expected and actually happened?)

Ask in right place

  • for bugs or feature requests, post here (github issue)
  • for questions, please post to google group

Hello!
First of all, I would like to thank you for this wonderful and very powerful package!

I have tried to plot a phylogenetic tree with heatmap of associated matrix (with gheatmap).
I found that the row names of matrix doesn't exactly match to the tip names of tree in case if there is missing data in associated matrix.
In other words, if we have two species (e.g., Species198 and Species1981), but only one of them is represented in the associated matrix, we will have colored cells for both species in the heatmap.

Here is a reproducible example:

library(ggtree)

set.seed(111)

# Prepare a species list
tipss <- c("Fomes", "Rozella", "Saitoella", "Entorrhiza", "Cryptococcus", "Tremella", "Puccinia", "Amoeboaphelidium")
tipss <- c(tipss, "Species198", "Species1981")

# Generate random tree
trr <- ape::rtree(n = length(tipss), rooted = TRUE, tip.label = tipss)

# Generate associated data matrix for each species
abunds <- matrix(data = sample(1:100, size = 4*length(tipss)), nrow = length(tipss))
rownames(abunds) <- tipss
colnames(abunds) <- paste("Samp", 1:ncol(abunds), sep="")

# Remove data for some species
abunds <- abunds[-which(rownames(abunds) == "Species198"), ]     # !! no information for this species
abunds <- abunds[-which(rownames(abunds) == "Cryptococcus"), ]

tt <- ggtree(trr) + geom_tiplab()
gheatmap(tt, abunds)

Here is the resulting picture:
example

You may see that heatmap cells are blank for Cryptococcus (as expected).
However, cells corresponding to Species198 are colored with Species1981 data (marked with red arrow).

With best regards,
Vladimir

@GuangchuangYu
Copy link
Member

good catch and this is an unexpected surprise from R.

> dd
                 Samp1 Samp2 Samp3 Samp4
Fomes               47    58     3    13
Rozella            100    83    27    18
Saitoella           36    51    78    63
Entorrhiza          70    32    43    16
Tremella            75    73    35    20
Puccinia            61    53     8    72
Amoeboaphelidium    95    66    92    19
Species1981         30    48    34    41
> dd['Species198',]
            Samp1 Samp2 Samp3 Samp4
Species1981    30    48    34    41

bug fixed.

@vmikk
Copy link
Contributor Author

vmikk commented May 23, 2018

Great, It's working now!
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants