From 0271c93575e78fc396f16dc8caea4992f648feb8 Mon Sep 17 00:00:00 2001 From: KrisDavie Date: Thu, 22 Feb 2018 12:35:53 +0100 Subject: [PATCH] Allow calling of multiple tSNEs Default 'Embedding' is -1 --- scope-client/src/proto/s.proto | 1 + .../scopeserver/modules/gserver/GServer.py | 17 +++-- .../scopeserver/modules/gserver/s_pb2.py | 67 ++++++++++--------- 3 files changed, 50 insertions(+), 35 deletions(-) diff --git a/scope-client/src/proto/s.proto b/scope-client/src/proto/s.proto index 35f21039..831bf66c 100644 --- a/scope-client/src/proto/s.proto +++ b/scope-client/src/proto/s.proto @@ -61,6 +61,7 @@ message FeatureReply { message CoordinatesRequest { string loomFilePath=1; + int32 coordinatesID=2; } message CoordinatesReply { diff --git a/scope-server/scopeserver/modules/gserver/GServer.py b/scope-server/scopeserver/modules/gserver/GServer.py index d2e6bf32..481cc5b8 100644 --- a/scope-server/scopeserver/modules/gserver/GServer.py +++ b/scope-server/scopeserver/modules/gserver/GServer.py @@ -120,11 +120,18 @@ def get_features(self, loom_file_path, query): return {'feature': res, 'featureType': resF} - def get_coordinates(self, loom_file_path, EmbeddingName='Embedding'): + def get_coordinates(self, loom_file_path, coordinatesID=-1): loom = self.get_loom_connection(loom_file_path) - embedding = loom.ca[EmbeddingName] - return {"x": embedding["_X"], - "y": embedding["_Y"]} + if coordinatesID == -1: + embedding = loom.ca['Embedding'] + x = embedding['_X'] + y = embedding['_Y'] + else: + x = loom.ca.Embeddings_X["coordinatesID"] + y = loom.ca.Embeddings_Y["coordinatesID"] + print(x, y) + return {"x": x, + "y": y} def get_file_metadata(self, loom_file_path): loom = self.get_loom_connection(loom_file_path) @@ -218,7 +225,7 @@ def getFeatures(self, request, context): def getCoordinates(self, request, context): # request content - c = self.get_coordinates(self.get_loom_filepath(request.loomFilePath)) + c = self.get_coordinates(self.get_loom_filepath(request.loomFilePath), coordinatesID=request.coordinatesID) return s_pb2.CoordinatesReply(x=c["x"], y=c["y"]) def getMyLooms(self, request, context): diff --git a/scope-server/scopeserver/modules/gserver/s_pb2.py b/scope-server/scopeserver/modules/gserver/s_pb2.py index 5823ad2d..b9cb589b 100644 --- a/scope-server/scopeserver/modules/gserver/s_pb2.py +++ b/scope-server/scopeserver/modules/gserver/s_pb2.py @@ -19,7 +19,7 @@ name='s.proto', package='scope', syntax='proto3', - serialized_pb=_b('\n\x07s.proto\x12\x05scope\"\xb5\x01\n\x1a\x43\x65llColorByFeaturesRequest\x12\x14\n\x0cloomFilePath\x18\x01 \x01(\t\x12\x0f\n\x07\x66\x65\x61ture\x18\x02 \x03(\t\x12\x13\n\x0b\x66\x65\x61tureType\x18\x03 \x03(\t\x12\x16\n\x0ehasLogTranform\x18\x04 \x01(\x08\x12\x16\n\x0ehasCpmTranform\x18\x05 \x01(\x08\x12\x11\n\tthreshold\x18\x06 \x03(\x02\x12\x18\n\x10scaleThresholded\x18\x07 \x01(\x08\")\n\x18\x43\x65llColorByFeaturesReply\x12\r\n\x05\x63olor\x18\x01 \x03(\t\"\\\n\x1e\x43\x65llAUCValuesByFeaturesRequest\x12\x14\n\x0cloomFilePath\x18\x01 \x01(\t\x12\x0f\n\x07\x66\x65\x61ture\x18\x02 \x03(\t\x12\x13\n\x0b\x66\x65\x61tureType\x18\x03 \x03(\t\"-\n\x1c\x43\x65llAUCValuesByFeaturesReply\x12\r\n\x05value\x18\x01 \x03(\x02\"5\n\x0e\x46\x65\x61tureRequest\x12\x14\n\x0cloomFilePath\x18\x01 \x01(\t\x12\r\n\x05query\x18\x02 \x01(\t\"4\n\x0c\x46\x65\x61tureReply\x12\x0f\n\x07\x66\x65\x61ture\x18\x01 \x03(\t\x12\x13\n\x0b\x66\x65\x61tureType\x18\x02 \x03(\t\"*\n\x12\x43oordinatesRequest\x12\x14\n\x0cloomFilePath\x18\x01 \x01(\t\"(\n\x10\x43oordinatesReply\x12\t\n\x01x\x18\x01 \x03(\x02\x12\t\n\x01y\x18\x02 \x03(\x02\"*\n\nAnnotation\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06values\x18\x02 \x03(\t\"%\n\tEmbedding\x12\n\n\x02id\x18\x01 \x01(\x05\x12\x0c\n\x04name\x18\x02 \x01(\t\"4\n\x11\x43lusterAnnotation\x12\n\n\x02id\x18\x01 \x01(\x05\x12\x13\n\x0b\x64\x65scription\x18\x02 \x01(\t\"a\n\nClustering\x12\n\n\x02id\x18\x01 \x01(\x05\x12\r\n\x05group\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12*\n\x08\x63lusters\x18\x04 \x03(\x0b\x32\x18.scope.ClusterAnnotation\"\x84\x01\n\x0c\x43\x65llMetaData\x12&\n\x0b\x61nnotations\x18\x01 \x03(\x0b\x32\x11.scope.Annotation\x12$\n\nembeddings\x18\x02 \x03(\x0b\x32\x10.scope.Embedding\x12&\n\x0b\x63lusterings\x18\x03 \x03(\x0b\x32\x11.scope.Clustering\"/\n\x0c\x41UCThreshold\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x11\n\tthreshold\x18\x02 \x01(\x02\"T\n\x07Regulon\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06nGenes\x18\x02 \x01(\x05\x12+\n\x0e\x61utoThresholds\x18\x03 \x03(\x0b\x32\x13.scope.AUCThreshold\"3\n\x0fRegulonMetaData\x12 \n\x08regulons\x18\x01 \x03(\x0b\x32\x0e.scope.Regulon\"\x8c\x01\n\x0c\x46ileMetaData\x12\x16\n\x0ehasRegulonsAUC\x18\x01 \x01(\x08\x12\x13\n\x0bhasGeneSets\x18\x02 \x01(\x08\x12\x1c\n\x14hasSeuratClusterings\x18\x03 \x01(\x08\x12\x1a\n\x12hasExtraEmbeddings\x18\x04 \x01(\x08\x12\x15\n\rhasGlobalMeta\x18\x05 \x01(\x08\"\x10\n\x0eMyLoomsRequest\"\xa5\x01\n\x06MyLoom\x12\x14\n\x0cloomFilePath\x18\x01 \x01(\t\x12)\n\x0c\x63\x65llMetaData\x18\x02 \x01(\x0b\x32\x13.scope.CellMetaData\x12/\n\x0fregulonMetaData\x18\x03 \x01(\x0b\x32\x16.scope.RegulonMetaData\x12)\n\x0c\x66ileMetaData\x18\x04 \x01(\x0b\x32\x13.scope.FileMetaData\".\n\x0cMyLoomsReply\x12\x1e\n\x07myLooms\x18\x01 \x03(\x0b\x32\r.scope.MyLoom2\x93\x03\n\x04Main\x12^\n\x16getCellColorByFeatures\x12!.scope.CellColorByFeaturesRequest\x1a\x1f.scope.CellColorByFeaturesReply\"\x00\x12j\n\x1agetCellAUCValuesByFeatures\x12%.scope.CellAUCValuesByFeaturesRequest\x1a#.scope.CellAUCValuesByFeaturesReply\"\x00\x12;\n\x0bgetFeatures\x12\x15.scope.FeatureRequest\x1a\x13.scope.FeatureReply\"\x00\x12\x46\n\x0egetCoordinates\x12\x19.scope.CoordinatesRequest\x1a\x17.scope.CoordinatesReply\"\x00\x12:\n\ngetMyLooms\x12\x15.scope.MyLoomsRequest\x1a\x13.scope.MyLoomsReply\"\x00\x62\x06proto3') + serialized_pb=_b('\n\x07s.proto\x12\x05scope\"\xb5\x01\n\x1a\x43\x65llColorByFeaturesRequest\x12\x14\n\x0cloomFilePath\x18\x01 \x01(\t\x12\x0f\n\x07\x66\x65\x61ture\x18\x02 \x03(\t\x12\x13\n\x0b\x66\x65\x61tureType\x18\x03 \x03(\t\x12\x16\n\x0ehasLogTranform\x18\x04 \x01(\x08\x12\x16\n\x0ehasCpmTranform\x18\x05 \x01(\x08\x12\x11\n\tthreshold\x18\x06 \x03(\x02\x12\x18\n\x10scaleThresholded\x18\x07 \x01(\x08\")\n\x18\x43\x65llColorByFeaturesReply\x12\r\n\x05\x63olor\x18\x01 \x03(\t\"\\\n\x1e\x43\x65llAUCValuesByFeaturesRequest\x12\x14\n\x0cloomFilePath\x18\x01 \x01(\t\x12\x0f\n\x07\x66\x65\x61ture\x18\x02 \x03(\t\x12\x13\n\x0b\x66\x65\x61tureType\x18\x03 \x03(\t\"-\n\x1c\x43\x65llAUCValuesByFeaturesReply\x12\r\n\x05value\x18\x01 \x03(\x02\"5\n\x0e\x46\x65\x61tureRequest\x12\x14\n\x0cloomFilePath\x18\x01 \x01(\t\x12\r\n\x05query\x18\x02 \x01(\t\"4\n\x0c\x46\x65\x61tureReply\x12\x0f\n\x07\x66\x65\x61ture\x18\x01 \x03(\t\x12\x13\n\x0b\x66\x65\x61tureType\x18\x02 \x03(\t\"A\n\x12\x43oordinatesRequest\x12\x14\n\x0cloomFilePath\x18\x01 \x01(\t\x12\x15\n\rcoordinatesID\x18\x02 \x01(\x05\"(\n\x10\x43oordinatesReply\x12\t\n\x01x\x18\x01 \x03(\x02\x12\t\n\x01y\x18\x02 \x03(\x02\"*\n\nAnnotation\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06values\x18\x02 \x03(\t\"%\n\tEmbedding\x12\n\n\x02id\x18\x01 \x01(\x05\x12\x0c\n\x04name\x18\x02 \x01(\t\"4\n\x11\x43lusterAnnotation\x12\n\n\x02id\x18\x01 \x01(\x05\x12\x13\n\x0b\x64\x65scription\x18\x02 \x01(\t\"a\n\nClustering\x12\n\n\x02id\x18\x01 \x01(\x05\x12\r\n\x05group\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12*\n\x08\x63lusters\x18\x04 \x03(\x0b\x32\x18.scope.ClusterAnnotation\"\x84\x01\n\x0c\x43\x65llMetaData\x12&\n\x0b\x61nnotations\x18\x01 \x03(\x0b\x32\x11.scope.Annotation\x12$\n\nembeddings\x18\x02 \x03(\x0b\x32\x10.scope.Embedding\x12&\n\x0b\x63lusterings\x18\x03 \x03(\x0b\x32\x11.scope.Clustering\"/\n\x0c\x41UCThreshold\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x11\n\tthreshold\x18\x02 \x01(\x02\"T\n\x07Regulon\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06nGenes\x18\x02 \x01(\x05\x12+\n\x0e\x61utoThresholds\x18\x03 \x03(\x0b\x32\x13.scope.AUCThreshold\"3\n\x0fRegulonMetaData\x12 \n\x08regulons\x18\x01 \x03(\x0b\x32\x0e.scope.Regulon\"\x8c\x01\n\x0c\x46ileMetaData\x12\x16\n\x0ehasRegulonsAUC\x18\x01 \x01(\x08\x12\x13\n\x0bhasGeneSets\x18\x02 \x01(\x08\x12\x1c\n\x14hasSeuratClusterings\x18\x03 \x01(\x08\x12\x1a\n\x12hasExtraEmbeddings\x18\x04 \x01(\x08\x12\x15\n\rhasGlobalMeta\x18\x05 \x01(\x08\"\x10\n\x0eMyLoomsRequest\"\xa5\x01\n\x06MyLoom\x12\x14\n\x0cloomFilePath\x18\x01 \x01(\t\x12)\n\x0c\x63\x65llMetaData\x18\x02 \x01(\x0b\x32\x13.scope.CellMetaData\x12/\n\x0fregulonMetaData\x18\x03 \x01(\x0b\x32\x16.scope.RegulonMetaData\x12)\n\x0c\x66ileMetaData\x18\x04 \x01(\x0b\x32\x13.scope.FileMetaData\".\n\x0cMyLoomsReply\x12\x1e\n\x07myLooms\x18\x01 \x03(\x0b\x32\r.scope.MyLoom2\x93\x03\n\x04Main\x12^\n\x16getCellColorByFeatures\x12!.scope.CellColorByFeaturesRequest\x1a\x1f.scope.CellColorByFeaturesReply\"\x00\x12j\n\x1agetCellAUCValuesByFeatures\x12%.scope.CellAUCValuesByFeaturesRequest\x1a#.scope.CellAUCValuesByFeaturesReply\"\x00\x12;\n\x0bgetFeatures\x12\x15.scope.FeatureRequest\x1a\x13.scope.FeatureReply\"\x00\x12\x46\n\x0egetCoordinates\x12\x19.scope.CoordinatesRequest\x1a\x17.scope.CoordinatesReply\"\x00\x12:\n\ngetMyLooms\x12\x15.scope.MyLoomsRequest\x1a\x13.scope.MyLoomsReply\"\x00\x62\x06proto3') ) @@ -295,6 +295,13 @@ message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='coordinatesID', full_name='scope.CoordinatesRequest.coordinatesID', index=1, + number=2, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -308,7 +315,7 @@ oneofs=[ ], serialized_start=495, - serialized_end=537, + serialized_end=560, ) @@ -345,8 +352,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=539, - serialized_end=579, + serialized_start=562, + serialized_end=602, ) @@ -383,8 +390,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=581, - serialized_end=623, + serialized_start=604, + serialized_end=646, ) @@ -421,8 +428,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=625, - serialized_end=662, + serialized_start=648, + serialized_end=685, ) @@ -459,8 +466,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=664, - serialized_end=716, + serialized_start=687, + serialized_end=739, ) @@ -511,8 +518,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=718, - serialized_end=815, + serialized_start=741, + serialized_end=838, ) @@ -556,8 +563,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=818, - serialized_end=950, + serialized_start=841, + serialized_end=973, ) @@ -594,8 +601,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=952, - serialized_end=999, + serialized_start=975, + serialized_end=1022, ) @@ -639,8 +646,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1001, - serialized_end=1085, + serialized_start=1024, + serialized_end=1108, ) @@ -670,8 +677,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1087, - serialized_end=1138, + serialized_start=1110, + serialized_end=1161, ) @@ -729,8 +736,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1141, - serialized_end=1281, + serialized_start=1164, + serialized_end=1304, ) @@ -753,8 +760,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1283, - serialized_end=1299, + serialized_start=1306, + serialized_end=1322, ) @@ -805,8 +812,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1302, - serialized_end=1467, + serialized_start=1325, + serialized_end=1490, ) @@ -836,8 +843,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1469, - serialized_end=1515, + serialized_start=1492, + serialized_end=1538, ) _CLUSTERING.fields_by_name['clusters'].message_type = _CLUSTERANNOTATION @@ -1020,8 +1027,8 @@ file=DESCRIPTOR, index=0, options=None, - serialized_start=1518, - serialized_end=1921, + serialized_start=1541, + serialized_end=1944, methods=[ _descriptor.MethodDescriptor( name='getCellColorByFeatures',