From f65b9ce8259b2f66548c351df9ce4937ed237005 Mon Sep 17 00:00:00 2001 From: adkinsrs Date: Tue, 27 Aug 2024 09:39:50 -0400 Subject: [PATCH] Resolving #878 by renaming gene symbol earlier in the flow --- lib/gear/plotting.py | 4 ---- www/api/resources/plotly_data.py | 7 +++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/gear/plotting.py b/lib/gear/plotting.py index b321bd95..5d9dfa99 100644 --- a/lib/gear/plotting.py +++ b/lib/gear/plotting.py @@ -1,11 +1,7 @@ -# Purely kept so we can debug with sys.stderr from itertools import cycle -import pandas as pd - import plotly.express as px import plotly.graph_objects as go -from matplotlib.pyplot import plot from plotly import exceptions from plotly.colors import unlabel_rgb from plotly.subplots import make_subplots diff --git a/www/api/resources/plotly_data.py b/www/api/resources/plotly_data.py index 9413fda0..e9d5854a 100644 --- a/www/api/resources/plotly_data.py +++ b/www/api/resources/plotly_data.py @@ -215,6 +215,10 @@ def post(self, dataset_id): if adata.isbacked: adata.file.close() + # Rename the single selected.var index label to "raw_value" + # This resolves https://github.com/IGS/gEAR/issues/878 where the gene_symbol index may be the same as a observation column (i.e. projections) + selected.var.index = pd.Index(["raw_value"]) + df = selected.to_df() success = 1 @@ -224,8 +228,7 @@ def post(self, dataset_id): message = "WARNING: Multiple Ensemble IDs found for gene symbol '{}'. Using the first stored Ensembl ID.".format(gene_symbol) df = df.iloc[:,[0]] # Note, put the '0' in a list to return a DataFrame. Not having in list returns DataSeries instead - df2 = pd.concat([df,selected.obs], axis=1) - df = df2.rename(columns={df.columns[0]: "raw_value"}) + df = pd.concat([df,selected.obs], axis=1) # Valid analysis column names from api/resources/h5ad.py analysis_tsne_columns = ['X_tsne_1', 'X_tsne_2']