Matt Damon, starring as an astronaut and disco hater. (Giles Keyte/Twentieth Century Fox)

(This post contains spoilers about the end of “The Martian.”)

If you saw “The Martian” over the weekend, which opened No. 1 at the box office with $55 million, you probably didn’t expect to leave the theater with “I Will Survive” stuck in your head. And yet that may have happened, as the movie ends on a particularly joyful note and the music matches.

That appeared to be the intent behind all of the movie’s musical tracks, primarily its retro disco hits, which are drawing comparisons to last summer’s addictive “Guardians of the Galaxy” soundtrack. (The music plot was the same in the original novel, though, years before “Guardians” was released.) Although some of the songs in “The Martian” might seem a tad too literal, producers say that was intentional — to fit every important moment.

“The music was always there for comic relief or for some sarcasm,” editor Pietro Scalia told Billboard. “The [songs] are played with irony and were perfectly chosen.”

Here are the top five musical moments from the film:

1) “Hot Stuff” by Donna Summer

A minor plot thread throughout the movie is that as astronaut Mark Watney (Matt Damon) is stuck on Mars, his misery is compounded by the fact that the only music available to him is courtesy of his commander, Melissa Lewis (Jessica Chastain) — and it’s all disco. He pokes fun at her taste as he keeps his video journal, but he eventually breaks down and has a minor dance party to “Hot Stuff” in the rover — particularly as he finds a way to increase the temperature on the freezing planet using a nuclear reactor.

2) “Turn the Beat Around” by Vickie Sue Robinson

Again, Mark’s hatred of disco music helps give the film some lighter moments when he’s already in the worst possible situation of his life. Damon gives perfectly tortured looks when this classic comes on through the speakers.

3) “Love Train” by the O’Jays

Corny? Perhaps — but the whole world literally did come together, as China helped bring Mark home with the help of its own space technology. It was the ideal song at the end of the movie as the camera panned to the many people who pitched in to rescue Mark from Mars.

4) “Happy Days”

That theme song gets Mark through some slow nights as he mulls how to escape Mars, and the Fonz’s cheerful comedy is a hilarious contrast to Mark’s miserable state of affairs.

5) “I Will Survive” by Gloria Gaynor

Okay, technically, this was in the end credits, but it’s still a perfect way to wrap up the film as Mark indeed makes it out of Mars after a harrowing journey. It did take all the strength he had not to fall apart. Plus, the lyrics actually include the words “outer space,” which is even more fitting.

Read more:

Review: Stirring and amusing, ‘The Martian’ defines what’s best about Big Movies

‘The Martian’ isn’t just a great movie. It’s an important movie.

Science sells: ‘The Martian’ lands with $55 million debut