@sjcrh/proteinpaint-server 2.86.0 → 2.87.0
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.
- package/package.json +6 -10
- package/routes/_template_.js +1 -1
- package/routes/brainImaging.js +2 -9
- package/routes/burden.js +1 -1
- package/routes/dataset.js +1 -1
- package/routes/dsdata.js +1 -1
- package/routes/dzimages.js +1 -1
- package/routes/gdc.maf.js +2 -2
- package/routes/gdc.mafBuild.js +2 -2
- package/routes/gdc.topMutatedGenes.js +1 -1
- package/routes/genelookup.js +1 -1
- package/routes/genesetEnrichment.js +5 -3
- package/routes/genesetOverrepresentation.js +1 -1
- package/routes/healthcheck.js +1 -1
- package/routes/hicdata.js +1 -1
- package/routes/hicgenome.js +1 -1
- package/routes/hicstat.js +1 -1
- package/routes/isoformlst.js +1 -1
- package/routes/ntseq.js +1 -1
- package/routes/pdomain.js +1 -1
- package/routes/sampledzimages.js +1 -1
- package/routes/samplewsimages.js +1 -1
- package/routes/snp.js +1 -1
- package/routes/termdb.DE.js +1 -1
- package/routes/termdb.boxplot.js +22 -15
- package/routes/termdb.categories.js +1 -1
- package/routes/termdb.cluster.js +1 -1
- package/routes/termdb.cohort.summary.js +1 -1
- package/routes/termdb.cohorts.js +1 -1
- package/routes/termdb.descrstats.js +1 -1
- package/routes/termdb.numericcategories.js +1 -1
- package/routes/termdb.percentile.js +1 -1
- package/routes/termdb.rootterm.js +1 -1
- package/routes/termdb.sampleImages.js +1 -1
- package/routes/termdb.singleSampleMutation.js +1 -1
- package/routes/termdb.singlecellDEgenes.js +1 -1
- package/routes/termdb.singlecellData.js +1 -1
- package/routes/termdb.singlecellSamples.js +5 -5
- package/routes/termdb.termchildren.js +1 -1
- package/routes/termdb.termsbyids.js +1 -1
- package/routes/termdb.topTermsByType.js +1 -1
- package/routes/termdb.topVariablyExpressedGenes.js +1 -1
- package/routes/termdb.violin.js +1 -1
- package/routes/tileserver.js +1 -1
- package/routes/wsimages.js +1 -1
- package/src/app.js +217 -185
- package/utils/gsea.py +13 -3
- package/utils/plotBrainImaging.py +92 -53
package/utils/gsea.py
CHANGED
|
@@ -10,7 +10,7 @@ import numpy as np
|
|
|
10
10
|
import pandas as pd
|
|
11
11
|
|
|
12
12
|
def extract_symbols(x):
|
|
13
|
-
return x['symbol']
|
|
13
|
+
return x['symbol']
|
|
14
14
|
|
|
15
15
|
def extract_plot_data(signature, geneset, library, result, center=True):
|
|
16
16
|
signature = signature.copy()
|
|
@@ -48,6 +48,7 @@ try:
|
|
|
48
48
|
genes=json_object['genes']
|
|
49
49
|
fold_change=json_object['fold_change']
|
|
50
50
|
table_name=json_object['geneset_group']
|
|
51
|
+
filter_non_coding_genes=json_object['filter_non_coding_genes']
|
|
51
52
|
df = {'Genes': genes, 'fold_change': fold_change}
|
|
52
53
|
signature=pd.DataFrame(df)
|
|
53
54
|
db=json_object['db']
|
|
@@ -59,10 +60,19 @@ try:
|
|
|
59
60
|
|
|
60
61
|
# SQL query to select all data from the table
|
|
61
62
|
query = f"select id from terms where parent_id='" + table_name + "'"
|
|
62
|
-
|
|
63
63
|
# Execute the SQL query
|
|
64
64
|
cursor.execute(query)
|
|
65
|
-
|
|
65
|
+
if filter_non_coding_genes == True:
|
|
66
|
+
# SQL query to code all the protein coding genes
|
|
67
|
+
coding_genes_query = f"select * from codingGenes"
|
|
68
|
+
genedb = json_object['genedb']
|
|
69
|
+
gene_conn = sqlite3.connect(genedb)
|
|
70
|
+
gene_cursor = gene_conn.cursor()
|
|
71
|
+
gene_cursor.execute(coding_genes_query)
|
|
72
|
+
coding_genes_list=gene_cursor.fetchall()
|
|
73
|
+
coding_genes_list=list(map(lambda x: x[0],coding_genes_list))
|
|
74
|
+
signature=signature[signature['Genes'].isin(coding_genes_list)]
|
|
75
|
+
|
|
66
76
|
# Fetch all rows from the executed SQL query
|
|
67
77
|
rows = cursor.fetchall()
|
|
68
78
|
|
|
@@ -1,69 +1,108 @@
|
|
|
1
1
|
import nibabel as nib # Library for loading data from neuroimaging file formats such as NIfTI
|
|
2
2
|
import matplotlib.pyplot as plt
|
|
3
|
+
import matplotlib.colors as mcolors
|
|
4
|
+
import matplotlib.cm as cm
|
|
3
5
|
import numpy as np
|
|
4
6
|
import sys
|
|
5
7
|
import io
|
|
8
|
+
import json
|
|
6
9
|
|
|
7
10
|
if len(sys.argv) <= 1:
|
|
8
|
-
print('python3 '+sys.argv[0]+' <path/to/template/file>
|
|
11
|
+
print('python3 '+sys.argv[0]+' <path/to/template/file> plane index filesJson.\n filesJson: dictionary containg sample files and color per category).\nplane: L (left, sagittal), F (front, coronal), T (top, axial)')
|
|
12
|
+
sys.exit(1)
|
|
13
|
+
|
|
14
|
+
plane = sys.argv[2]
|
|
15
|
+
if(plane != 'L' and plane != 'F' and plane != 'T'):
|
|
16
|
+
print('Invalid plane')
|
|
17
|
+
sys.exit(1)
|
|
18
|
+
index = sys.argv[3]
|
|
19
|
+
|
|
20
|
+
if(len(index) == 0):
|
|
21
|
+
print('Need to provide index')
|
|
9
22
|
sys.exit(1)
|
|
10
23
|
|
|
11
24
|
templateFile = sys.argv[1]
|
|
12
|
-
labelFile = sys.argv[2]
|
|
13
25
|
|
|
14
26
|
# load data from nifti files
|
|
15
27
|
template = nib.load(templateFile).get_fdata()
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
28
|
+
|
|
29
|
+
vmaxSamples = sys.argv[4]
|
|
30
|
+
|
|
31
|
+
if(len(vmaxSamples) == 0):
|
|
32
|
+
print('Need to provide max samples for normalization')
|
|
33
|
+
sys.exit(1)
|
|
34
|
+
vmaxSamples = int(vmaxSamples)
|
|
35
|
+
|
|
36
|
+
sampleFiles = json.loads(sys.argv[5])
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
index = int(index)
|
|
40
|
+
# (left, sagittal), f (front, coronal), t (top, axial)
|
|
41
|
+
if plane == 'L':
|
|
42
|
+
slice = template[index,:,:]
|
|
43
|
+
slice = np.rot90(slice)
|
|
44
|
+
elif plane == 'F':
|
|
45
|
+
slice = template[:,index,:]
|
|
46
|
+
slice = np.flip(np.rot90(slice),axis=1)
|
|
47
|
+
|
|
48
|
+
else:# plane == 'T'
|
|
49
|
+
slice = template[:,:,index]
|
|
50
|
+
slice = np.flip(np.rot90(slice),axis=1)
|
|
51
|
+
|
|
52
|
+
fig, ax = plt.subplots(1, 1)
|
|
53
|
+
ax.imshow(slice, 'gray', filternorm=False, vmin=0, vmax=100)
|
|
54
|
+
|
|
55
|
+
for key, value in sampleFiles.items():
|
|
56
|
+
if(len(value["samples"]) == 0) :
|
|
57
|
+
continue
|
|
58
|
+
# Load all sample files
|
|
59
|
+
sample_data = [nib.load(file_path).get_fdata() for file_path in value["samples"]]
|
|
60
|
+
|
|
61
|
+
# Initialize the result array with zeros
|
|
62
|
+
labels = np.zeros_like(sample_data[0])
|
|
63
|
+
|
|
64
|
+
# Sum all sample data
|
|
65
|
+
for data in sample_data:
|
|
66
|
+
labels += data
|
|
67
|
+
|
|
68
|
+
labels = np.ma.masked_where(labels == 0, labels) # Mask labels where they are 0
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
index = int(index)
|
|
72
|
+
# (left, sagittal), f (front, coronal), t (top, axial)
|
|
73
|
+
if plane == 'L':
|
|
74
|
+
label = labels[index,:,:]
|
|
75
|
+
label = np.rot90(label)
|
|
76
|
+
elif plane == 'F':
|
|
77
|
+
label = labels[:,index,:]
|
|
78
|
+
label = np.flip(np.rot90(label),axis=1)
|
|
79
|
+
else:# plane == 'T'
|
|
80
|
+
label = labels[:,:,index]
|
|
81
|
+
label = np.flip(np.rot90(label),axis=1)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
# create three subplots for sagittal, coronal and axial plane
|
|
86
|
+
vmin = 0
|
|
87
|
+
vmax = 100
|
|
88
|
+
alpha = 0.6
|
|
89
|
+
|
|
90
|
+
color = value['color']
|
|
91
|
+
print(color)
|
|
92
|
+
cmap = mcolors.LinearSegmentedColormap.from_list('my_cmap', ['white', color])
|
|
93
|
+
ax.imshow(label, cmap, alpha=alpha, filternorm=False,vmin=0,vmax=vmaxSamples)
|
|
94
|
+
ax.axis('off')
|
|
95
|
+
|
|
96
|
+
# Create the color bar
|
|
97
|
+
# if showLegend == 1:
|
|
98
|
+
# # Create a color bar without changing figure size
|
|
99
|
+
# norm = mcolors.Normalize(vmin=0, vmax=vmaxSamples)
|
|
100
|
+
# sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
|
|
101
|
+
|
|
102
|
+
# cbar = plt.colorbar(sm, ax=ax, orientation='vertical', fraction=0.01, pad=0.05, alpha=alpha)
|
|
103
|
+
# cbar.set_label('Combined Intensity', color='white', fontsize=6, labelpad=-10)
|
|
104
|
+
# cbar.ax.text(0.5, 1.0001, vmaxSamples, ha='center', va='bottom', transform=cbar.ax.transAxes, color='white', fontsize=6)
|
|
105
|
+
# cbar.ax.text(0.5, -0.0001, 0, ha='center', va='top', transform=cbar.ax.transAxes, color='white', fontsize=6)
|
|
67
106
|
|
|
68
107
|
# Output the image data to stdout
|
|
69
108
|
buf = io.BytesIO()
|