An example of metaphor and analogy in popular science writing:
"Imagine a written script for a play, or film, or television programme. It is perfectly possible for someone to read a script just as they would a book, But the script becomes so much more powerful when it is used to produce something. It becomes more than a string of words on a page when it is spoken aloud, or better yet, acted.
DNA is rather similar. It is the most extraordinary script. Using a tiny alphabet of just four letters it carries the code for organisms from bacteria to elephants, and from brewer's yeast to blue whales. "But DNA in a test tube is pretty boring. It does nothing. DNA becomes far more exciting when a cell or an organism uses it to stage a production. …
Thousands and thousands of regions of junk DNA are suspected to regulate networks of gene expression. They act like the stage directions for the genetic script, but directions of a complexity we could never envisage in the theatre."
Nessa Carey (2015) Junk DNA. A journey through the dark matter of the genome. London: Icon Books Ltd.
There are several different metaphors here. The alphabet of four letters (i.e., the four bases) and seeing the genome as carrying a 'code' (though both of these metaphors are so commonly used that they might be considered 'dead metaphors' – as many readers will already be familiar with these comparisons.).
To describe DNA as a script could also be seen as a metaphor. However the preamble about the nature of scripts sets this up as an analogy. An analogy has a mapping between parallel structural features of the target (here: DNA) and analogue (here: script).
So, again, by itself, the reference to DNA being used to 'stage a production' would be seen as a metaphor. However here it is an extension of the same metaphor, meant to be understood as part of an analogy: a script is used in staging a play or other production. In teaching, the teacher should make the mapping of the analogy explicit to learners: but here (in a more informal genre of science communication) the reader is expected to work out what the production refers to.
Read examples of scientific analogies
There is a linguistic problem in discussing DNA as it is not strictly, in a chemical sense, a substance, as (essentially!) each different type of DNA has a different molecular structure, so we might want to say that DNA is not one script but rather that each version of DNA is a distinct script.