Skip to content

Instantly share code, notes, and snippets.

@mikelove
Created July 6, 2023 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikelove/8d4fd58d9a65bcf3cc26a1ef758022cf to your computer and use it in GitHub Desktop.
Save mikelove/8d4fd58d9a65bcf3cc26a1ef758022cf to your computer and use it in GitHub Desktop.
file to make UpSet plot of banana intersections
# scraped from https://doi.org/10.1038/nature11241
# note that intersections < 100 not included
banana_sets <- c(
Musa = 759,
Phoenix = 769,
Sorghum = 827,
Brachypodium = 387,
Ozyza = 1246,
Arabidopsis = 1187,
`Musa&Phoenix` = 467,
`Brachypodium&Sorghum` = 402,
`Musa&Brachypodium&Sorghum&Oryza` = 368,
`Musa&Brachypodium&Sorghum&Oryza&Phoenix` = 685,
`Brachypodium&Oryza` = 547,
`Brachypodium&Sorghum&Oryza` = 2809,
`Sorghum&Oryza` = 1151,
`Brachypodium&Sorghum&Oryza&Phoenix` = 190,
`Brachypodium&Sorghum&Oryza&Arabidopsis` = 206,
`Musa&Brachypodium&Sorghum&Oryza&Arabidopsis` = 1458,
`Musa&Brachypodium&Sorghum&Oryza&Phoenix&Arabidopsis` = 7674,
`Phoenix&Brachypodium&Sorghum&Oryza&Arabidopsis` = 258,
`Musa&Brachypodium&Sorghum&Phoenix&Arabidopsis` = 113,
`Musa&Sorghum&Oryza&Phoenix&Arabidopsis` = 149,
`Musa&Arabidopsis` = 155,
`Musa&Phoenix&Arabidopsis` = 206,
`Phoenix&Arabidopsis` = 105
)
library(UpSetR)
bana_df <- fromExpression(banana_sets)
musa_list <- strsplit(grep("Musa",names(banana_sets[banana_sets>400]), value=TRUE), "&")
musa_list_plus <- lapply(musa_list, \(x) list(query = intersects, params = x, color = "gold", active=TRUE))
cols <- rep(c("grey30","gold","grey30"), c(3,1,2))
png(file="banana_upset.png", width=680, height=510, res=120)
upset(bana_df, nsets = 6, nintersects = 12, order.by = "freq",
queries = musa_list_plus, sets.bar.color = cols)
dev.off()
@mikelove
Copy link
Author

mikelove commented Jul 6, 2023

Original
banana
UpSet version
banana_upset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment