Message Boards Message Boards

Convert GenomeData's ACGT letter sequence to base-4 digit sequence?

I have a very elementary question. In Mathematica, I want to convert A,C,G,T letters from GenomeData to base-4 (or for that matter any 4 different integers). How do I do that? Actually, I want to 2dplot the sequence as a random walk. I know how to do this for integer sequence, but my try of it directly from ACGT letters does not work. Perhaps, there is a command to do so?

POSTED BY: Soo-Jong Rey
4 Replies

A different way to go about this is to use the "Chaos Game Representation". Please see this post:

http://community.wolfram.com/groups/-/m/t/920422

POSTED BY: Daniel Lichtblau

A word of advice, it is considered impolite and generally against forum rules to just bluntly solicit help without showing your own attempts. Documentation is very detailed and full of examples, for instance: ColorFunction. You should read about how to post properly.

So is this what you wanted?

ListPlot[seq, Joined -> True, Mesh -> Full, PlotStyle -> Thick, 
 ColorFunction -> Function[{x, y}, ColorData[{"Rainbow", "Reverse"}][x]]]

enter image description here

ListPlot[seq, Joined -> True, Mesh -> Full, PlotStyle -> Thick, Filling -> Bottom, 
 ColorFunction -> Function[{x, y}, ColorData[{"Rainbow", "Reverse"}][x]]]

enter image description here

Also the Demonstrations Project has a lot of free relevant examples, for instance:

DNA Rotator Walk

enter image description here

POSTED BY: Sam Carrettie

Thanks for your help! This is quite close to what I need. One more technical help to ask. Is there any way to rainbow color decorate the first graph along the sequence? i.e. starting from red and then progressing toward violet?

POSTED BY: Soo-Jong Rey

may be:

seq = "ACAAGATGCCATTGTCCCCCGGCCTCCTGCTGCTGCTGCTCTCCGGGGCCACGGCCACCGCTG\
CCCTGCCCCTGGAGGGTGGCCCC";
seq = StringSplit[seq, ""];
seq = ToExpression@StringReplace[seq, {"A" -> "1", "C" -> "2", "G" -> "3", "T" -> "4"}];
ListPlot[seq, Joined -> True, Mesh -> Full]
BarChart[seq]

enter image description here

POSTED BY: Nasser M. Abbasi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract