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

How can I reduce the file size of the .eps UpSet figure? #172

Open
bagcik1lumc opened this issue Jan 8, 2023 · 0 comments
Open

How can I reduce the file size of the .eps UpSet figure? #172

bagcik1lumc opened this issue Jan 8, 2023 · 0 comments
Labels
help-request User requested help with the package

Comments

@bagcik1lumc
Copy link

bagcik1lumc commented Jan 8, 2023

Objective
Reduce the file size of the .eps UpSet figure produced in R.

Code

upset(
  M1_BinaryMatrix,
  colnames(M1_BinaryMatrix),
  sort_intersections_by='ratio',
  intersections='all',
  min_degree=2,
  
  set_sizes=(
    upset_set_size(position='right')
    + geom_text(aes(label=paste0(round((..count../nrow(M1_BinaryMatrix))*100), '%')), hjust=1.1, stat='count', color='white')
    + expand_limits(y=1000)
    + ylab("")
    + theme(axis.text.x = element_blank())
  ),
  #
  base_annotations=list(
    'Intersection ratio'=intersection_ratio(text_mapping=aes(label=!!upset_text_percentage()))
#    'Intersection ratio'= intersection_ratio(text_mapping=aes(label=paste0(round(
#      !!get_size_mode('inclusive_intersection')/!!nrow(head(M1_BinaryMatrix, 1000)) * 100
#    ), '%')))
    + ylab("") 
    + theme(axis.text.y=element_blank())
  ),
  #
  name="",
  wrap=TRUE,
  stripes=c(alpha('grey90', 0.45), alpha('white', 0.3)),
  matrix = intersection_matrix(    
    geom=geom_point(
      shape='square',
      size=4
    ),
    segment=geom_segment(
      linetype='solid'
    ), 
    outline_color=list(
      active='darkorange3',
      inactive='grey70'
    )
  )
) + labs(title = "", caption = "") 
ggsave(
  "ups.eps",
  plot = last_plot(),
  device = 'eps',
  # scale = 1
  # width = NA,
  # height = NA,
  # units = c("in", "cm", "mm", "px"),
  dpi = 300,
  limitsize = TRUE
  # bg="transparent"
)

Context (required)
ComplexUpset version: 1.3.3

R version 4.2.2 (2022-10-31 ucrt)
R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
@bagcik1lumc bagcik1lumc added the help-request User requested help with the package label Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help-request User requested help with the package
Projects
None yet
Development

No branches or pull requests

1 participant