Skip to content

Commit 9f2e538

Browse files
author
Adetunji
committed
fixed gene names and signal files
1 parent 589fdaa commit 9f2e538

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

bin/ROSE_geneMapper.py

+5-17
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def mapEnhancerToGene(annotFile,enhancerFile,transcribedFile='',uniqueGenes=True
7373
geneToEnhancerTable = [['GENE_NAME','REFSEQ_ID','PROXIMAL_STITCHED_PEAKS']]
7474

7575
#have all information
76-
signalWithGenes = [['GENE_NAME', 'REFSEQ_ID','PROXIMAL_STITCHED_PEAKS', 'SIGNAL']]
76+
signalWithGenes = [['GENE_NAME', 'REFSEQ_ID', 'PROXIMAL_STITCHED_PEAKS', 'SIGNAL']]
7777

7878
for line in enhancerTable[6:]:
7979

@@ -129,14 +129,6 @@ def mapEnhancerToGene(annotFile,enhancerFile,transcribedFile='',uniqueGenes=True
129129

130130
#get absolute distance to enhancer center
131131
distList = [abs(enhancerCenter - startDict[geneID]['start'][0]) for geneID in allEnhancerGenes]
132-
#get the ID and convert to name
133-
#print enhancerCenter - startDict[geneID]['start'][0]
134-
#print distList.index(min(distList))
135-
#print min(distList)
136-
#print len(distList)
137-
#print len(allEnhancerGenes[distList.index(min(distList))])
138-
#print line
139-
#print len(startDict[allEnhancerGenes[distList.index(min(distList))]])
140132
closestGene = startDict[allEnhancerGenes[distList.index(min(distList))]]['name']
141133

142134
#NOW WRITE THE ROW FOR THE ENHANCER TABLE
@@ -145,9 +137,6 @@ def mapEnhancerToGene(annotFile,enhancerFile,transcribedFile='',uniqueGenes=True
145137
if byRefseq:
146138
newEnhancerLine.append(','.join(ROSE_utils.uniquify([x for x in overlappingGenes])))
147139
newEnhancerLine.append(','.join(ROSE_utils.uniquify([x for x in proximalGenes])))
148-
#print newEnhancerLine
149-
#print len(allEnhancerGenes)
150-
#print distList
151140
closestGene = allEnhancerGenes[distList.index(min(distList))]
152141
newEnhancerLine.append(closestGene)
153142
else:
@@ -157,20 +146,21 @@ def mapEnhancerToGene(annotFile,enhancerFile,transcribedFile='',uniqueGenes=True
157146
newEnhancerLine.append(closestGene)
158147

159148

149+
#WRITE GENE TABLE
150+
signalWithGenes.append([startDict[closestGene]['name'], closestGene, enhancerString, enhancerSignal])
151+
160152
newEnhancerLine += line[-2:]
161153
enhancerToGeneTable.append(newEnhancerLine)
162154
#Now grab all overlapping and proximal genes for the gene ordered table
163155

164156
overallGeneList +=overlappingGenes
165157
for refID in overlappingGenes:
166158
geneDict['overlapping'][refID].append(enhancerString)
167-
geneDict['enhancerString'][enhancerString].append(enhancerSignal)
168-
159+
169160

170161
overallGeneList+=proximalGenes
171162
for refID in proximalGenes:
172163
geneDict['proximal'][refID].append(enhancerString)
173-
geneDict['enhancerString'][enhancerString].append(enhancerSignal)
174164

175165

176166
#End loop through
@@ -197,8 +187,6 @@ def mapEnhancerToGene(annotFile,enhancerFile,transcribedFile='',uniqueGenes=True
197187
newLine = [geneName,refID,','.join(proxEnhancers)]
198188

199189

200-
for eachEnhancer in proxEnhancers:
201-
signalWithGenes.append([geneName,refID,eachEnhancer,ROSE_utils.uniquify(geneDict['enhancerString'][eachEnhancer])[0]])
202190
geneToEnhancerTable.append(newLine)
203191

204192
#re-sort enhancerToGeneTable

0 commit comments

Comments
 (0)