Lots of great opinions here. One thing you might want to remember though. Chances are it's going to be at night in a dimly lit or dark house. The muzzle blast from any gun under those conditions create immediate debilitating conditions for the shooter. (I really don't care about the intruder.) First, you will be immediately blinded. Second, you will no long have your sense of hearing. Those are the facts.
With that knowledge, you had better select a weapon with which you have extreme confidence in and one with which you practice a lot at the range. Common sense, right? Most folks that have a gun for home defense rarely use it unfortunately. Something to think about.
My selection is a short, double barreled 12 ga. loaded with low base 7 1/2's. If you ever shot this load at a paper target at 10 yards, you'd know why. Quite a devastating machine. You will also be very nervous under these stressful conditions and pointing a shotgun is much more effective than aiming a pistol. I know there are some good pistoleros out there, but most are not. And unless you are visiting the range at least once a week, you are not as good as you think you are.
The shotgun stacks the odds in your favor. And the above load reduces the chances of bullets or large pellets leaving your premises and harming someone outside your home. JMO.