The movie Naked Lunch is not only an adaption of the book (which is already considered highly autobiographical), but also about what drove Burroughs to write it in the first place.
As such, it mixes the story of the book with facts from Burroughs' biography. Even more so than in the book, the William Lee of the movie is an alter ego of Burroughs himself.
Some important facts to make this clear:
- William Lee in the book is not an exterminator. The whole bug-powder subplot does not occur in the book. Burroughs on the other hand worked as an exterminator during his early years Chicago and was of course famously addicted to a variety of drugs.
- The whole killing-the-wife thing does not appear in the book. There is actually no indication in the book that Lee is married at all. Burroughs however killed his wife (who was called Joan, just like the wife in the movie) in a very similar manner as is depicted in the movie.
- Many of the events of the movie that happen after Joan is shot closely resemble the events of the book. Examples include the encounter with Dr. Benway and the investigations in Interzone.
- Still, the movie regularly reminds us that the majority of what we see only happens in William Lee's head. Just recall the scene when William carries around the pieces of his destroyed typewriter, which are eventually revealed to be empty liquor bottles.
- Furthermore, it is implied that Lee's main motivation for his actions is to seek redemption for Joan's death. Hence his desire to flee with Joan's doppelgänger from Interzone. However, since the whole Interzone business is just an elaborate hallucination, reality eventually catches up with William as he shoots Joan a second time.
- The bug creatures and Kiki's transformation are not present in the book and are a trademark of early films of David Cronenberg, the director of the movie. Take for example, the transformation of a man to a giant insect in The Fly, the body-modification technology and insectoid weapons in eXistenZ or the various body transformations endured by the protagonist of Videodrome. In Naked Lunch, they serve the purpose of underlining how the protagonist loses touch with reality and drifts into a nightmarish hallucination.
I personally favor the interpretation that the pages that the William Lee of the movie writes on his typewriter are the pages of the real-world book Naked Lunch. Just as Burroughs was lost in a state of drug-induced hallucination, paranoia and guilt when writing the book, so is the William Lee of the movie.
Rather than attempting a straight adaptation, Cronenberg took a few
elements from the book and combined them with elements of Burroughs'
life, creating a hybrid film about the writing of the book rather than
the book itself.
Disclaimer: It's been a while since I watched the movie and I only managed to read the book in excerpts due to its unique writing style. So apologies if this answer gets some of the finer details wrong.