New Yorkers’ drug tests come back cleaner than the rest of the country — except when it comes to deadly opiates.

The rates for testing positive for heroin were higher in New York state last year than they were nationally, according to new data from lab testing company Quest Diagnostics.

The metabolite that indicates recent heroin use — 6-acetylmorphine — was present in .026 percent of New Yorkers’ tests, higher than the .019 percent national rate.

PCP, or Angel Dust, was also prevalent in New Yorkers’ urine, blood and saliva at a higher rate than the US average — .015 percent, compared to .01 percent nationally.

Amid a wave of recreational marijuana legalization, passed in 10 states so far, Quest found drugs in 4.4 percent of 10 million tests taken across the country last year, a 14-year high. But New York’s overall positivity rate was only 3.5 percent.

While lower than the national rate, it was a slight increase over its 2007 rate of 3.2 percent.

The Bronx and Manhattan had the highest overall positivity rates by ZIP code (3.5 to 4.5 percent), followed by Staten Island and parts of southern Queens (both at 2.5 to 3.5 percent). The rest of Queens and Brooklyn had the lowest rates (0 to 2.5 percent).