Skip to content

Commit 4d495c4

Browse files
author
Dan-RAI
committed
misc
1 parent d46c07a commit 4d495c4

2 files changed

Lines changed: 49 additions & 4 deletions

File tree

python/PascalX/genescorer.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2053,4 +2053,40 @@ def score(self,gene,parallel=1,unloadRef=False,method='saddle',mode='auto',reqac
20532053
self._SCORES[X[0]] = float(X[1])
20542054

20552055

2056-
return R
2056+
return R
2057+
2058+
2059+
def _getMinSNP(self,cr,gene,REF):
2060+
2061+
RID = self._getSNPs(cr,gene,REF)
2062+
2063+
minp = 1
2064+
2065+
for R in RID:
2066+
p = self._GWAS[R]
2067+
2068+
if p < minp:
2069+
minp = p
2070+
2071+
return minp
2072+
2073+
def getMinSNPs(self):
2074+
"""
2075+
Returns dictionary with minimal GWAS p-value for gene
2076+
"""
2077+
RET = {}
2078+
REF = {}
2079+
for gid in self._GENEID:
2080+
cr = self._GENEID[gid][0]
2081+
2082+
# Load Reference panel
2083+
if not cr in REF:
2084+
REF = {}
2085+
REF[cr] = self._ref.load_pos_reference(cr)
2086+
2087+
minp = self._getMinSNP(cr,gid,REF)
2088+
2089+
RET[self._GENEID[gid][4]] = minp
2090+
2091+
return RET
2092+

python/PascalX/pathway.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def set_genescorer(self,S):
5353
"""
5454
self._genescorer = S
5555

56-
def load_modules(self,file,ncol=0,fcol=2):
56+
def load_modules(self,file,ncol=0,fcol=2,symbol=True):
5757
"""
5858
Load modules from tab separated file
5959
@@ -62,7 +62,7 @@ def load_modules(self,file,ncol=0,fcol=2):
6262
file(string): path/filename
6363
ncol(int): Column with name of module
6464
fcol(int): Column with first gene (symbol) in module. Remaining genes have to follow tab (\t) separated
65-
65+
symbol(bool): Genes are given as gene symbols (False requires genome to be set in genescorer)
6666
"""
6767
F = []
6868

@@ -72,7 +72,16 @@ def load_modules(self,file,ncol=0,fcol=2):
7272

7373
L = line.rstrip('\n').split("\t")
7474

75-
F.append([L[ncol],L[fcol:]])
75+
if symbol:
76+
F.append([L[ncol],L[fcol:]])
77+
else:
78+
G = L[fcol:]
79+
R = []
80+
for x in G:
81+
if x in self._genescorer._GENEID:
82+
R.append(self._genescorer._GENEID[x][-1])
83+
84+
F.append([L[ncol],R])
7685

7786
f.close()
7887

0 commit comments

Comments
 (0)