Statins are now very widely used by the NHS
Scientists have pinpointed a gene mutation as a major cause of a rare side effect of the cholesterol-lowering drugs statins.
They hope the discovery could lead to a simple test to identify patients at increased risk of myopathy - severe muscle pain and weakness.
This would also enable higher doses of statins to be safely prescribed to patients not at risk of the condition.
The University of Oxford study appears in the New England Journal of Medicine.
Statins are now widely prescribed in the UK and are credited with saving almost 10,000 lives a year in England alone.
The researchers, funded by the British Heart Foundation (BHF), found a variation in the DNA code of a gene called SLC01B1 was responsible for 60% of the myopathy cases in people taking high dose statin therapy.
SLC01B1 regulates the uptake of statins into the liver, and the genetic variant seems to affect its function, causing higher levels of the statin to be present in the blood.
Only about one in 10,000 patients taking a standard dose of statins develops myopathy, and the risk remains very low even if they carry the rogue gene.
However, the risk of myopathy for patients taking higher doses of statins - because they are at greater risk of heart attack or stroke - jumps to around one in 1,000. If they are taking other medications which can react with statins the risk can be as high as one in 100.
The researchers found that patients on the higher dose who carry one copy of the rogue gene were more than four times more likely to develop myopathy than those without a copy.
And for patients who carried two copies of the rogue gene - one from each parent - the risk was increased 16 times.
Around one in four people carries either one or two copies of the key genetic variant.
Myopathy is usually completely reversible by a change of prescription. However, very occasionally the muscle begins to break down, which can cause kidney failure and sometimes death.
Lead researcher Professor Rory Collins said: "We believe that this is the first time anyone has scanned the complete human genome for the genetic culprit of a drug's side effect.
"A DNA test based on these findings could guide doctors as to whether a patient at high risk of heart disease will cope with a high dose of a statin, which might be more effective than a standard dose at preventing a heart attack or stroke.
"If the patient doesn't have the gene variation, they are likely to be at low risk of myopathy even on high statin dose."
Professor Peter Weissberg, BHF medical director, said the study was a good example of the emerging field of pharmacogenomics - the use of genetic information to guide safer drug prescribing.
He said statin-induced myopathy was very rare and reversible if the symptoms are recognised and the drug is stopped, so it would not be necessary to screen all people prescribed usual doses.
But he added: "This approach will help us to optimise treatments to prevent heart attacks and strokes in individuals at high risk."