0

I am creating a Sequence Logo plot using ggseqlogo. The input to ggseqlogo is a position frequency matrix. My sequences are of varying length. When creating the plot the x-axis is too messy. I found a similar answer, by suggesting to convert the data to factor and create a discrete x-axis here Overflowing X axis (ggplot2) . But in my case the input is a matrix and I am not sure how to move forward.

Thanks for all the help.

Below is a similar structure(The frequency count is not similar to my actual data).

StackOverflow <- matrix(sample.int(2500, 6*151, TRUE), 6, 151)

rownames(StackOverflow) <- c('A' , 'C', 'G', 'T', 'N', 'S')

cs_gaps <-
    make_col_scheme(
            chars = c("A", "T", "C", "G", "N" , "S"),
            cols = c("Green", "Red", "Orange", "blue", "purple" , "white")
    )
#labels <- seq(0, 2000, length.out= 76)
ggseqlogo(StackOverflow , method = 'p' , namespace = 'ATCGNS', col_scheme = cs_gaps) +

    theme(plot.title = element_text(size = 30 , face = "bold" , hjust = 0.5),
          plot.subtitle = element_text(size = 28 , face = "bold", hjust = 0.5),
          axis.text.x = element_text(size = 25, angle = 45, hjust = 1),
          axis.text.y = element_text(size = 25))

          #scale_x_discrete(breaks=labels, labels=as.character(labels))
RG20
  • 189
  • 1
  • 8
  • why not label it every 10? ```ggseqlogo(StackOverflow , method = 'p') + scale_x_continuous(breaks=seq(1,151,by=10))``` – StupidWolf May 11 '20 at 20:19
  • @StupidWolf, Thank you. Can you please write it as an answer, so that I can accept it. – RG20 May 12 '20 at 10:30

0 Answers0