well, first of all, think of it logically, sometimes when we awake from an intense dream we can remember it, and might even relive some parts, it could of just been memories from your nightmare.
if it is a spirit, try talking with it to see what it wants. if it wishes you harm, or you're afraid, ask the spirit to leave. if it refuses, the easiest thing would be to burn sage. if you have sea salt, place in on your windowsill. finally make a protection charm and hang it in you room to keep unwanted spirits out.