scanpex 0.3.2__tar.gz → 0.3.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {scanpex-0.3.2 → scanpex-0.3.4}/PKG-INFO +1 -1
- {scanpex-0.3.2 → scanpex-0.3.4}/pyproject.toml +1 -1
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/sq/__init__.py +2 -0
- scanpex-0.3.4/src/scanpex/sq/_ensembl_mapper.py +63 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/tl/_degs.py +1 -1
- {scanpex-0.3.2 → scanpex-0.3.4}/AUTHORS.rst +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/LICENSE +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/README.md +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/__init__.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/ft/__init__.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/ft/_gene_list.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/ml/__init__.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/ml/lightgbm_args/__init__.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/__init__.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/_curate_phase.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/_gene_list.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/_scrublet.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/_subplots.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/_umap.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/ml_evaluation/__init__.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/ml_evaluation/_pr.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/ml_evaluation/_roc.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/preferences/__init__.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pp/__init__.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pp/_metrics.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pp/_scrublet.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/sns/__init__.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/sns/_catlollipop.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/sns/_lollipop.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/sns/_vinswarm.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/sq/_gene_cache_mgr.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/sq/_gene_query.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/sq/_xor.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/tl/__init__.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/tl/_gene_score.py +0 -0
- {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/tl/_seacells.py +0 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
import pandas as pd
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def ensembl_mapper(
|
|
7
|
+
ensembl_list: List[str],
|
|
8
|
+
species: str = "human",
|
|
9
|
+
) -> pd.DataFrame:
|
|
10
|
+
"""Map a list of Ensembl gene IDs to their corresponding gene symbols.
|
|
11
|
+
|
|
12
|
+
This function queries the MyGene.info API to translate Ensembl IDs into
|
|
13
|
+
gene symbols. If a gene symbol cannot be found for a given ID, the original
|
|
14
|
+
Ensembl ID is retained in the 'symbol' column. Duplicate queries are dropped,
|
|
15
|
+
keeping only the first matched record.
|
|
16
|
+
|
|
17
|
+
Parameters
|
|
18
|
+
----------
|
|
19
|
+
ensembl_list : List[str]
|
|
20
|
+
A list of Ensembl gene IDs to be mapped (e.g., ['ENSG00000139618']).
|
|
21
|
+
species : str, optional
|
|
22
|
+
The species name or taxonomy ID to restrict the query. Common values
|
|
23
|
+
include 'human' or 'mouse'. Default is 'human'.
|
|
24
|
+
|
|
25
|
+
Returns
|
|
26
|
+
-------
|
|
27
|
+
pd.DataFrame
|
|
28
|
+
A pandas DataFrame containing two columns:
|
|
29
|
+
- 'query': The original Ensembl ID.
|
|
30
|
+
- 'symbol': The mapped gene symbol (or the original ID if unmapped).
|
|
31
|
+
|
|
32
|
+
Raises
|
|
33
|
+
------
|
|
34
|
+
ImportError
|
|
35
|
+
If the `mygene` package is not installed in the current environment.
|
|
36
|
+
|
|
37
|
+
Examples
|
|
38
|
+
--------
|
|
39
|
+
>>> ensembl_ids = ["ENSG00000139618", "ENSG00000157764", "INVALID_ID"]
|
|
40
|
+
>>> df = ensembl_mapper(ensembl_ids, species="human")
|
|
41
|
+
>>> print(df)
|
|
42
|
+
query symbol
|
|
43
|
+
0 ENSG00000139618 BRCA2
|
|
44
|
+
1 ENSG00000157764 BRAF
|
|
45
|
+
2 INVALID_ID INVALID_ID
|
|
46
|
+
"""
|
|
47
|
+
try:
|
|
48
|
+
import mygene
|
|
49
|
+
except ImportError:
|
|
50
|
+
raise ImportError(
|
|
51
|
+
"mygene is not installed. Please install it using `pip install mygene`."
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
mg = mygene.MyGeneInfo()
|
|
55
|
+
gene_symbols = mg.querymany(
|
|
56
|
+
ensembl_list,
|
|
57
|
+
scopes="ensembl.gene",
|
|
58
|
+
fields="symbol",
|
|
59
|
+
species=species,
|
|
60
|
+
as_dataframe=True,
|
|
61
|
+
).reset_index()[["query", "symbol"]]
|
|
62
|
+
gene_symbols["symbol"] = gene_symbols["symbol"].fillna(gene_symbols["query"])
|
|
63
|
+
return gene_symbols.drop_duplicates(subset=["query"], keep="first")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|