how do I add a title to an Upset plots

I was trying to add a title to an upset plot using the suggestion in this post but it returned an error.

Error in upset(plot, nintersects = 8, nsets = 6, sets = c("Pos.Corr.K1",  : 

non-numeric argument to binary operator

My code is

library (Upset)
library(grid)
#setting up some random data
Pos.Corr.K1 <- c("GO:0055114", "GO:0016491", 
                        "GO:0016620", "GO:0005739", 
                        "GO:0005759", "GO:0022900", 
                        "GO:0016208")

Neg.Corr.K1 <- c("GO:0005840", "GO:0003987", 
                        "GO:0019427", "GO:0005524",
                        "GO:0005737", "GO:0043231", 
                        "GO:0000166")

Pos.Corr.DXB11 <- c("GO:0055114", "GO:0016491", 
                           "GO:0005739", "GO:0005737", 
                           "GO:0043231", "GO:0000166", 
                           "GO:0005524")

Neg.Corr.DXB11 <- c("GO:0016620", "GO:0005759", 
                           "GO:0022900", "GO:0005840", 
                           "GO:0003987") 

#Draw Upset Plot
data <- list( Pos.Corr.K1, Neg.Corr.K1,  
             Pos.Corr.DXB11, Neg.Corr.DXB11)
names(data) <- c( "Pos.Corr.K1", "Neg.Corr.K1", 
                  "Pos.Corr.DXB11", 
                 "Neg.Corr.DXB11") 
plot <- UpSetR::fromList(data) 
setwd("C:/PETER PROJECT/3g. Mass Spec Processing (Comparison of K1 v DXB11)/Results/Upset Plot")
# create PNG for the heat map     
png("Upset Plot (2) - K1 v DXB11 (DE Proteins).png",   
width = 10*300,        # 10 x 300 pixels
height = 10*300,
res = 300,)            # 300 pixels per inch
Upset <- upset(plot, 
          nintersects = 8, 
          nsets = 6,
          sets = c( "Pos.Corr.K1", "Neg.Corr.K1", 
                  "Pos.Corr.DXB11", "Neg.Corr.DXB11"),
          #group.by = "sets", 
          #cutoff = 0,
          empty.intersections = "off",
          order.by = "freq", 
          decreasing = T, 
          point.size = 5,
          line.size = 1,
          mb.ratio = c(0.65, 0.35),
          number.angles = 0, 
          text.scale = c(2, 2, 2, 2, 2, 2) 
          #text.scale = c(intersection size title, 
          #               intersection size tick labels, set size title, 
          #               set size tick labels, set names, 
          #               numbers above bars)
          ) +
grid.text("Distribution of DE Proteins", x = 0.65, y = 0.95,
          gp = gpar(fontsize = 20))
print(Upset)

The code runs perfectly without the lines

+
    grid.text("Distribution of DE Proteins", x = 0.65, y = 0.95,
              gp = gpar(fontsize = 20))

but this is the code suggested in the original post.

Any advice would be appreciated.

Source link