Closed m3hdad closed 1 year ago
pls provide a reproducible example.
Thanks for prompt reply. @GuangchuangYu could you provide a link so I can share my objects.
p1
and p4
are rather complex to share a reproducible code.
Thanks,
pls send to guangchuangyu AT gmail.com
It's all in your hands!
it also doesn't work fine in 0.1.8
version on my platform. But I find the p1
is not a ggtree
object, which might cause the issue. The following codes should work. I hope it can help you.
library(ggplot2)
library(aplot)
packageVersion("aplot")
p1 <- readRDS("p1.rds")
module_names <- readRDS("module_names.rds")
p4 <- readRDS('p4.rds')
#p4 |> insert_left(p1, width = .5)
f1 <- module_names %>%
data.frame(value=.) %>%
dplyr::mutate(group=gsub(' .*','',value)) %>%
ggplot(aes(x=0, y = value, fill = I(group))) +
geom_tile() +
theme(
axis.ticks = element_blank(),
axis.title = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_text(hjust = 0),
panel.grid=element_blank(),
panel.background = element_blank(),
plot.background=element_blank()
)
p.tr <- p4[[1]]$data %>%
tidyr::pivot_wider(id_cols=module, names_from='traits_of_interest', values_from='correlation') %>%
tibble::column_to_rownames(var='module') %>%
dist() %>%
hclust(method='ave') %>%
ggtree::ggtree(hang=-1)
p.end <- (p4[[1]] + coord_cartesian(expand=F)) %>%
insert_left(f1 + coord_cartesian(expand=F), width=.05) %>%
insert_left(p.tr, width=.2)
thanks for looking into this. I believe you are using R 4.2.3 and something has changed since 4.2.1. We can close the issue since it is not related to aplot.
I get the following error in 0.1.10 but everything works fine in 0.1.8 version. downgrading for now!