(Here, the phrase ‘a ghost in the bed’ answers the question ‘what?’. It is the object of the verb ‘saw’. Hence, it is acting as a noun.)

Sometimes aclause can perform the role of a noun in a sentence.

For example:

He saw that you were hiding from your wife.

(Here, the clause ‘that you were hiding from your wife’ acts as the object of the verb ‘saw’. You can ask the question ‘He saw what?’ and get the clause as the answer. Hence, in this sentence, the clause acts as a noun.)