docs: def go_enrichment(df, enrichment='function', organism='Homo sapiens', summary=True, fdr=0.05, ids_from=['Proteins','Protein IDs']):
      """
      Calculate gene ontology (GO) enrichment for a specified set of indices, using the PantherDB GO enrichment service.
  
      Provided with a processed data ``DataFrame`` will calculate the GO ontology enrichment specified by `enrichment`,
      for the specified `organism`. The IDs to use for genes are taken from the field `ids_from`, which by default is
      compatible with both proteinGroups and modified peptide tables. Setting the `fdr` parameter (default=0.05) sets
      the cut-off to use for filtering the results. If `summary` is ``True`` (default) the returned ``DataFrame``
      contains just the ontology summary and FDR.
  
      :param df: Pandas ``DataFrame`` to
      :param enrichment: ``str`` GO enrichment method to use (one of 'function', 'process', 'cellular_location', 'protein_class', 'pathway')
      :param organism: ``str`` organism name (e.g. "Homo sapiens")
      :param summary: ``bool`` return full, or summarised dataset
      :param fdr: ``float`` FDR cut-off to use for returned GO enrichments
      :param ids_from: ``list`` of ``str`` containing the index levels to select IDs from (genes, protein IDs, etc.) default=['Proteins','Protein IDs']
      :return: Pandas ``DataFrame`` containing enrichments, sorted by P value.
      """
  
      if isinstance(df, pd.DataFrame) or isinstance(df, pd.Series):
          l = list(set(ids_from) & set(df.index.names))[0]
          data = "\n".join([get_protein_id(s) for s in df.index.get_level_values(l)])
      else:
          data = "\n".join([get_protein_id(s) for s in df])
  
      r = requests.post("http://www.pantherdb.org/webservices/garuda/tools/enrichment/VER_2/enrichment.jsp", data={
              'organism': organism,
              'type': 'enrichment',
              'enrichmentType': enrichment},
              files = {
              'geneList': ('genelist.txt', StringIO(data) ),
  
              }
          )
  
      try:
          go = pd.read_csv(StringIO(r.text), sep='\t', skiprows=5, lineterminator='\n', header=None)
      except ValueError:
          return None
  
      go.columns = ["GO", "Name", "Gene ID", "P", "FDR"]
      go = go.set_index(["GO", "Name"])
      if summary:
          go = go.drop("Gene ID", axis=1).mean(axis=0, level=["GO","Name"])
  
      if fdr:
          go = go[ go["P"] < fdr ]
  
      return go.sort_values(by="P", ascending=True)