Biostar Beta. Not for public use.
Building sequence logo from uneven sequences
0
Entering edit mode
19 months ago
rioualen • 360
France

Hi,

I'm looking for methods to build logo from fasta sequences. I'm not sure what strategy to adopt. My input is a fasta file containing various sequences of various sizes (precisely binding sites, so they're rather short). Looks like this:

>Chromosome:180614-180629
GTAAATTACCGTCAG
>Chromosome:200346-200361
GTAAAACCTGGTAAG
>Chromosome:461646-461661
GTAAAGAGATCACCA
>Chromosome:461694-461709
GTAAAGCACTGAAAG
>Chromosome:461714-461731
GTAAACTAAGCGTTGTC


What I have done is to first align the sequences, using an R package named DECIPHER.

>Chromosome:180614-180629
-CATTTAATGGCAGTC-------
>Chromosome:200346-200361
---GTAAAACCTGGTAAG-----
>Chromosome:461646-461661
---GTAAAGAGATCACCA-----
>Chromosome:461694-461709
----GAAAGTCACGAAATG----
>Chromosome:461714-461731
---GTAAACTAAGCGTTGTC---


I then generated logos using the aligned fasta file, using the R library ggseqlogo, and the online version of weblogo. However I'm not satisfied with the result in both cases.

ggseqlogo

weblogo

It doesn't seem to take into account the "N" characters from my sequences. For example the initial "C" looks big, but in reality it only appears twice among 50 sequences, otherwise this position is unknown.

How can I correct this? Either by changing some parameter, or maybe "trimming" the extremities somehow beforehand?

Thanks!

0
Entering edit mode
0
Entering edit mode

The second one I posted is from weblogo, but maybe I'm missing some parameter here? I just posted 5 sequences here but they're 52 in this particular case.

0
Entering edit mode

I see. Have considered limiting the logo to just the part where there is something in each position?

0
Entering edit mode

Yeah but I'm afraid of losing information, and there has to be a cleaner way to do it, it seems like quite a basic problem to me...

1
Entering edit mode
18 months ago
SMK ♦ 1.3k
Ghent, Belgium

Hi rioualen,

What you can do is:

seqs <- chartr('ATCG-', 'ATCGN', aln)
ggseqlogo(seqs, method = 'p', namespace = 'ATCGN')


Where aln is your alignment characters. (note that here I switched to the "probability" method, you can turn it back to "bits" by removing method = 'p')

0
Entering edit mode

Yeah that's the idea, only I don't want the "N" to appear, for it kinda disturbs the visualization!

0
Entering edit mode

Indeed. A workaround is to make "N" in light grey:

by:

cs_gaps <-
make_col_scheme(
chars = c("A", "T", "C", "G", "N"),
cols = c("#178739", "#CA112C", "#1D4887", "#F3A522", "grey97")
)
ggseqlogo(seqs, method = 'p', namespace = 'ATCGN', col_scheme = cs_gaps)


But also, base 1, 21, 22, and 23 contain not much info and might be trimmed.