improve graph scale and centering (#796)

* add gutter to embedding canvas

* improve layout scale and translate

* fix lint

* pin tables to version 3.5.1

* fix lasso coordinate smoke tests
This commit is contained in:
Bruce Martin
2019-05-30 13:31:41 -07:00
committed by GitHub
parent ffd7f0db49
commit a6142bdf93
4 changed files with 21 additions and 7 deletions
+14 -1
View File
@@ -442,13 +442,26 @@ class ScanpyEngine(CXGDriver):
Caveats:
* does not support filtering
* only returns Matrix in columnar layout
All embeddings must be individually centered & scaled (isotropically)
to a [0, 1] range.
"""
try:
layout_data = []
for layout in self.config["layout"]:
full_embedding = self.data.obsm[f"X_{layout}"]
embedding = full_embedding[:, :2]
normalized_layout = (embedding - embedding.min()) / (embedding.max() - embedding.min())
# scale isotropically
min = embedding.min(axis=0)
max = embedding.max(axis=0)
scale = np.amax(max - min)
normalized_layout = (embedding - min) / scale
# translate to center on both axis
translate = 0.5 - ((max - min) / scale / 2)
normalized_layout = normalized_layout + translate
normalized_layout = normalized_layout.astype(dtype=np.float32)
layout_data.append(pandas.DataFrame(normalized_layout, columns=[f"{layout}_0", f"{layout}_1"]))
+1 -1
View File
@@ -12,4 +12,4 @@ pandas>=0.23.1
scanpy>=1.3.7
scipy>=1.1.0
scikit-learn>=0.19.1,!=0.20.0
tables>=3.5.1
tables==3.5.1