Loading packages
if (!require("UpSetR")) install.packages("UpSetR"); library(UpSetR)
## Loading required package: UpSetR
all genes.. boolean data file
dat <- read.csv("countsFileBoolean.csv", header=T, row.names = 1)
head(dat)
## chvi_f cabr_f stlu_f arja_f loth_n ange_n glso_n
## sp|A0A024RBG1|NUD4B_HUMAN 1 1 0 0 1 1 0
## sp|A0A061I403|FICD_CRIGR 0 0 0 0 0 0 0
## sp|A0A075B6H9|LV469_HUMAN 0 0 0 0 0 0 0
## sp|A0A075B6I0|LV861_HUMAN 0 0 0 1 0 1 1
## sp|A0A075B6I1|LV460_HUMAN 0 0 0 0 0 0 0
## sp|A0A075B6I3|LVK55_HUMAN 1 0 0 0 0 1 0
## nole_p mobl_i mawa_i ptpa_i dero_b gene
## sp|A0A024RBG1|NUD4B_HUMAN 1 1 1 1 1 NA
## sp|A0A061I403|FICD_CRIGR 0 0 0 0 1 NA
## sp|A0A075B6H9|LV469_HUMAN 0 0 0 1 0 NA
## sp|A0A075B6I0|LV861_HUMAN 0 1 1 1 1 NA
## sp|A0A075B6I1|LV460_HUMAN 0 0 0 1 0 NA
## sp|A0A075B6I3|LVK55_HUMAN 0 0 0 1 0 NA
plot showing intersections between all species/all genes
upset(dat, nsets =12 , number.angles = 30, point.size = 2, line.size = 1,
mainbar.y.label = "Gene Intersection Size",
text.scale = c(1, 1, 1, 1, 0.75, 0.75))

plot showing intersections between specfic speices
(Frugivore/Piscivore)
upset(dat, sets = c("nole_p", "stlu_f", "chvi_f"), sets.bar.color = "#56B4E9",
order.by = "freq", empty.intersections = "on", mainbar.y.label = "Gene Intersections" , query.legend = "top", queries = list(list(query = intersects, params = list("stlu_f","chvi_f"), color = "orange", active = T, query.name = "Frugivores"), (list(query = intersects, params = list("nole_p","chvi_f"), color = "red", active = T, query.name = "Frugivore/Piscivore"))))

plot showing intersections between specfic speices
(Frugivore/Insectivore)
top three intersection groups were between frugivores.
upset(dat, sets = c("stlu_f", "mawa_i", "arja_f", "chvi_f"), sets.bar.color = "#56B4E9",
order.by = "freq", empty.intersections = "on", mainbar.y.label = "Gene Intersections", queries = list(list(query = intersects, params = list("stlu_f", "arja_f", "chvi_f"), color = "orange", active = T),list(query = intersects, params = list("stlu_f","arja_f"), color = "orange", active = T),list(query = intersects, params = list("stlu_f","chvi_f"), color = "orange", active = T), (list(query = intersects, params = list("stlu_f","chvi_f", "mawa_i"), color = "red", active = T))))

plot showing intersections between specfic speices
(Frugivore/Insectivore) and presence specifc gene
func <- function(row, species) {
dat <- (row["gene"] %in% species)
}
upset(dat, sets = c("nole_p", "stlu_f", "chvi_f"), sets.bar.color = "#56B4E9",
order.by = "freq", empty.intersections = "on", mainbar.y.label = "Gene Intersections" , query.legend = "top", queries = list(list(query = func, params = list(1534), color = "blue", active = F, query.name = "specific gene"),list(query = intersects, params = list("stlu_f","chvi_f"), color = "orange", active = T, query.name = "Frugivores"), (list(query = intersects, params = list("nole_p","chvi_f"), color = "red", active = T, query.name = "Frugivore/Piscivore"))))
