Heart rate and heart rate variability are under the control of the autonomous nervous system. It can be assumed that during sleep internal influences dominate the autonomous nervous system. During the different sleep stages heart rate regulation differs in normal subjects. Obstructive sleep apnea is a disorder which has its origin in sleep and has strong modulating effects on the autonomous nervous system with prominent heart rate variations in consequence. In order to separate the influences of sleep stages and sleep apnea on heart rate variability we applied detrended fluctuation analysis in 12 healthy subjects and 20 patients with sleep apnea. We could show that the differences between sleep stages observed in healthy subjects were still present in subjects with sleep apnea despite their cyclical variation in heart rate. We conclude, that detrended fluctuation analysis is able to separate the influences of sleep stages and sleep apnea on heart rate variability.