Search
Question: DiffBind: How to change the scatter plot colors?
0
15 months ago by
Senthil0
Germany
Senthil0 wrote:

How to change the default scatter plot colors of dba.plotMA function?

---

Senthil

modified 15 months ago by Rory Stark2.4k • written 15 months ago by Senthil0
0
15 months ago by
Rory Stark2.4k
CRUK, Cambridge, UK
Rory Stark2.4k wrote:

Hi Senthil-

Currently there is not an official way to change the colors of the MA plots in DiffBind.

I can think of two ways to get MA plots with different colors. One is to do your own plotting, and the other is to hack some un-exported variables.

Suppose you want to change the color of the dots from blue to black, and the color of the dots representing significantly bound sites from magenta to green. Here's some code that makes a MA plot (example uses built-in tamoxifen dataset):

> data(tamoxifen_analysis)
> report <- dba.report(tamoxifen,th=1)
> plot(report$Conc,report$Fold,pch=20,cex=.15,col="black")
> points(report$Conc[sigDB],report$Fold[sigDB],pch=20,cex=.15,col="green")

You still have to fill in the labels for the axes etc.

The second way involves a hack, but lets you use the logic in dba.plotMA(). The default colors are set using two internal variables, crukBlue and crukMagenta. You can change the values for these variables using assignInNamespace():

> data(tamoxifen_analysis)
> dba.plotMA(tamoxifen, bSmooth=FALSE)

> crukBlue.save <- getFromNamespace("crukBlue", "DiffBind")
> crukMagenta.save <- getFromNamespace("crukMagenta", "DiffBind")
> assignInNamespace("crukBlue","black","DiffBind")
> assignInNamespace("crukMagenta","green","DiffBind")
> dba.plotMA(tamoxifen, bSmooth=FALSE)

> assignInNamespace("crukBlue",crukBlue.save,"DiffBind")
> assignInNamespace("crukMagenta",crukMagenta.save,"DiffBind")

There isn't a way to change the horizontal line at 0 fold using this hack as it is hard-wired in the code.

Regards-

Rory