Setup
library(UpSetR)
library(ggplot2)
library(ComplexUpset)
##
## Attaching package: 'ComplexUpset'
## The following object is masked from 'package:UpSetR':
##
## upset
library(ggplot2movies)
Read in DEGs
star_brain <- read.delim("../../../bulkRNA/results/star/DEGs/LPS_Brain_gene_DEGs_FDRq0.05.txt",
header = TRUE, sep = "\t")
sn_brain <- read.delim("../../results/DEGs/individual/brain_pseudo_bulk_DEGs_LPS_vs_saline_pval_0.05.tsv",
sep = "\t", header = TRUE)
Subset lists
up_star_brain <- subset(star_brain$gene_name, star_brain$logFC > 0)
down_star_brain <- subset(star_brain$gene_name, star_brain$logFC < 0)
up_sn_brain <- subset(sn_brain$gene, sn_brain$avg_log2FC > 0)
down_sn_brain <- subset(sn_brain$gene, sn_brain$avg_log2FC < 0)
Up set plot
list_input <- list("Bulk brain up-regulated" = up_star_brain,
"Bulk brain down-regulated" = down_star_brain,
"snRNA brain up-regulated" = up_sn_brain,
"snRNA brain down-regulated" = down_sn_brain)
data <- fromList(list_input)
upset_gene <- upset(data, set_sizes=FALSE,
c('Bulk brain up-regulated','Bulk brain down-regulated','snRNA brain up-regulated', 'snRNA brain down-regulated'),
queries=list(
upset_query(set='Bulk brain up-regulated', fill='red'),
upset_query(set='Bulk brain down-regulated', fill='blue'),
upset_query(set='snRNA brain up-regulated', fill='red'),
upset_query(set='snRNA brain down-regulated', fill='blue')
),
base_annotations=list(
'Intersection size'=(
intersection_size(
bar_number_threshold=1, # show all numbers on top of bars
width=0.5, # reduce width of the bars
)
# add some space on the top of the bars
+ scale_y_continuous(expand=expansion(mult=c(0, 0.05)))
+ theme(
# hide grid lines
panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),
# show axis lines
axis.line=element_line(colour='black')
)
)
),
stripes=upset_stripes(
geom=geom_segment(size=12), # make the stripes larger
colors=c('grey95', 'white')
),
# to prevent connectors from getting the colorured
# use `fill` instead of `color`, together with `shape='circle filled'`
matrix=intersection_matrix(
geom=geom_point(
shape='circle filled',
size=3,
stroke=0.45
)
),
sort_sets='descending',
sort_intersections='descending'
)
upset_gene

# show the genes that shared up and shared down
shared_up <- intersect(up_star_brain, up_sn_brain)
shared_up
## [1] "JDP2" "MXD1" "PARP14" "MX2" "BIRC2" "NOCT"
## [7] "CDC25C" "FILIP1L" "PLOD1" "LITAF" "CCNL1" "DNAJB1"
## [13] "B4GALT5" "PLEK" "SLC26A11" "HSPH1" "HUNK" "HS6ST2"
## [19] "ATP1A1" "BAG3" "HSPA8" "HSPB8" "DNAJA4" "STIP1"
## [25] "SLC38A2" "RGS20" "CARS1" "CSRP2"
shared_down <- intersect(down_star_brain, down_sn_brain)
shared_down
## [1] "LEF1" "ARHGAP24" "ARHGAP25" "SLCO2B1" "GRAMD1C" "FLI1"
## [7] "HDAC9" "ITGA6" "P3H1" "PDE3B" "KCNK13" "DOCK8"
## [13] "GPC5" "PDZRN4" "RCSD1" "CGNL1" "P2RY12" "TMCC3"
## [19] "LRMDA" "RASSF3" "ST6GAL1" "DISC1" "PHACTR2" "TST"
## [25] "SOX13" "MAN1A1" "SLC6A20" "ZIC2" "BLNK" "LOXL3"
## [31] "TMOD3" "SERINC5" "NID2" "ARHGAP15" "DOCK2" "CDK6"
## [37] "FAM160A1" "ZFPM2" "IQGAP2" "BIN2" "TMEFF2" "VANGL1"
## [43] "CECR2" "ADAMTS10" "ACOX2" "FIGN" "ERCC6L2" "APBB1IP"
## [49] "BCKDHB" "BTBD7" "FLT1" "ALPL"