Firstly, I try never to use the shoulder. The shoulder is about as safe as cycling on the sidewalk - in other words, very unsafe.
About the only times I don't take the lane are when I want to clear the road behind me for some reason, or when the lane is very wide so that cars can pass safely within the same lane. In every other situation, I try to use up enough of the road so that cars can't pass within the same lane.