I Am Legend by Richard Matheson.
A bit of a rum cove, Robert Neville. Holed up in his house drinking whisky and obsessively sharpening bits of wood every night, by day he stalks the streets of Los Angeles breaking into people's houses and hammering wooden stakes into them. Well, you've got to have a hobby, haven't you?
And it's not like Neville can take up something more social like joining a book group, because he is the last man on earth. Or, at least, the last one unaffected by the wind- and insect-borne plague that has transformed the rest of the human race into something resembling vampires - pale-skinned, sensitive to daylight and garlic, active at night, and with a disturbing habit of biting people on the neck and sucking their blood. No, the book group idea is definitely out.
So Neville lives out a grim existence - roaming the city by day staking slumbering vampires, and skulking in his boarded-up house at night while they throw rocks and shout for him to come out. Eventually he decides that he really has got to find a hobby, and starts researching the possible origins of the plague, and conducting experiments on some of the vampires, both the living and the undead (there are both kinds) to try and work out how the disease works. He eventually concludes that it is some sort of blood-borne bacterium, so powerful that it can animate the human body in search of sustenance even after death.
Out roaming the city one day Neville finds himself not alone for once - a young woman, Ruth, is out walking in a field. He catches up with her and persuades her to come back to the house with him, where they talk, though Neville is still suspicious - is she immune or infected? Gradually the tension thaws, and after a brief sexual encounter Ruth agrees to undergo a blood test. While Neville is looking through his microscope at the results, she clouts him over the head with a mallet and escapes.
When he awakes he finds that she has left him an explanatory note - she was a spy sent by a group of infected people (living ones, the undead ones being just zombie-like automatons) who are trying to find treatments and possibly cures for the disease, but who have had loved ones killed in their beds by Neville, who they see as some sort of rampaging bogeyman who must be stopped at all costs. She urges him to flee before the death squads come for him, but it's too late - one day they do come, and, while slaughtering all the undead vampires, they capture Neville and imprison him.
Ruth comes to see Neville in his prison cell and illustrates the error of his perspective to him - it is the still living infected population who are the last hope of the human race, not him; he is just a savage leftover of a dead race who must be put down like a dog before he can do any more harm. In a last show of compassion she slips him a couple of suicide pills so he can at least escape being made a public spectacle of.
It's a brave man who tries to put a new spin on the old vampire legends - Bram Stoker's Dracula remains the definitive vampire story, but it doesn't attempt to address vampirism in any sort of scientific way, preferring to stick with the old tropes about vampires being able to shape-shift into giant hounds and bats and the like, as well as providing the source material for Bela Lugosi to deliver a couple of the greatest lines in movie history. Even more modern vampire novels like Stephen King's Salem's Lot adhere fairly closely to the supernatural explanations. I Am Legend makes a commendable attempt to ground the vampires' lifecycle and behaviour in the real world, though, which I suppose makes it more of a science fiction novel than a horror novel, assuming that those terms mean anything.
I Am Legend has been filmed three times, as The Last Man On Earth in 1964 (featuring a hilariously miscast Vincent Price as the protagonist), as The Omega Man in 1971 (featuring Charlton Heston in the second of his trio of science fiction appearances, between Planet Of The Apes and Soylent Green) and finally as I Am Legend in 2007 (featuring Will Smith). All of those films saw fit to mess with the basic storyline in one way or the other, the downbeat ending in particular - as with The Talented Mr Ripley, it was obviously decided that there was only so much that the cinema-going audience would put up with.
The post-apocalyptic setting echoes a few other books, for instance Cormac McCarthy's The Road and Stephen King's The Stand. King, who is a big fan of Matheson and wrote the afterword to my Gollancz SF Masterworks paperback edition, also stole pretty much wholesale the segment where Neville buries his wife Virginia and has her reappear, undead, on his doorstep, for the finale of Pet Sematary. The last-minute switch of viewpoint throwing all that has gone before into a new perspective is similar to the one at the end of William Golding's The Inheritors. Anyway, it's a miniature masterpiece (at only 160 pages), and you should read it.