3 answers
You could use qusage http://clip.med.yale.edu/qusage/. This is a Bioconductor package and is easy to use with R.
You could also use the piano: http://www.bioconductor.org/packages/release/bioc/html/piano.html. This is also a Bioconductor package and easy to use.
Go through the manuals and try to follow steps with the given examples.
You can also use MSigDB gene set data with the gene set tools in the limma package (also found in edgeR package if you are analyzing NGS data using GLMs). Tools like camera(), roast(), romer(), etc., all can use gene sets, like those defined in MSigDB. You can download MSigDB gene sets in an R friendly format from the limma/edgeR developer's website here. Take a look at help("10.GeneSetTests") in the limma documentation. Some examples are shown also in the limma and edgeR user's guide.
another option in R is using clusterProfiler package.
Log in to answer this question.