LieberInstitute / jaffelab

R package with commonly used functions by the Jaffe lab
http://lieberinstitute.github.io/jaffelab
7 stars 3 forks source link

we should just make our own clusterProfiler plotting function #2

Open andrewejaffe opened 5 years ago

andrewejaffe commented 5 years ago

there's been a bit of instability with returning NAs in the clusters using dotplot....something like the below almost completely reproduces their plotting. i think this would be useful 1) so we start with data frames, 2) so we can also more easily pick gene sets to highlight in figures (which is super hard now) and 3) so we can add newline breaks in super long descriptions

library(ggplot2)
library(jaffelab)
library(DOSE)
load("/dcl02/lieber/ptsd/RNAseq/VA_PTSD_RNAseq/rdas/geneSet_threeGroups_qSVA_BasoAmyg_onlyPTSD_q0.2.rda")
d = as.data.frame(go_basoamyg)

## write code to add newline breaks to long descriptions as a new variable...ie find a space to add a newline for every N characters

## make the ratio numeric
d$GeneProp = as.numeric(ss(d$GeneRatio, "/"))/as.numeric(ss(d$GeneRatio, "/",2))

## you can filter way easier
dd = d[d$p.adjust < 0.05,]

## and plot
ggplot(dd, aes(x=Cluster, y=Description)) +
    geom_point(aes(size = GeneProp, color = p.adjust)) +
    scale_colour_gradient(limits=c(0, max(dd$p.adjust)), low="red",high="blue") +
    theme_dose() + ylab(NULL)