Genes#

The module genes provides functions related to Genes section of cBioPortal Web Public API.

pybioportal.genes.fetch_genes(gene_ids, gene_id_type='ENTREZ_GENE_ID', projection='SUMMARY')#

Fetch genes by Entrez Gene IDs or Hugo Gene Symbols.

Parameters:
  • gene_ids (list of str) – List of Entrez Gene IDs or Hugo Gene Symbols (e.g., [“BRCA1”,”BRCA2”]).

  • gene_id_type (str) –

    Type of gene ID.

    Possible values:

    • ”ENTREZ_GENE_ID” (default): Entrez Gene IDs.

    • ”HUGO_GENE_SYMBOL”: Hugo Gene Symbols.

  • projection (str) –

    Level of detail of the response.

    Possible values:

    • ”DETAILED”: Detailed information.

    • ”ID”: Information with only IDs.

    • ”META”: Metadata information.

    • ”SUMMARY”: Summary information (default).

Returns:

A DataFrame containing genes based on the specified Entrez Gene IDs or Hugo Gene Symbols.

Return type:

pandas.DataFrame

pybioportal.genes.get_aliases_of_gene(gene_id)#

Get aliases of a gene by Entrez Gene ID or Hugo Gene Symbol.

Parameters:

gene_id (str) – Entrez Gene ID or Hugo Gene Symbol (e.g., “1” or “A1BG”).

Returns:

A DataFrame containing aliases for the specified gene.

Return type:

pandas.DataFrame

pybioportal.genes.get_all_genes(alias=None, direction='ASC', keyword=None, pageNumber=0, pageSize=10000000, projection='SUMMARY', sortBy='hugoGeneSymbol')#

Get all genes based on filter criteria (alias or keyword).

Parameters:
  • alias (str) – Alias of the gene.

  • direction (str) –

    Direction of the sort.

    Possible values:

    • ”ASC”: Ascending (default)

    • ”DESC”: Descending

  • keyword (str) – Search keyword that applies to hugo gene symbol of the genes.

  • pageNumber (int) –

    Page number of the result list.

    • Minimum value is 0.

  • pageSize (int) –

    Page size of the result list.

    • Minimum value is 1, maximum value is 10000000.

  • projection (str) –

    Level of detail of the response.

    Possible values:

    • ”DETAILED”: Detailed information.

    • ”ID”: Information with only IDs.

    • ”META”: Metadata information.

    • ”SUMMARY”: Summary information (default).

  • sortBy (str) –

    Name of the property that the result list is sorted by.

    Possible values:

    • ”cytoband”

    • ”entrezGeneId”

    • ”hugoGeneSymbol” (default)

    • ”length”

    • ”type”

Returns:

A DataFrame containing genes based on the specified filter criteria.

Return type:

pandas.DataFrame

pybioportal.genes.get_gene(gene_id)#

Get gene information by Entrez Gene ID or Hugo Gene Symbol.

Parameters:

gene_id (str) – Entrez Gene ID or Hugo Gene Symbol (e.g., “1” or “A1BG”).

Returns:

A DataFrame containing information about the specified gene.

Return type:

pandas.DataFrame


Examples#

from pybioportal import genes as gns
df1a = gns.get_all_genes(keyword = "BRCA1")
df1a
entrezGeneId hugoGeneSymbol type
0 394269 BRCA1P1 pseudogene
1 672 BRCA1 protein-coding
df1b = gns.get_all_genes(alias = "FANCS")
df1b
entrezGeneId hugoGeneSymbol type
0 672 BRCA1 protein-coding
df2 = gns.get_gene("BRCA1")
df2
entrezGeneId hugoGeneSymbol type
0 672 BRCA1 protein-coding
df3 = gns.get_aliases_of_gene("BRCA2")
df3
0
0 FAD1
1 FANCD1
2 XRCC11
df4 = gns.fetch_genes(gene_ids=["BRCA1","BRCA2"], gene_id_type = "HUGO_GENE_SYMBOL")
df4
entrezGeneId hugoGeneSymbol type
0 672 BRCA1 protein-coding
1 675 BRCA2 protein-coding