mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-06 20:58:12 +08:00
Remove cell ids from engine
Previously I just removed them from the driver
This commit is contained in:
@@ -193,7 +193,6 @@ class CellsAPI(Resource):
|
|||||||
def get(self):
|
def get(self):
|
||||||
from app import data
|
from app import data
|
||||||
payload = {
|
payload = {
|
||||||
"cellids": [],
|
|
||||||
"metadata": [],
|
"metadata": [],
|
||||||
"cellcount": 0,
|
"cellcount": 0,
|
||||||
"graph": [],
|
"graph": [],
|
||||||
@@ -205,8 +204,7 @@ class CellsAPI(Resource):
|
|||||||
payload["metadata"] = data.metadata(filtered_data)
|
payload["metadata"] = data.metadata(filtered_data)
|
||||||
payload["ranges"] = data.metadata_ranges(filtered_data)
|
payload["ranges"] = data.metadata_ranges(filtered_data)
|
||||||
payload["graph"] = data.create_graph(filtered_data)
|
payload["graph"] = data.create_graph(filtered_data)
|
||||||
payload["cellids"] = data.cellids(filtered_data)
|
payload["cellcount"] = data.cell_count
|
||||||
payload["cellcount"] = len(payload["cellids"])
|
|
||||||
return make_payload(payload)
|
return make_payload(payload)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,12 +13,15 @@ class ScanpyEngine(CXGDriver):
|
|||||||
def __init__(self, data, schema=None, graph_method="umap", diffexp_method="ttest"):
|
def __init__(self, data, schema=None, graph_method="umap", diffexp_method="ttest"):
|
||||||
self.data = self._load_data(data)
|
self.data = self._load_data(data)
|
||||||
self.schema = self._load_or_infer_schema(data, schema)
|
self.schema = self._load_or_infer_schema(data, schema)
|
||||||
self._set_cell_ids()
|
self._set_cell_names()
|
||||||
self.cell_count = self.data.shape[0]
|
self.cell_count = self.data.shape[0]
|
||||||
self.gene_count = self.data.shape[1]
|
self.gene_count = self.data.shape[1]
|
||||||
self.graph_method = graph_method
|
self.graph_method = graph_method
|
||||||
self.diffexp_method = diffexp_method
|
self.diffexp_method = diffexp_method
|
||||||
|
|
||||||
|
def _set_cell_names(self):
|
||||||
|
self.data.obs["cell_name"] = list(self.data.obs.index)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _load_data(data):
|
def _load_data(data):
|
||||||
return sc.read(os.path.join(data, "data.h5ad"))
|
return sc.read(os.path.join(data, "data.h5ad"))
|
||||||
@@ -32,20 +35,9 @@ class ScanpyEngine(CXGDriver):
|
|||||||
data_schema = parse_schema(os.path.join(data, schema))
|
data_schema = parse_schema(os.path.join(data, schema))
|
||||||
return data_schema
|
return data_schema
|
||||||
|
|
||||||
def _set_cell_ids(self):
|
|
||||||
self.data.obs["cxg_cell_id"] = list(range(self.data.obs.shape[0]))
|
|
||||||
self.data.obs["cell_name"] = list(self.data.obs.index)
|
|
||||||
self.data.obs.set_index("cxg_cell_id", inplace=True)
|
|
||||||
|
|
||||||
def cells(self):
|
def cells(self):
|
||||||
return list(self.data.obs.index)
|
return list(self.data.obs.index)
|
||||||
|
|
||||||
def cellids(self, df=None):
|
|
||||||
if df:
|
|
||||||
return list(df.obs.index)
|
|
||||||
else:
|
|
||||||
return list(self.data.obs.index)
|
|
||||||
|
|
||||||
def genes(self):
|
def genes(self):
|
||||||
return self.data.var.index.tolist()
|
return self.data.var.index.tolist()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user