andreamrau / coseq

Co-Expression Analysis of Sequencing Data
6 stars 2 forks source link

rotate labels #6

Closed leorippel closed 1 year ago

leorippel commented 1 year ago

Hi, thanks for the amazing tool.

My sample names are a bit long, how can I rotate to 45degrees the sample names?

cheers.

andreamrau commented 1 year ago

Hi, and thanks for your question. The plots produced by coseq are actually made with ggplot2, so you can modify them as you wish with standard ggplot2 code. Here's an example to change the sample labels on cluster boxplots and rotate to 45 degrees.

## Quick simulation
library(coseq)
countmat <- matrix(runif(300*4, min=0, max=500), nrow=300, ncol=4)
countmat <- countmat[which(rowSums(countmat) > 0),]
sample_labels <- paste0("Super long name for replicate ", 1:ncol(countmat))
run_arcsin <- coseq(object=countmat, K=2:4, iter=5, transformation="arcsin",
                    model="Normal", seed=12345)

## Customize coseq boxplots
library(ggplot2)
plot(run_arcsin, graph="boxplots")$boxplots +
  scale_x_discrete(labels= sample_labels) +
  xlab("") +
  theme(axis.text.x=element_text(angle=45, vjust=1, hjust=1)) 

Best wishes, AR