Giter Site home page Giter Site logo

ggheatmap's People

Contributors

guangchuangyu avatar xiaoluo-boy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ggheatmap's Issues

legend placement

Could you add some code to make it possible to position multiple legends side by side or to position some legends on the bottom of the plot?

Switch column and row metadata

Really nice package.

Is there a way to switch between the annotation_cols and annotation_rows. Example : Show exprttype first followed by genetype?

The same on the column side. Was not sure where this is being controlled.

How to add axis labels?

Related to #15, this is a feature request.

I would like to add axis label, in addition to column labels, as possible with heatmaply:
This is a gllobal X and Y label as in usual plots.

image

I tried

  • labs()
  • ggtitle
  • annotate()
  • geom_text()

e.g:

>   ggheatmap::ggheatmap(data_matrix ) + labs(title = 'title', subtitle = 'subtitle', caption = 'caption')
# plot is generated, and labeled correctly

>   ggheatmap::ggheatmap(data_matrix ) + labs(title = 'title', subtitle = 'subtitle', caption = 'caption', x ="111", y ="1212121")
# no x y labels added 

Otherwise labs() works

 p <- ggplot(mtcars, aes(mpg, wt, colour = cyl)) + geom_point()
 p + labs(x = "New x label")

Also nothing (may have mistakes):

 p + 
  geom_text(label="Custom X Label", x=5, y=0, hjust=1, vjust=1, size=5) +
  geom_text(label="Custom Y Label", x=0, y=35, angle=90, hjust=1, vjust=1, size=5)

Same for other trials

could not place all the legends together on the right side as your example shows

Hi, I am trying to plot a heatmap with row annotations, but the legends are not placed as expected.
Then I turned back to your example code, the legends of row annotations are placed at the right of the row annotations, but not placed together on the right side as your example shows.
I have also checked the original code, the function "insert_right" seems to attach subplots together, but not rearrage the legends.
So, is there any revision to place all the legends as you show?
Thanks!

`library(tidyr)
set.seed(123)
df <- matrix(runif(225,0,10),ncol = 15)
colnames(df) <- paste("sample",1:15,sep = "")
rownames(df) <- sapply(1:15, function(x)paste(sample(LETTERS,3,replace = F),collapse = ""))
df[1:4,1:4]

row_metaData <- data.frame(exprtype=sample(c("Up","Down"),15,replace = T),
genetype=sample(c("Metabolism","Immune","None"),15,replace = T))
rownames(row_metaData) <- rownames(df)
col_metaData <- data.frame(tissue=sample(c("Normal","Tumor"),15,replace = T),
risklevel=sample(c("High","Low"),15,replace = T))
rownames(col_metaData) <- colnames(df)
exprcol <- c("#EE0000FF","#008B45FF" )
names(exprcol) <- c("Up","Down")
genecol <- c("#EE7E30","#5D9AD3","#D0DFE6FF")
names(genecol) <- c("Metabolism","Immune","None")
tissuecol <- c("#98D352","#FF7F0E")
names(tissuecol) <- c("Normal","Tumor")
riskcol <- c("#EEA236FF","#46B8DAFF")
names(riskcol) <- c("High","Low")
col <- list(exprtype=exprcol,genetype=genecol,tissue=tissuecol,risklevel=riskcol)
text_rows <- sample(rownames(df),3)
ppp <- ggheatmap(df,cluster_rows = T,cluster_cols = T,scale = "row",
text_show_rows = text_rows,
cluster_num = c(3,3),
tree_color_rows = c("#008B45FF","#631879FF","#008280FF"),
tree_color_cols = c("#1F77B4FF","#FF7F0EFF","#2CA02CFF"),
annotation_rows = row_metaData,
annotation_cols = col_metaData,
annotation_color = col
)
ppp
`

Change legend labels

Hi,

thanks for this excellent package. I am plotting relative abundance data in a very wide range (1 to 50), therefore I am transforming my input matrix with the log10 function and then feed it to ggheatmap. But I would like anyway to have on the legend the true values instead of their log10 (e.g. 3, 10, 30 instead of 0.5, 1, 1.5). In a "pure" ggplot2 scenario I could do this with scale_color_continuous(breaks = c(0.5, 1, 1.5), labels = c(3, 10, 30)), but if I try to append it to a ggheatmap call, eg ggheatmap(...) + scale_color_continuous(breaks = c(0.5, 1, 1.5), labels = c(3, 10, 30)) I get a NULL object. Any suggestion about this?

Thank you

Domenico

Error when running examples

I've tried both the development version of ggheatmap and the version on CRAN. Both encounter the same error.

