immucellai2 2.1.17__tar.gz → 2.1.20__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.
- {immucellai2-2.1.17 → immucellai2-2.1.20}/PKG-INFO +1 -1
- {immucellai2-2.1.17 → immucellai2-2.1.20}/immucellai2/myfunction2.py +14 -81
- {immucellai2-2.1.17 → immucellai2-2.1.20}/immucellai2.egg-info/PKG-INFO +1 -1
- {immucellai2-2.1.17 → immucellai2-2.1.20}/setup.cfg +1 -1
- {immucellai2-2.1.17 → immucellai2-2.1.20}/README.md +0 -0
- {immucellai2-2.1.17 → immucellai2-2.1.20}/immucellai2/__init__.py +0 -0
- {immucellai2-2.1.17 → immucellai2-2.1.20}/immucellai2/myclasses.py +0 -0
- {immucellai2-2.1.17 → immucellai2-2.1.20}/immucellai2/myconfig/Celltype.category +0 -0
- {immucellai2-2.1.17 → immucellai2-2.1.20}/immucellai2/myconfig/MarkerUsedDeconvolution.txt +0 -0
- {immucellai2-2.1.17 → immucellai2-2.1.20}/immucellai2/myconfig/reference_normalCelltypes.txt +0 -0
- {immucellai2-2.1.17 → immucellai2-2.1.20}/immucellai2/myconfig/reference_tumorCelltypes.txt +0 -0
- {immucellai2-2.1.17 → immucellai2-2.1.20}/immucellai2/myfunction1.py +0 -0
- {immucellai2-2.1.17 → immucellai2-2.1.20}/immucellai2/myfunction3.py +0 -0
- {immucellai2-2.1.17 → immucellai2-2.1.20}/immucellai2/myfunction4.py +0 -0
- {immucellai2-2.1.17 → immucellai2-2.1.20}/immucellai2/myfunction5.py +0 -0
- {immucellai2-2.1.17 → immucellai2-2.1.20}/immucellai2.egg-info/SOURCES.txt +0 -0
- {immucellai2-2.1.17 → immucellai2-2.1.20}/immucellai2.egg-info/dependency_links.txt +0 -0
- {immucellai2-2.1.17 → immucellai2-2.1.20}/immucellai2.egg-info/entry_points.txt +0 -0
- {immucellai2-2.1.17 → immucellai2-2.1.20}/immucellai2.egg-info/requires.txt +0 -0
- {immucellai2-2.1.17 → immucellai2-2.1.20}/immucellai2.egg-info/top_level.txt +0 -0
- {immucellai2-2.1.17 → immucellai2-2.1.20}/pyproject.toml +0 -0
|
@@ -3,6 +3,7 @@ from .myclasses import CLASS_FOR_RUN
|
|
|
3
3
|
from .myfunction3 import ObtainCellTypeCateogry
|
|
4
4
|
import pandas
|
|
5
5
|
import os
|
|
6
|
+
import importlib.util
|
|
6
7
|
import re
|
|
7
8
|
import sys
|
|
8
9
|
import multiprocessing as mp
|
|
@@ -11,93 +12,25 @@ def Obtainmyconfigpath():
|
|
|
11
12
|
script_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
|
|
12
13
|
return os.path.join(script_dir, "immucellai2", "myconfig", "")
|
|
13
14
|
|
|
15
|
+
def get_package_dir(package_name):
|
|
16
|
+
spec = importlib.util.find_spec(package_name)
|
|
17
|
+
if spec is None:
|
|
18
|
+
raise ModuleNotFoundError(f"Package '{package_name}' not found")
|
|
19
|
+
path = spec.origin or spec.submodule_search_locations[0]
|
|
20
|
+
return os.path.dirname(path)
|
|
21
|
+
|
|
14
22
|
def SelectGeneForDeconvolution(DFReferenceProfile, FileCoveredGenes="", Method="UsedMarker"):
|
|
15
23
|
print("Select the gene for the following deconvolution...")
|
|
16
24
|
GeneUsedForDeconvolution = []
|
|
17
25
|
DFReferenceProfileGenes = DFReferenceProfile.index.values
|
|
18
|
-
print(f"[DEBUG] reference genes: {len(DFReferenceProfileGenes)}")
|
|
19
|
-
print(f"[DEBUG] head: {DFReferenceProfileGenes[:5]}")
|
|
20
|
-
|
|
21
26
|
if Method == "UsedMarker":
|
|
22
27
|
if FileCoveredGenes == "":
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
import immucellai2.myconfig
|
|
30
|
-
pkg_config_dir = os.path.dirname(immucellai2.myconfig.__file__)
|
|
31
|
-
pkg_marker_path = os.path.join(pkg_config_dir, "MarkerUsedDeconvolution.txt")
|
|
32
|
-
if os.path.exists(pkg_marker_path):
|
|
33
|
-
FileCoveredGenes = pkg_marker_path
|
|
34
|
-
print(f"[INFO] Found marker file in immucellai2 package: {FileCoveredGenes}")
|
|
35
|
-
except ImportError:
|
|
36
|
-
# ��ʽ2��ͨ��importlib.resources.files����������Դ�����ã�
|
|
37
|
-
try:
|
|
38
|
-
marker_resource = files("immucellai2.myconfig").joinpath("MarkerUsedDeconvolution.txt")
|
|
39
|
-
with as_file(marker_resource) as marker_path:
|
|
40
|
-
if marker_path.exists():
|
|
41
|
-
FileCoveredGenes = str(marker_path)
|
|
42
|
-
print(f"[INFO] Found marker file in immucellai2 package (resources API): {FileCoveredGenes}")
|
|
43
|
-
except Exception as e:
|
|
44
|
-
pass # ����������һ������
|
|
45
|
-
|
|
46
|
-
# ���ȼ�2���û��Զ��廷������������Դ������/�DZ���װ��
|
|
47
|
-
if FileCoveredGenes is None:
|
|
48
|
-
config_dir = os.getenv("IMMUCELLAI_CONFIG_DIR")
|
|
49
|
-
if config_dir:
|
|
50
|
-
env_marker_path = os.path.join(config_dir, "MarkerUsedDeconvolution.txt")
|
|
51
|
-
if os.path.exists(env_marker_path):
|
|
52
|
-
FileCoveredGenes = env_marker_path
|
|
53
|
-
print(f"[WARNING] Use marker file from env IMMUCELLAI_CONFIG_DIR: {FileCoveredGenes}")
|
|
54
|
-
|
|
55
|
-
# ���ȼ�3����ǰ����Ŀ¼�µ�myconfig�������ֶ�����
|
|
56
|
-
if FileCoveredGenes is None:
|
|
57
|
-
cwd_config_dir = os.path.join(os.getcwd(), "myconfig")
|
|
58
|
-
cwd_marker_path = os.path.join(cwd_config_dir, "MarkerUsedDeconvolution.txt")
|
|
59
|
-
if os.path.exists(cwd_marker_path):
|
|
60
|
-
FileCoveredGenes = cwd_marker_path
|
|
61
|
-
print(f"[WARNING] Use marker file from current directory: {FileCoveredGenes}")
|
|
62
|
-
|
|
63
|
-
# �������ȼ���ʧ�ܣ���ʾ�û�
|
|
64
|
-
if FileCoveredGenes is None:
|
|
65
|
-
print("[ERROR] Marker file 'MarkerUsedDeconvolution.txt' not found!")
|
|
66
|
-
print("Solutions for users:")
|
|
67
|
-
print(" 1. Install immucellai2 correctly: pip install --upgrade immucellai2")
|
|
68
|
-
print(" 2. Set environment variable: export IMMUCELLAI_CONFIG_DIR='/path/to/your/myconfig/'")
|
|
69
|
-
print(" 3. Put MarkerUsedDeconvolution.txt in ./myconfig/ (current working directory)")
|
|
70
|
-
return []
|
|
71
|
-
|
|
72
|
-
# ===== ͨ�û��ļ���ȡ�����ݸ�ʽ+³���� =====
|
|
73
|
-
try:
|
|
74
|
-
print(f"[DEBUG] getwd: {FileCoveredGenes}")
|
|
75
|
-
# ��iloc[1] �� iloc[:,0]����ȡ��һ�������У����䵥�б���ļ���
|
|
76
|
-
# ����error_bad_lines=False��������ʽ�������
|
|
77
|
-
df_marker = pd.read_table(
|
|
78
|
-
FileCoveredGenes,
|
|
79
|
-
sep="\t",
|
|
80
|
-
header=None,
|
|
81
|
-
error_bad_lines=False,
|
|
82
|
-
warn_bad_lines=True
|
|
83
|
-
)
|
|
84
|
-
# ��ȡ��һ�У�ȥ��+ȥ��+ת��д�����ݻ�������Сд��
|
|
85
|
-
GeneUsedForDeconvolution0 = df_marker.iloc[:, 0].astype(str).str.strip()
|
|
86
|
-
GeneUsedForDeconvolution0 = [gene.upper() for gene in GeneUsedForDeconvolution0 if gene and not gene.isdigit()]
|
|
87
|
-
GeneUsedForDeconvolution0 = list(set(GeneUsedForDeconvolution0)) # ȥ��
|
|
88
|
-
|
|
89
|
-
# �ο�������Ҳת��д��ȷ������ƥ��
|
|
90
|
-
DFReferenceProfileGenes_upper = [gene.upper() for gene in DFReferenceProfileGenes]
|
|
91
|
-
# ȡ����
|
|
92
|
-
GeneUsedForDeconvolution = list(set(GeneUsedForDeconvolution0) & set(DFReferenceProfileGenes_upper))
|
|
93
|
-
|
|
94
|
-
print(f"[DEBUG] marker genes head: {GeneUsedForDeconvolution0[:5]}")
|
|
95
|
-
print(f"Successfully loaded {len(GeneUsedForDeconvolution)} valid marker genes (total: {len(GeneUsedForDeconvolution0)})")
|
|
96
|
-
except Exception as e:
|
|
97
|
-
print(f"[ERROR] Failed to read marker file: {str(e)}")
|
|
98
|
-
print("Tips for users: Check if MarkerUsedDeconvolution.txt is in 'single-column, no header' format")
|
|
99
|
-
return []
|
|
100
|
-
|
|
28
|
+
pkg_marker_path = os.path.join(get_package_dir("immucellai2"), "myconfig/MarkerUsedDeconvolution.txt")
|
|
29
|
+
if os.path.exists(pkg_marker_path):
|
|
30
|
+
FileCoveredGenes = pkg_marker_path
|
|
31
|
+
print(f"[INFO] Found marker file in immucellai2 package: {FileCoveredGenes}")
|
|
32
|
+
GeneUsedForDeconvolution0 = (pandas.read_table(FileCoveredGenes, sep= "\t")).iloc[0].to_list()
|
|
33
|
+
GeneUsedForDeconvolution = list(set(GeneUsedForDeconvolution0).intersection(set(DFReferenceProfileGenes)))
|
|
101
34
|
return GeneUsedForDeconvolution
|
|
102
35
|
|
|
103
36
|
def CelltypeCategoryCheck(FileCellTypeCategory = "", celltypelist = [] ):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{immucellai2-2.1.17 → immucellai2-2.1.20}/immucellai2/myconfig/reference_normalCelltypes.txt
RENAMED
|
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
|