Skip to content

Commit

Permalink
Merge pull request #4 from solislemuslab/dev
Browse files Browse the repository at this point in the history
Added changes to the sticker
  • Loading branch information
YunyiShen authored Jul 14, 2021
2 parents 1370dda + 34fcaab commit a5971ca
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 16 deletions.
Binary file added real_data/alpha_cent_vs_mu2.pdf
Binary file not shown.
33 changes: 27 additions & 6 deletions real_data/alphavsmean.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,37 @@ soil <- soil[order(soil$mu),]
soil$genus <- factor(soil$X, levels = (as.character(soil$X)))
human <- human[order(human$mu),]
human$genus <- factor(human$X, levels = (as.character(human$X)))

gsoil <- ggplot(data = soil,aes(x=genus,y=alpha_cent)) +
geom_bar( stat = "identity") +
geom_bar( stat = "identity", fill="chocolate") +
ylab("alpha centrality") +
xlab("soil")+
xlab("")+ ggtitle("Soil") +
theme(
plot.title = element_text(hjust=0.5, size=rel(1.5)),
axis.title.x = element_text(size=rel(1.2)),
axis.title.y = element_text(size=rel(1.2), angle=90, vjust=0.5, hjust=0.5),
axis.text.x = element_text(colour="grey49", size=rel(1.0), angle=0, face="plain"),
axis.text.y = element_text(colour="grey49", size=rel(1.2), angle=0, face="plain"),
panel.background = element_blank(),
axis.line = element_line(colour = "grey"),
strip.text = element_text(size = 17)
) +
coord_flip()

ghuman <- ggplot(data = human,aes(x=genus,y=alpha_cent)) +
geom_bar( stat = "identity") +
geom_bar( stat = "identity", fill="gold3") +
ylab("alpha centrality") +
xlab("gut") +
xlab("") + ggtitle("Human gut") +
theme(
plot.title = element_text(hjust=0.5, size=rel(1.5)),
axis.title.x = element_text(size=rel(1.2)),
axis.title.y = element_text(size=rel(1.2), angle=90, vjust=0.5, hjust=0.5),
axis.text.x = element_text(colour="grey49", size=rel(1.0), angle=0, face="plain"),
axis.text.y = element_text(colour="grey49", size=rel(1.2), angle=0, face="plain"),
panel.background = element_blank(),
axis.line = element_line(colour = "grey"),
strip.text = element_text(size = 17)
) +
coord_flip()


Expand All @@ -24,8 +45,8 @@ ggpubr::ggarrange(ghuman,gsoil,
ncol = 2, nrow = 1)


ggsave("./real_data/alpha_cent_vs_mu.pdf", width = 9, height = 4, scale = 0.8)

#ggsave("./real_data/alpha_cent_vs_mu.pdf", width = 9, height = 4, scale = 0.8)
ggsave("alpha_cent_vs_mu2.pdf", width = 10, height = 5, scale = 0.8)


cor.test(human$mu, human$alpha_cent,
Expand Down
31 changes: 21 additions & 10 deletions tests/Formal/Accurancy/Graph_ploter.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,39 @@ graphss <- lapply(1:6, function(i){
graphss <- Reduce(stack, graphss)
names(graphss) <- paste0("model",1:6)

gplot(graphss) +
geom_tile(aes(fill = value)) +
facet_wrap(~ variable) +
#blue: "#0072B2",
#red: "#990000"

p <- gplot(graphss) +
geom_tile(aes(fill = value), color="grey65") +
facet_grid(~ variable) +
scale_fill_gradient2(#low = "#0339ce",
#high = "#fdcf18",
low = "red",
#mid = "white",
mid = "grey95",
high = "blue",
#low = "blue",
low = "#0072B2",
mid = "white",
#mid = "grey95",
#high = "red",
high = "#990000",
midpoint = 0,
na.value="transparent") +
labs(fill = "value", x = "", y="") +
theme(text = element_text(size=14),
theme(text = element_text(size=20),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank(),
plot.margin = margin(.15, .15, .15, .15, "cm"))+
plot.margin = margin(.15, .15, .15, .15, "cm"),
#legend.position = "bottom",
legend.title = element_blank())+
theme(
panel.background = element_rect(fill = "transparent"), # bg of the panel
plot.background = element_rect(fill = "transparent", color = NA), # bg of the plot
legend.background = element_rect(fill = "transparent")#, # get rid of legend bg
#legend.box.background = element_rect(fill = "transparent") # get rid of legend panel bg
)

ggsave("./simu_graphs.pdf",width = 10.5,height=7, scale = 0.8)
#ggsave("./simu_graphs.pdf",width = 10.5,height=7, scale = 0.8)

pdf("model-grid.pdf", height=3, width=18)
p
dev.off()
Binary file added tests/Formal/Accurancy/model-grid.pdf
Binary file not shown.
31 changes: 31 additions & 0 deletions tests/sticker.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,34 @@ ww
ggsave("CARlasso.png",width = 1,height = 1, unit = "in", dpi = 500, scale = 1)

sticker(pp, package = "CARlasso", s_width = 2.3, s_height=2.3, s_x=0.96, s_y=0.65, h_fill = "#4e8ff0", p_y = 1.5, p_size = 15.5)


## New sticker:
# CAR-LASSO
library(CARlasso)
library(ggplot2)
library(hexSticker)

#example(CARlasso)
set.seed(1234)
dt <- simu_AR1(n=100,k=4, rho=0.7)
car_res <- CARlasso(y1+y2+y3+y4~x1+x2+x3, data = dt, adaptive = TRUE)

car_res$nodes$predictors <- rep("", 3)
car_res$nodes$response <- rep("", 4)
p <- plot(car_res)
pp <- p + theme(legend.position = "none") +
theme(
panel.background = element_rect(fill = "transparent",color = NA), # bg of the panel
plot.background = element_rect(fill = "transparent", color = NA), # bg of the plot
panel.grid.major = element_blank(), # get rid of major grid
panel.grid.minor = element_blank(), # get rid of minor grid
legend.background = element_rect(fill = "transparent"), # get rid of legend bg
legend.box.background = element_rect(fill = "transparent"), # get rid of legend panel bg
legend.key = element_rect(fill = "transparent", colour = NA), # get rid of key legend fill, and of the surrounding
axis.line = element_line(colour = NA) # adding a black line for x and y axis
)


ww <- sticker(pp, package = "CARlasso", s_width = 1.83, s_height=1.83, s_x=1.05, s_y=0.8, h_fill = "#edeff2", p_y = 1.6, p_color="black", p_size=15, h_color="#9d9d9e")
ww

0 comments on commit a5971ca

Please sign in to comment.