# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Produce a frequency chaos game representation image from a string of nucleotides

Contributed by:
Daniel Lichtblau

ResourceFunction["FCGRImage"][ gives the frequency chaos game representation (FCGR) image of a DNA nucleotide sequence | |

ResourceFunction["FCGRImage"][ gives the FCGR image at resolution 2 | |

ResourceFunction["FCGRImage"][ gives the FCGR image using a square with corners given by |

ResourceFunction["FCGRImage"][*str*] uses a default pixelation level of 7 and works with the square having "A" as the lower-right vertex, proceeding counterclockwise with "T", "G" and "C".

ResourceFunction["FCGRImage"][*str*,*k*] gives an image of dimension 2^{k}×2^{k}.

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 *str* are converted to upper case.

All characters in the converted input *str* other than {"A","C","G","T"} will be removed.

There is an "off-centered" asymmetry of the nucleotide positions from using grids that have side lengths of powers of 2. This will be illustrated in examples. It can be removed by enlarging the grids by one unit in each dimension.

By default, we do not remove the asymmetry. The body of literature on the FCGR gives no indication of doing this. Perhaps more importantly, empirical evidence suggests that results are better when working with the slightly off-centered version.

Create a "random" FCGR image using a pseudorandom string of nucleotides:

In[1]:= |

Out[3]= |

Show simple images using sequences of the same nucleotide repeated three times:

In[4]:= |

Out[4]= |

The off-center asymmetry seen above is perhaps more apparent when we use sequences of length four:

In[5]:= |

Out[5]= |

The asymmetry can be removed using the option setting "Centered"→True:

In[6]:= |

Out[6]= |

Select a human gene from the Wolfram Language curated data:

In[7]:= |

Show the Chaos Game Representation image for this gene:

In[8]:= |

Out[8]= |

Show this gene at higher levels of pixelation:

In[9]:= |

Out[9]= |

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

In[10]:= |

Out[10]= |

Select a human gene from the Wolfram Language curated data:

In[11]:= |

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

In[12]:= |

Out[12]= |

Reverse the order of the purines from the default ordering:

In[13]:= |

Out[13]= |

- ChaosGame–Wolfram Demonstrations Project
- ChaosGame–Wolfram MathWorld
- "Chaos Game Representation of gene structure"–Wolfram Community
- How to Plot a Gene Graph for a DNA Sequence Say ATGCGTCGTAACGT–Stack Overflow
- rallis GitHub–GenomicSignatures

Wolfram Language 11.3 (March 2018) or above

- 2.0.1 – 19 April 2022
- 2.0.0 – 14 November 2019

This work is licensed under a Creative Commons Attribution 4.0 International License