It depends on a lot of variables. Namely what do you intend to do?
Hunkering down in a bedroom is way different than clearing your house.
In the case of one or two intruders, who manage to get past one American bulldog, a 90lb Lab, and a mean as hell Cocker Spaniel (yes really), plus alarm system.....
I'll clear the house with my .45 and the wife will stay in the bedroom with a 12 gauge. From our room the upstairs hall is covered from her vantage point. Intruder would have to get past me then her to get to our daughter.
I prefer the .45 because I feel it's more maneuverable and can't be yanked out of my hands if they managed to get close. I can open doors and still be in low ready position, with a long arm that's hard to do.
I'm in the country and have no neighbors so penetration is not a concern for me so I could choose any weapon. If my choice (which i couldn't, not my nature) was to bunker down I'm going with the AR.
Home invasion I'd be handicapped to my 9mm I carry at all times and my wife has her .380 also. Shot gun at back door for either one of us that gets to it. Can't really plan that scenario very well, but once again the dogs would buy us some time, your not going to sneak up on us, lol.
Main thing is have one or two and train with them. Like they say, I carry a gun because a cop is to heavy. Seriously though, out here the sheriff is 20 minutes away and we've been told to "defend yourself, we will handle the paperwork"
Molon Labe. Defend your 2A rights.