Wolfram Research

FCGRImage

Contributed by: Daniel Lichtblau

Source Notebook

Produce a Frequency Chaos Game Representation image from a string of nucleotides

ResourceFunction["FCGRImage"][str]

gives the Frequency Chaos Game Representation image of a DNA nucleotide sequence str comprised of the characters “A”, “T”, “G”, and “C”.

ResourceFunction["FCGRImage"][str,k]

gives the FCGR image at resolution 2k.

ResourceFunction["FCGRImage"][str,k, bases]

gives the FCGR image using a square with corners given by bases, beginning at the lower right and proceeding counter-clockwise.

Details and Options

ResourceFunction["FCGRImage"][str] uses a default pixelation level of 7 and works with the square having “A” as the lower right vertex, proceeding counter-clockwise with “T”, “G”, and “C”.
ResourceFunction["FCGRImage"][str,k] gives an image of dimension 2k×2k.
For ResourceFunction["FCGRImage"][str,k,bases], the third argument must be a permutation of the list {"A","C","G","T"}.
Any occurrence of the character “U” in str is converted to “T”.
All characters in the converted input str other than {"A","C","G","T"} will be removed.

Examples

Basic Examples

Select a human gene from the Wolfram Language curated data:

In[1]:=
gene = GenomeData["SCNN1A", "FullSequence"];

Show the Chaos Game Representation image for this gene:

In[2]:=
ResourceFunction["FCGRImage"][gene]
Out[55]=

Scope

Show this gene at higher levels of pixelation:

In[56]:=
ResourceFunction["FCGRImage"][gene, 8]
Out[57]=

One may observe a fractal nature to these, with similarities appearing as the resolution level is increased:

In[58]:=
ResourceFunction["FCGRImage"][gene, 9]
Out[59]=

Compute the image with respect to a square having the purines positioned at the bottom vertices and the pyrimidines at the top:

In[60]:=
ResourceFunction["FCGRImage"][gene, 8, {"A", "G", "C", "T"}]
Out[61]=

Reverse the order of the purines from the default ordering:

In[62]:=
ResourceFunction["FCGRImage"][gene, 8, {"G", "T", "A", "C"}]
Out[63]=

Resource History

Source Metadata