library(ggforce) # For drawing circle
# ***** Read the two images *****
# Read the logo of GeneCard Bio
genecard_bio_logo <- "images/genecard-bio_logo.png" |>
magick::image_read()
genecard_bio_logo_grob <- genecard_bio_logo |>
grid::rasterGrob(interpolate = TRUE) # For changing to grob
# Read the logo of GeneCard Bioimage
genecard_bioimage_logo <- "images/genecard-bioimage_logo.png" |>
magick::image_read()
genecard_bioimage_logo_grob <- genecard_bioimage_logo |>
grid::rasterGrob(interpolate = TRUE) # For changing to grob
# ***** Set the coordinates for magnifying lens (放大镜) *****
# Prepare a data frame for circles/glasses
circles <- data.frame(
x = c(50, 150),
y = c(50, 50),
r = c(40, 40)
)
# Prepare a data frame for lines (i.e. the handles of magnifying lens)
line_1 <- data.frame( # Try several iterates to set the coordinates
x = c(73, 90),
y = c(20, 0)
)
line_2 <- data.frame( # Try several iterates to set the coordinates
x = c(173, 190),
y = c(20, 0)
)
# ***** Plot the two image with QuPath-style *****
df <- data.frame(x = seq(1, 200, by = 2), y = 1:100) # Create a data frame
genecard_qupath_style <- df |> ggplot(aes(x = x, y = y)) +
annotation_custom( # For adding the logo of GeneCard Bio
genecard_bio_logo_grob,
xmin = 20, # Try several iterates to set the coordinates
xmax = 80,
ymin = 20,
ymax = 80
) +
annotation_custom( # For adding the logo of GeneCard Bioimage
genecard_bioimage_logo_grob,
xmin = 112, # Try several iterates to set the coordinates
xmax = 182,
ymin = 12,
ymax = 82
) +
geom_point(alpha = 0) + # For adding points but with alpha = 0 (i.e., invisible)
geom_line( # For adding the handle of magnifying lens (left black line)
data = line_1,
aes(x = x, y = y),
linewidth = 4,
color = "black"
) +
geom_line( # For adding the handle of magnifying lens (right black line)
data = line_2,
aes(x = x, y = y),
linewidth = 4,
color = "black"
) +
ggforce::geom_circle( # For adding circles/glasses of magnifying lens
data = circles,
aes(x0 = x, y0 = y, r = r, linewidth = 8),
color = "#3674C1"
) +
theme_void() +
theme(legend.position = "none") # For removing legend
genecard_qupath_style |> ggsave( # For saving
filename = "images/qupath-style-logo-2.png",
width = 6,
height = 3,
units = "cm",
dpi = 300
)