library(ggheatmap)
library(tidyr)
set.seed(123)
df <- matrix(runif(225,0,10),ncol = 15)
colnames(df) <- paste("sample",1:15,sep = "")
rownames(df) <- sapply(1:15, function(x)paste(sample(LETTERS,3,replace = F),collapse = ""))
df[1:4,1:4]


row_metaData <- data.frame(exprtype=sample(c("Up","Down"),15,replace = T),
                           genetype=sample(c("Metabolism","Immune","None"),15,replace = T))
rownames(row_metaData) <- rownames(df)
col_metaData <- data.frame(tissue=sample(c("Normal","Tumor"),15,replace = T),
                           risklevel=sample(c("High","Low"),15,replace = T))
rownames(col_metaData) <- colnames(df)
exprcol <- c("#EE0000FF","#008B45FF" )
names(exprcol) <- c("Up","Down")
genecol <- c("#EE7E30","#5D9AD3","#D0DFE6FF")
names(genecol) <- c("Metabolism","Immune","None")
tissuecol <- c("#98D352","#FF7F0E")
names(tissuecol) <- c("Normal","Tumor")
riskcol <- c("#EEA236FF","#46B8DAFF")
names(riskcol) <- c("High","Low")
col <- list(exprtype=exprcol,genetype=genecol,tissue=tissuecol,risklevel=riskcol)
text_rows <- sample(rownames(df),3)

p<- ggheatmap(df,cluster_rows = T,cluster_cols = T,scale = "row",
              text_show_rows = text_rows,
              cluster_num = c(3,3),
              tree_color_rows = c("#008B45FF","#631879FF","#008280FF"),
              tree_color_cols = c("#1F77B4FF","#FF7F0EFF","#2CA02CFF"),
              annotation_rows = row_metaData,
              annotation_cols = col_metaData,
              annotation_color = col
)
p
Warning messages:
1: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead. 
2: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead. 
Error in `ggplot_add()`:
! Can't add `x[[i]]` to a ggplot object.

No plot is generated.

About the linesize of clustertree

Thanks for providing such a great package. It really helps me a lot in data visualization. However, sometimes the line is too thick in the output figure. I'm wondering is it possible to add a parameter to control the linesize just like tree_color_rows and tree_color_cols?

Plot labeling (title, subtitle, caption) are only possible when both cluster_rows and cluster_cols are both false.

Hey, thanks for the great tool!

I encountered a weird problem: Plot labeling (title, subtitle, caption) are only possible when both cluster_rows and cluster_cols are both false.

>   ggheatmap::ggheatmap(data_matrix ) + labs(title = 'title', subtitle = 'subtitle', caption = 'caption')
# plot is generated, and labeled correctly

