diff --git a/python/PascalX/__init__.py b/python/PascalX/__init__.py index 1519339..51c8ba8 100755 --- a/python/PascalX/__init__.py +++ b/python/PascalX/__init__.py @@ -1,2 +1,2 @@ -__version__ = "0.0.3" +__version__ = "0.0.4" diff --git a/python/PascalX/genescorer.py b/python/PascalX/genescorer.py index c9a2035..090d589 100755 --- a/python/PascalX/genescorer.py +++ b/python/PascalX/genescorer.py @@ -225,7 +225,7 @@ def load_GWAS(self,file,rscol=0,pcol=1,bcol=None,a1col=None,a2col=None,delimiter if log10p: p = 10**(-p) - if p > 0 and p < 1: + if p > 0 and p < 1 and L[rscol][:2]=='rs': self._GWAS[L[rscol]] = p else: continue @@ -706,12 +706,11 @@ def _calcGeneSNPcorr(self,cr,gene,REF,useAll=False): else: if gene in self._MAP: P = set(REF[str(cr)][0].getSNPsPos(list(self._MAP[gene].keys()))) - useAll = True else: P = [] DATA = REF[str(cr)][0].get(list(P)) - + filtered = {} #use = [] @@ -763,7 +762,6 @@ def _calcGeneSNPcorr_wAlleles(self,cr,gene,REF,useAll=False): else: if gene in self._MAP: P = set(REF[str(cr)][0].getSNPsPos( list(self._MAP[gene].keys()) )) - useAll = True else: P = [] @@ -809,8 +807,11 @@ def _getChi2Sum_mapper(self,RIDs,gene): ps = np.zeros(len(RIDs)) for i in range(0,len(ps)): #ps = chi2.ppf(1- np.array([GWAS[x] for x in RIDs]),1) - if RIDs[i] in self._MAP[gene]: + if RIDs[i] in self._MAP[gene] and self._MAP[gene][RIDs[i]][0] is not None: ps[i] = tools.chiSquared1dfInverseCumulativeProbabilityUpperTail(self._MAP[gene][RIDs[i]][0]) + else: + ps[i] = tools.chiSquared1dfInverseCumulativeProbabilityUpperTail(self._GWAS[RIDs[i]]) + return np.sum(ps) def _getChi2Sum(self,RIDs): @@ -942,8 +943,11 @@ def _scoremain(self,gene,unloadRef=False,method='saddle',mode='auto',reqacc=1e-1 if len(R) == 1: if self._MAP is not None and self._joint == False: - if R[0] in self._MAP[G[i]]: + if R[0] in self._MAP[G[i]] and self._MAP[G[i]][R[0]][0] is not None: RESULT.append( [self._GENEIDtoSYMB[G[i]],float(self._MAP[G[i]][R[0]][0]),1] ) + else: + RESULT.append( [self._GENEIDtoSYMB[G[i]],float(self._GWAS[R[0]]),1] ) + else: RESULT.append( [self._GENEIDtoSYMB[G[i]],float(self._GWAS[R[0]]),1] ) else: diff --git a/python/PascalX/mapper.py b/python/PascalX/mapper.py index acbb354..3d1e2fd 100755 --- a/python/PascalX/mapper.py +++ b/python/PascalX/mapper.py @@ -63,6 +63,7 @@ def load_mapping(self,file,gcol=0,rcol=1,wcol=None,a1col=None,a2col=None,bcol=No f.readline() c = 0 + s = 0 for line in f: line = line.rstrip().split(delimiter) @@ -99,5 +100,7 @@ def load_mapping(self,file,gcol=0,rcol=1,wcol=None,a1col=None,a2col=None,bcol=No self._SNPtoGENEID[line[rcol]] = [gid] else: self._SNPtoGENEID[line[rcol]].append(gid) + + s += 1 - print(c,"gene to SNP mappings loaded") \ No newline at end of file + print(c,"gene to SNP mappings loaded (# SNPs: "+str(s)+")") \ No newline at end of file