Skip to content

Commit

Permalink
Fix issues remaining after rebase onto develop
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeJustJames committed May 21, 2021
1 parent 3c83036 commit ade6360
Show file tree
Hide file tree
Showing 22 changed files with 10,188 additions and 11,416 deletions.
840 changes: 831 additions & 9 deletions opt/scopeserver/bindserver/package-lock.json

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions opt/scopeserver/dataserver/modules/gserver/GServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,7 @@ def getNextCluster(self, request, context):

search_results: List[CategorisedMatches] = [
result
for result in get_search_results(
cluster_metadata["description"], "all", loom, self.config["dataHashSecret"]
)
for result in get_search_results(cluster_metadata["description"], "all", loom)
if result.category == f"Clustering: {clustering_meta['name']}"
]

Expand Down Expand Up @@ -329,7 +327,7 @@ def getCellMetaData(self, request, context):

def getFeatures(self, request, context):
loom = self.lfh.get_loom(loom_file_path=Path(request.loomFilePath))
features = get_search_results(request.query, request.filter, loom, self.config["dataHashSecret"])
features = get_search_results(request.query, request.filter, loom)
return s_pb2.FeatureReply(
features=[
s_pb2.FeatureReply.Feature(
Expand Down
104 changes: 52 additions & 52 deletions opt/scopeserver/dataserver/modules/gserver/s_pb2.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion opt/scopeserver/dataserver/utils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
T = TypeVar("T")


def get_99_and_100_percentiles(values: np.ndarray) -> Tuple[np.float, np.float]:
def get_99_and_100_percentiles(values: np.ndarray) -> Tuple[np.ndarray, np.number]:
"""
Compute the 99th and 100th (maximum value) of an array of values
and clamp the 99th percentil value between [0.01, max(values)]
Expand Down
4 changes: 2 additions & 2 deletions opt/scopeserver/dataserver/utils/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def labels() -> Generator[FeatureLabel, None, None]:
yield FeatureLabel(
label=annotation,
colour=colours[i],
coordinate=Coordinate(x=np.mean(coords["x"]), y=np.mean(coords["y"])),
coordinate=Coordinate(x=float(np.mean(coords["x"])), y=float(np.mean(coords["y"]))),
)

return [label for label in labels()]
Expand Down Expand Up @@ -85,7 +85,7 @@ def labels() -> Generator[FeatureLabel, None, None]:
yield FeatureLabel(
label=cluster,
colour=colours[i],
coordinate=Coordinate(x=np.mean(coords["x"]), y=np.mean(coords["y"])),
coordinate=Coordinate(x=float(np.mean(coords["x"])), y=float(np.mean(coords["y"]))),
)

return [label for label in labels()]
10 changes: 2 additions & 8 deletions opt/scopeserver/dataserver/utils/loom.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def __init__(

logger.info(f"New Loom object created for {file_path}")
# Metrics
self.nUMI = None
self.species, self.gene_mappings = self.infer_species()
self.ss_pickle_name = self.abs_file_path.with_suffix(".ss_pkl")
self.ss = ss.load_ss(self)
Expand Down Expand Up @@ -758,8 +757,6 @@ def get_gene_names(self) -> Dict[str, str]:
##############

def get_nUMI(self) -> np.ndarray:
if self.nUMI is not None:
return self.nUMI
if self.has_ca_attr(name="nUMI"):
return self.loom_connection.ca.nUMI
if self.has_ca_attr(name="n_counts"):
Expand All @@ -768,10 +765,7 @@ def get_nUMI(self) -> np.ndarray:
# TODO: Add case here for large files. Sum across 1mio rows takes a very long time to compute
# Possibly faster fix totals = ds.map([np.sum], axis=1)[0]

calc_nUMI_start_time = time.time()
self.nUMI = self.loom_connection.map([np.sum], axis=1)[0]
logger.debug("{0:.5f} seconds elapsed (calculating nUMI) ---".format(time.time() - calc_nUMI_start_time))
return self.nUMI
return self.loom_connection.map([np.sum], axis=1)[0]

def get_gene_expression_by_gene_symbol(self, gene_symbol: str) -> np.ndarray:
return self.loom_connection[self.get_genes() == gene_symbol, :][0]
Expand Down Expand Up @@ -834,7 +828,7 @@ def get_regulon_genes(self, regulon: str) -> np.ndarray:
return self.get_genes()[self.loom_connection.ra.Regulons[regulon] == 1]
except Exception as err:
logger.error(err)
return []
return np.array([])

def has_regulons_AUC(self) -> bool:
return self.has_legacy_regulons() or self.has_motif_regulons() or self.has_track_regulons()
Expand Down
Loading

0 comments on commit ade6360

Please sign in to comment.