To begin with there is no single best method. It is always depend on the data you have in hand.
"Gene Ontology enrichment analysis != Pathway analysis"
For a detailed explanation of GO term enrichment see this previous discussion at Biostars.
You mentioned that
"I am trying to identify common functions or pathways in a set of genes mutated in cancer samples."
I assume your data could have come from an genome/exome/transcriptome analysis workflow. If your list of genes are from an exome or genome workflow the approach discussed in the previous answers will be enough but you need to take care of few important things.
To do a pathway analysis you primarily need
- List of background genes
- List of perturbed genes,
- Annotation file that map each gene to a pathway
Now you have to be very careful when you define your background. If your data is from a tumor - normal pair your background should only contain the genes that are specific to the cell-line or tissue of your interest. Consult databases like HPRD/Human Protein Atlas to find cell/tissue specific genes. Once you have this data/files you can perform enrichment analysis (standard statistical test followed by multiple testing correction) using R to see significant pathways. You can use external tools only if they allow you to input a user-defined / experimental platform specific background.
If your data is from transcriptome/RNA-Seq you may use GOSeq: It uses a statistical approach developed specifically for RNA-seq data that can incorporate length or total count bias of RNA-Seq data into gene set tests.
If you are working with whole-genome level background you can use web-based tools like: Panther Pathways Reactome Pathways KEGG Pathway analysis using SubPathwayMiner or other R/BioC packages
You may also refer to a previous post here