It was both, actually! Mary Shelley was in a competition with four other writers to come up with the best horror story, and the idea for the story came from a dream she had about a scientist who was horrified with his creation. I didn't get much time to research the editorial process on the novel, but I am not surprised to learn that it went through a lot of different passes.