Rattmann is never shown in any Portal game, although it is revealed he is still alive by Portal's conclusion. Instead he leaves "Rattmann's dens" which show mad scribblings and pictures, as well as scattered milk, beans, and water he used to keep himself nourished. He carries a Companion Cube with him at all times, for he suffers schizophrenia and uses it both to project his conscience and because he believes it to be his only "friend" in the facility.
He is revealed to have been the one who designed GLaDOS's morality core, but didn't believe it could fix her. As a result, he is very paranoid, and is found to be right when GLaDOS kills almost everyone in Aperture Laboratories, leaving only two known survivors, him and Chell, although it is possible that others were kept alive to be used as "test subjects" who have since perished.
Rattmann's dens are found scattered around the facility in hidden areas that GLaDOS never shows awareness of. Although he is never seen, the entire course of the game he's later to have been revealed spying on Chell as she makes her way through the test chambers. He has shown to have been a former test subject, and developed a very personal relationship with a companion cube that was eventually destroyed. He has a small memorial as well as dedicated poetry to the cube in a den found in chamber 17 (where Chell first meets the companion cube.) It is unknown how he had found another one, although it is true that companion cubes are mass produced.
He is also the origin of the "The cake is a lie" meme, spawned from a message left in one of his dens. The developers are apparently sick of the joke, but managed to stick one more reference to it in Portal: Lab Rat. The binary code on one of Chell's interview sheets in the comic translates to the infamous phrase.
Portal: Lab Rat
In this comic, Rattmann is revealed to have been the "link" that bridges Portal and Portal 2.
During the comic, the reader discovers that he has been spying on Chell, with GLaDOS still aware that he is alive, but never able to eliminate him. He had escaped along with his companion cube, which due to his mental illness can "talk" to him, and offers him helpful advice. Rattmann also carries only two pills; they can relieve him of his schizophrenia, but this will also silence his cube. He is also revealed to have been a former scientist who did not ever fully trust GLaDOS.
Rattmann firmly believes that Chell is "the one" and follows her until she defeats GLaDOS. Seeing that she has been taken outside, only to be dragged back in by the Party Escort Bot, Rattmann decides to try and rescue her, against his cubes advice. He takes his two pills, silencing his cube, and attempts to access the database, which is guarded by turrets. Upon finding her asleep in a cryo-room, another problem arises. The explosion caused by the fight with GLaDOS has knocked out power to the cryo-rooms, and all the sleepers will die without power. Again, against his Companion Cube's advice, he attempts to save Chell by sneaking past guard turrets. Unfortunately, the pills take full effect and his Companion Cube disappears leaving him with no advice on how to dodge the turrets. He is shot multiple times and loses consciousness. While unconscious he has a flashback to the day GlaDOS had killed the staff, and he was left alone on the run. He runs to the file room, looking for a test subject that might throw a wrench in GLaDOS's plans. He comes across Chell's file, and decides she is the one, moving her up in the testing order to "0001". When Doug reawakens, his Companion Cube has returned (an indication his medication has worn off) and tells him that while he might not be able to free Chell, he can save her. Rattmann crawls wounded to the reserve power station and reconnects the power to Chell's reservation unit, putting her in deep cryogenic storage (where she awakens in Portal 2.) Doug explains to his cube that he chose Chell based on a hunch. She's not the smartest or most athletic test subject, but is implied to be the most stubborn (she wouldn't answer any test questions, although it's left ambiguous whether she's a mute or just irritated by having to answer stupid questions.) He realizes that someone will have to wake her up eventually, and it's either the "long sleep... or the long sleep" and a slim chance of survival is better then death. He then finally goes to sleep in a bed, and is presumed dead.
By Portal 2, it is assumed that Rattmann has died, since the events of Portal 2 take place several hundred years after the first game, but Rattmann still left messages before he died. In the room where Chell finds the Portal gun, there are numerous "prophetic" illustrations of her that Ratmann was seen drawing in Lab Rat. Additionally, Ratmann's dens can be found in GLaDOS's test chambers, along with a radio playing The National's "Exile Vilify." (Some of the lyrics were also referenced in the comic.) It is assumed that Rattmann found a connection with this as the radio is accompanied with parts of the lyrics written on the wall. Additionally, there is a hidden area in which the radio changes frequency to display a series of sounds which, when deciphered, reveal an image of the Companion Cube on the moon.