Skip to content

Commit 43f0e6b

Browse files
authored
Merge pull request #1011 from IGS/hotfix-jorvis-1211
Fixing bug where adata.X is a sparse matrix and breaking things downs…
2 parents 8897867 + a9434da commit 43f0e6b

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

.gitignore

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
gear.ini
21
docker/docker-compose.yml
32
docker/gear.ini.docker
43
NOTES
54
TODO
65
www/.env
76
www/cgi/remove_dataset_from_profile.cgi
8-
www/css/dataset_manager.css
97
www/include/manual/create_account.html~
10-
www/include/manual/dataset_manager.html~
118
www/include/manual/search_gear.html~
129
www/include/manual/search_results.html~
1310
www/include/manual/upload_dataset.html~
14-
www/js/dataset_curator.vue3.js
15-
www/js/dataset_manager.js
1611
www/tests/test_dataset_curator_plotly.py
1712
www/datasets_epigenetic/uploads/files/*
1813
www/.DS_Store
1914
www/.cache
2015
.DS_Store
16+
orthomap_inputs
17+
**/__pycache__
18+
**/*.bak
19+
**/*.sql
20+
www/nemoarchive_import/*.json

www/api/resources/mg_plotly_data.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,6 @@ def post(self, dataset_id):
163163

164164
adata.obs = order_by_time_point(adata.obs)
165165

166-
# quick check to ensure
167-
168-
169166
# get a map of all levels for each column
170167
columns = adata.obs.select_dtypes(include="category").columns.tolist()
171168

@@ -242,6 +239,13 @@ def post(self, dataset_id):
242239
# The "try" may fail for projections as it is already in memory
243240
selected = adata
244241

242+
# convert adata.X to a dense matrix if it is sparse
243+
# This prevents potential downstream issues
244+
try:
245+
selected.X = selected.X.todense()
246+
except:
247+
pass
248+
245249
# These plot types filter to only the specific genes.
246250
# The other plot types use all genes and rather annotate the specific ones.
247251
if plot_type in ['dotplot', 'heatmap', 'mg_violin'] and gene_filter is not None:
@@ -271,7 +275,6 @@ def post(self, dataset_id):
271275
# Sort ensembl IDs based on the gene symbol order
272276
sorted_ensm = map(lambda x: gene_to_ensm[x], normalized_genes_list)
273277

274-
275278
try:
276279
# Reorder the categorical values in the observation dataframe
277280
sort_fields = []
@@ -298,11 +301,6 @@ def post(self, dataset_id):
298301
except:
299302
pass
300303

301-
# Make a composite index of all categorical types
302-
#selected.obs['composite_index'] = create_composite_index_column(selected, columns)
303-
#selected.obs['composite_index'] = selected.obs['composite_index'].astype('category')
304-
#columns.append("composite_index")
305-
306304
# Filter dataframe on the chosen observation filters
307305
if filters:
308306
for field in filters.keys():
@@ -353,7 +351,6 @@ def post(self, dataset_id):
353351
'message': str(pe),
354352
}
355353

356-
357354
var_index = selected.var.index.name
358355

359356
if plot_type == "volcano":

www/api/resources/plotly_data.py

+7
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,13 @@ def post(self, dataset_id):
228228
# The "try" may fail for projections as it is already in memory
229229
selected = adata[:, gene_filter]
230230

231+
# convert adata.X to a dense matrix if it is sparse
232+
# This prevents potential downstream issues
233+
try:
234+
selected.X = selected.X.todense()
235+
except:
236+
pass
237+
231238
# Filter by obs filters
232239
if filters:
233240
for col, values in filters.items():

www/api/resources/tsne_data.py

+7
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,13 @@ def post(self, dataset_id):
347347
# The "try" may fail for projections as it is already in memory
348348
selected = adata[:, gene_filter]
349349

350+
# convert adata.X to a dense matrix if it is sparse
351+
# This prevents potential downstream issues
352+
try:
353+
selected.X = selected.X.todense()
354+
except:
355+
pass
356+
350357
# Filter by obs filters
351358
if filters:
352359
for col, values in filters.items():

0 commit comments

Comments
 (0)