rm(list = ls())
##############################input data
dir_path <- "C:\\Users\\liyix\\OneDrive\\Desktop\\"
dir_path_name <- dir(dir_path,pattern = "*.",full.names = T)
#dir_path_name
data_1 <- read.csv(grep("abc.csv",dir_path_name,value = T),header = T,stringsAsFactors = F)
dim(data_1) #[1] 25 12
## [1] 25 12
library(openxlsx)
labs <- read.xlsx(grep("abc.xlsx",dir_path_name,value = T),sheet = 1)
dim(labs)
## [1] 268 40
labs <- colnames(labs)
data_2 <- unique(labs)
data_2 <- data_2[-grep("LogAC50",data_2)]
data_2 <- data_2[-grep("efficacy",data_2)]
data_2 <- data_2[-c(1,2,3,4)]
library(ggplot2)
dim(data_1)
## [1] 25 12
########################################
data_1$Name
## [1] "HEP3B217" "HEPG2" "HLF" "HUH1" "HUH6" "HUH7"
## [7] "JHH1" "JHH2" "JHH4" "JHH5" "JHH6" "JHH7"
## [13] "LI7" "NCIH684" "PLCPRF5" "SKHEP1" "SNU182" "SNU387"
## [19] "SNU398" "SNU423" "SNU449" "SNU475" "SNU761" "SNU878"
## [25] "SNU886"
intersect(data_1$Name, data_2)
## [1] "HEP3B217" "HEPG2" "HUH7" "PLCPRF5" "SKHEP1" "SNU182"
## [7] "SNU387" "SNU398" "SNU423" "SNU449" "SNU475"
############
dat = read.table(text=
" x y sizes
1 -(r1-r2) r2
1 0 r1", header=TRUE)
dat
## x y sizes
## 1 1 -(r1-r2) r2
## 2 1 0 r1
#r1^2*3.14 = 25
r1 <- sqrt(25/3.14)
#r1
#r2^2*3.14 = 11
r2 <- sqrt(11/3.14)
#r2
dat <- matrix(data = c(1, -(r1-r2),r2, 1, 0, r1),
nrow = 2, ncol = 3, byrow = T,
dimnames = list(c("row1", "row2"),
c("x", "y", "sizes")))
dat <- data.frame(dat)
#
dat$color <- c(1,2)
library(ggforce)
dat$color <- as.factor(dat$color)
p1 <- ggplot(dat, aes(x0=x, y0=y, r=sizes,color = color)) +
geom_circle(size = 0.6) + coord_equal() + theme_classic()
p2 <- p1 + theme(panel.border = element_blank(),
legend.position = "",
axis.line = element_blank(),
axis.text = element_blank(),
axis.title = element_blank(),
axis.ticks = element_blank()) +
scale_color_manual(values = c("darkgreen", "darkblue"))
p2

################################################add text
library(cowplot)
##
## ********************************************************
## Note: As of version 1.0.0, cowplot does not change the
## default ggplot2 theme anymore. To recover the previous
## behavior, execute:
## theme_set(theme_cowplot())
## ********************************************************
library(gridExtra)
mytable <- data.frame(matrix(c(intersect(data_1$Name, data_2),""), ncol = 3,nrow = 4))
thm <- ttheme_minimal(
core=list(fg_params = list(hjust=rep(c(0, 1), each=4),
x=rep(c(0.15, 0.85), each=4)),
bg_params = list(fill = NA)),
colhead=list(bg_params=list(fill = NA)),
base_size = 10)
P3 <- p2 + draw_grob(tableGrob(mytable,rows=NULL, cols = NULL,theme=thm),
x= 0.8, y= -1.2, width= 0.3, height=0.4)
dat
## x y sizes color
## row1 1 -0.9499836 1.871680 1
## row2 1 0.0000000 2.821663 2
P3 + annotate(geom="text", x=1, y=3, label="CCLE",
color="darkblue") +
annotate(geom="text", x=1, y=1.2, label="Chemical activity",
color="darkgreen")

###
ggsave(filename = paste0(Sys.Date(),"-overlap_cell.tif"),
plot = last_plot(),
device = "tiff",
path = dir_path,
scale = 1, width = 10.5, height =10.5, units = "cm",dpi = 300,
limitsize = TRUE, compression = "lzw")