>   ggheatmap::ggheatmap(data_matrix, cluster_rows = T ) + labs(title = 'title', subtitle = 'subtitle', caption = 'caption')
Error in ggheatmap::ggheatmap(data_matrix, cluster_rows = T) + labs(title = "title",  : 
non-numeric argument to binary operator

Increasing the cell size on plot

Hello,

I try to create a plot using ggheatmap() and need to increase the cell size on the plot. Normally, while I am using phheatmap(), It has cellwidht, cellheight arguments also heatmap.2() contains the width and height argument.

Is there any argument that I can use with ggheathmap()

Error When Adding Clusters to Heatmap

Hi,
Adding clusters to rows or columns causes an error in ggheatmap. While running the first example code shared under the Usage title, I got the below error.

Error Message : Error in if (zero_range(as.numeric(limits))) { :
missing value where TRUE/FALSE needed
In addition: Warning message:
In zero_range(as.numeric(limits)) : NAs introduced by coercion

Note : All the packages installed are recently updated.

Thank for your help.
Sincerely.

Error in ggheatmap[[1]][[num]] + theme[[i]] :

example code does not work:

devtools::install_github("XiaoLuo-boy/ggheatmap")
install.packages("ggheatmap")
library(ggheatmap)
library(tidyr)
set.seed(123)
df <- matrix(runif(225,0,10),ncol = 15)
colnames(df) <- paste("sample",1:15,sep = "")
rownames(df) <- sapply(1:15, function(x)paste(sample(LETTERS,3,replace = F),collapse = ""))
df[1:4,1:4]


row_metaData <- data.frame(exprtype=sample(c("Up","Down"),15,replace = T),
                           genetype=sample(c("Metabolism","Immune","None"),15,replace = T))
rownames(row_metaData) <- rownames(df)
col_metaData <- data.frame(tissue=sample(c("Normal","Tumor"),15,replace = T),
                           risklevel=sample(c("High","Low"),15,replace = T))
rownames(col_metaData) <- colnames(df)
exprcol <- c("#EE0000FF","#008B45FF" )
names(exprcol) <- c("Up","Down")
genecol <- c("#EE7E30","#5D9AD3","#D0DFE6FF")
names(genecol) <- c("Metabolism","Immune","None")
tissuecol <- c("#98D352","#FF7F0E")
names(tissuecol) <- c("Normal","Tumor")
riskcol <- c("#EEA236FF","#46B8DAFF")
names(riskcol) <- c("High","Low")
col <- list(exprtype=exprcol,genetype=genecol,tissue=tissuecol,risklevel=riskcol)
text_rows <- sample(rownames(df),3)

p<- ggheatmap(df,cluster_rows = T,cluster_cols = T,scale = "row",
              text_show_rows = text_rows,
              cluster_num = c(3,3),
              tree_color_rows = c("#008B45FF","#631879FF","#008280FF"),
              tree_color_cols = c("#1F77B4FF","#FF7F0EFF","#2CA02CFF"),
              annotation_rows = row_metaData,
              annotation_cols = col_metaData,
              annotation_color = col
)
p


ggheatmap(df,cluster_rows = T,cluster_cols = T,scale = "row",
          text_show_rows = text_rows,
          border = "grey",
          cluster_num = c(3,3),
          tree_color_rows = c("#008B45FF","#631879FF","#008280FF"),
          tree_color_cols = c("#1F77B4FF","#FF7F0EFF","#2CA02CFF"),
          annotation_rows = row_metaData,
          annotation_cols = col_metaData,
          annotation_color = col
)%>%
  ggheatmap_theme(1,theme =list(theme(axis.text.x = element_text(angle = 90,face = "bold",size = 10),
                                      axis.text.y = element_text(colour = "red",face = "bold"))))

Error:

Error in ggheatmap[[1]][[num]] + theme[[i]] : 
  non-numeric argument to binary operator
In addition: Warning messages:
1: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead. 
2: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead. 
3: In ggheatmap_theme(., 1, theme = list(theme(axis.text.x = element_text(angle = 90,  :
  Incompatible methods ("Ops.data.frame", "+.gg") for "+"

Error when running the sample

> p<- ggheatmap(df,cluster_rows = T,cluster_cols = T,scale = "row",
+               text_show_rows = text_rows,
+               cluster_num = c(3,3),
+               tree_color_rows = c("#008B45FF","#631879FF","#008280FF"),
+               tree_color_cols = c("#1F77B4FF","#FF7F0EFF","#2CA02CFF"),
+               annotation_rows = row_metaData,
+               annotation_cols = col_metaData,
+               annotation_color = col
+ )
> p
Error in if (zero_range(as.numeric(limits))) { : 
  需要TRUE/FALSE值的地方不可以用缺少值
此外: Warning message:
In zero_range(as.numeric(limits)) : 强制改变过程中产生了NA
> sessionInfsessionInfo()
Error in sessionInfsessionInfo() : 没有"sessionInfsessionInfo"这个函数
> sessionInfo()
R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.utf8
[2] LC_CTYPE=Chinese (Simplified)_China.utf8
[3] LC_MONETARY=Chinese (Simplified)_China.utf8
[4] LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.utf8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] aplot_0.1.9   tidyr_1.3.0   ggheatmap_2.2 ggplot2_3.4.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.10        pillar_1.8.1       compiler_4.2.2     ggpubr_0.6.0
 [5] viridis_0.6.2      yulab.utils_0.0.6  dendextend_1.16.0  viridisLite_0.4.1
 [9] jsonlite_1.8.4     lifecycle_1.0.3    tibble_3.1.8       gtable_0.3.1
[13] pkgconfig_2.0.3    rlang_1.0.6        cli_3.6.0          ggplotify_0.1.0   
[17] patchwork_1.1.2    ggrepel_0.9.3      gridExtra_2.3      factoextra_1.0.7
[21] withr_2.5.0        dplyr_1.1.0        generics_0.1.3     vctrs_0.5.2
[25] gridGraphics_0.5-1 grid_4.2.2         tidyselect_1.2.0   glue_1.6.2
[29] R6_2.5.1           rstatix_0.7.2      fansi_1.0.4        carData_3.0-5
[33] farver_2.1.1       purrr_1.0.1        car_3.1-1          magrittr_2.0.3
[37] scales_1.2.1       backports_1.4.1    abind_1.4-5        colorspace_2.1-0
[41] ggsignif_0.6.4     labeling_0.4.2     utf8_1.2.3         munsell_0.5.0
[45] broom_1.0.3        crayon_1.5.2       ggfun_0.0.9

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.