Nekrasov's formula and refined sheaf counting