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.
Files changed (36) hide show
  1. {scanpex-0.3.2 → scanpex-0.3.4}/PKG-INFO +1 -1
  2. {scanpex-0.3.2 → scanpex-0.3.4}/pyproject.toml +1 -1
  3. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/sq/__init__.py +2 -0
  4. scanpex-0.3.4/src/scanpex/sq/_ensembl_mapper.py +63 -0
  5. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/tl/_degs.py +1 -1
  6. {scanpex-0.3.2 → scanpex-0.3.4}/AUTHORS.rst +0 -0
  7. {scanpex-0.3.2 → scanpex-0.3.4}/LICENSE +0 -0
  8. {scanpex-0.3.2 → scanpex-0.3.4}/README.md +0 -0
  9. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/__init__.py +0 -0
  10. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/ft/__init__.py +0 -0
  11. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/ft/_gene_list.py +0 -0
  12. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/ml/__init__.py +0 -0
  13. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/ml/lightgbm_args/__init__.py +0 -0
  14. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/__init__.py +0 -0
  15. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/_curate_phase.py +0 -0
  16. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/_gene_list.py +0 -0
  17. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/_scrublet.py +0 -0
  18. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/_subplots.py +0 -0
  19. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/_umap.py +0 -0
  20. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/ml_evaluation/__init__.py +0 -0
  21. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/ml_evaluation/_pr.py +0 -0
  22. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/ml_evaluation/_roc.py +0 -0
  23. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pl/preferences/__init__.py +0 -0
  24. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pp/__init__.py +0 -0
  25. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pp/_metrics.py +0 -0
  26. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/pp/_scrublet.py +0 -0
  27. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/sns/__init__.py +0 -0
  28. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/sns/_catlollipop.py +0 -0
  29. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/sns/_lollipop.py +0 -0
  30. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/sns/_vinswarm.py +0 -0
  31. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/sq/_gene_cache_mgr.py +0 -0
  32. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/sq/_gene_query.py +0 -0
  33. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/sq/_xor.py +0 -0
  34. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/tl/__init__.py +0 -0
  35. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/tl/_gene_score.py +0 -0
  36. {scanpex-0.3.2 → scanpex-0.3.4}/src/scanpex/tl/_seacells.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scanpex
3
- Version: 0.3.2
3
+ Version: 0.3.4
4
4
  Summary: ScanPy Extension and kwarg Preferences
5
5
  License-File: AUTHORS.rst
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "scanpex"
3
- version = "0.3.2"
3
+ version = "0.3.4"
4
4
  description = "ScanPy Extension and kwarg Preferences"
5
5
  authors = ["yo-aka-gene <yujiokano@keio.jp>"]
6
6
  readme = "README.md"
@@ -1,8 +1,10 @@
1
+ from ._ensembl_mapper import ensembl_mapper
1
2
  from ._gene_cache_mgr import GeneCacheManager
2
3
  from ._gene_query import gene_query
3
4
  from ._xor import xor
4
5
 
5
6
  __all__ = [
7
+ "ensembl_mapper",
6
8
  "gene_query",
7
9
  "GeneCacheManager",
8
10
  "xor",
@@ -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")
@@ -1,4 +1,4 @@
1
- import anndat as ad
1
+ import anndata as ad
2
2
  import numpy as np
3
3
 
4
4
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes