kkdey / Logolas

R package for Enrichment Depletion Logos (EDLogos) and String Logos
https://kkdey.github.io/Logolas-pages
GNU General Public License v3.0
27 stars 1 forks source link

help with color_type = "per_symbol" with protein sequences #18

Closed ron-geller closed 4 years ago

ron-geller commented 4 years ago

Hi, I would like to generate an EDlogo for a protein sequence (so 20 letters in total) with custom colors. However, I am not finding a way to do it. I manage to get the right colors with the following code: color_profile <- list("type" = "per_symbol", "col" = cols$color) # cols$color has the 20 colors I want in order plogomaker(df[,2:7], color_profile = color_profile) but I cannot figure out how to do this in the logomaker function, which gives me the correct formatting. I tried different things in the logo_control argument with no luck. Can you please let me know how to do this? Thanks, Ron

kkdey commented 4 years ago

Hi Ron,

Can you try this?

library(Logolas) cols1 <- c(rev(RColorBrewer::brewer.pal(12, "Paired"))[c(3,4,7,8,11,12,5,6,9,10)], RColorBrewer::brewer.pal(12, "Set3")[c(1,2,5,8,9)], RColorBrewer::brewer.pal(9, "Set1")[c(9,7)], RColorBrewer::brewer.pal(8, "Dark2")[c(3,4,8)]) names(cols1) = c("A", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "Y")

library(ggseqlogo) data(ggseqlogo_sample) sequence <- seqs_aa$AKT1 logomaker(sequence, type = "EDLogo", colors = cols1)

This should take the colors for the corresponding amino acid monomer character in the cols1 vector. Let me know if it does not work.

ron-geller commented 4 years ago

Hi, Thanks for the answer. However, it is still not giving me the right colors I want... For example: these are my colors cols1 <- c("#f76ab4", "#ff7f00", "#e41a1c", "#e41a1c", "#84380b", "#f76ab4", "#3c58e5", "#12ab0d", "#3c58e5", "#12ab0d", "#12ab0d" ,"#972aa8" ,"#12ab0d", "#972aa8", "#3c58e5", "#ff7f00", "#ff7f00" ,"#12ab0d", "#84380b" ,"#84380b")

names(cols1) = c("A", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M","N", "P", "Q", "R", "S", "T", "V", "W", "Y")

some simulated data

df=data.frame(data=runif(20)) rownames(df)= names(cols1)

the logo plot

logomaker(df,colors=cols1)

The error

If you notice, M is pink and it should be green ("#12ab0d"), as can be see here

barplot(height = df$data,names=names(cols1),col=cols$color)

Thanks in advance Ron

kkdey commented 4 years ago

Hi Ron,

Surprisingly I get the M to be green. Here is the code I ran.

cols1 <- c("#f76ab4", "#ff7f00", "#e41a1c", "#e41a1c", "#84380b", "#f76ab4", "#3c58e5", "#12ab0d", "#3c58e5", "#12ab0d", "#12ab0d" ,"#972aa8" ,"#12ab0d", "#972aa8", "#3c58e5", "#ff7f00", "#ff7f00" ,"#12ab0d", "#84380b" ,"#84380b")

names(cols1) = c("A", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M","N", "P", "Q", "R", "S", "T", "V", "W", "Y") df=data.frame(data=runif(20)) rownames(df)= names(cols1) logomaker(df,colors=cols1)

Rplot01

kkdey commented 4 years ago

Are you using the latest version of the package from Github? In case you are using the Bioc version, can you please switch to the Github version instead?

ron-geller commented 4 years ago

Yes, that was the problem. Updating fixed the color issue. Thanks for making the great tool and helping to resolve the issue so fast.