-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunSCNLP.py
More file actions
executable file
·57 lines (51 loc) · 1.61 KB
/
RunSCNLP.py
File metadata and controls
executable file
·57 lines (51 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 5 17:08:37 2020
@author: smith
"""
import os
os.chdir("/home/smith/scNLP/")
from config.PubMedScraperUtils import *
import singleCellNLP as scn
from scipy import stats
import statsmodels.api as sm
# If you want to update the manifest file first:
clu = int(cluster.strip('Cluster'))
clusters = ["Cluster" + str(x) for x in range(clu)]
maniDf = scn.updateManifest(clusters, rettype="full")
# Run NLP on current cluster:
scn.runNLP(cluster, rettype="full", n_genes=25, copy=False, dlProcesses=3)
# Downstream analysis:
category = "Physio" # NER recognized categories: Physio, Label (region), NT, CellType
#types = scn.concatFrequencies(clusters, category=category, save=True)
types = scn.concatFrequencies(clusters, category=category, save=True)
catTypes = scn.filterConcatFrequencies(
types, category=category, min_count=50, save=True
)
cat = pd.DataFrame()
for cluster in clusters:
min_count = 300
lz = scn.findUpregulatedEntities(cluster, category=category, min_count=min_count)
resDf = pd.DataFrame(lz)
resDf.columns = [
cluster + " term",
cluster + "_pvalue",
cluster + "_corrected_p",
cluster + "_oddsratio",
]
resDf = resDf.loc[resDf[cluster + "_oddsratio"] > 1.0]
resDf = resDf.sort_values(by=cluster + "_corrected_p", ascending=True)
cat = pd.concat([cat, resDf], axis=1)
cat.to_excel(
os.path.join(
resultDirectory,
"Combined_Clusters_Enriched_"
+ category
+ "_"
+ comparison
+ "_minCount"
+ str(min_count)
+ ".xlsx",
)
)