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

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

Open
yinxy1992 opened this issue Jul 10, 2022 · 2 comments

Comments

@yinxy1992
Copy link

yinxy1992 commented Jul 10, 2022

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
`

@yinxy1992
Copy link
Author

test

@yinxy1992
Copy link
Author

The issue has been addressed by detaching the packahe "ggpubr"!

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

1 participant