Skip to content

Commit

Permalink
[easy] - fixing all expression matrix saves (#1413)
Browse files Browse the repository at this point in the history
* fixing all expression matrix saves

* Delete barista_decode.py

* fixing lint error

* adding anndata and loompy to travis install

* proper editing of reqs file

* Update test_serialization.py

* removing anndata and loom tests
  • Loading branch information
Shannon Axelrod authored Jun 19, 2019
1 parent 9f0ae37 commit 89dc61e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
28 changes: 28 additions & 0 deletions starfish/core/expression_matrix/test/test_serialization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import random

from starfish import IntensityTable
from starfish.core.codebook.test.factories import codebook_array_factory
from starfish.core.types import Features

NUMBER_SPOTS = 10


def test_save_expression_matrix():

codebook = codebook_array_factory()

intensities = IntensityTable.synthetic_intensities(
codebook,
num_z=3,
height=100,
width=100,
n_spots=10
)
# mock out come cell_ids
cell_ids = random.sample(range(1, 20), NUMBER_SPOTS)
intensities[Features.CELL_ID] = (Features.AXIS, cell_ids)

expression_matrix = intensities.to_expression_matrix()

# test all saving methods
expression_matrix.save("expression")
5 changes: 3 additions & 2 deletions starfish/core/intensity_table/intensity_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,10 +522,11 @@ def to_expression_matrix(self) -> ExpressionMatrix:
counts = grouped.count().iloc[:, 0].unstack().fillna(0)
if self.has_physical_coords:
grouped = self.to_features_dataframe().groupby([Features.CELL_ID])[[
Axes.X, Axes.Y, Axes.ZPLANE, Coordinates.X, Coordinates.Y, Coordinates.Z]]
Axes.X.value, Axes.Y.value, Axes.ZPLANE.value, Coordinates.X.value,
Coordinates.Y.value, Coordinates.Z.value]]
else:
grouped = self.to_features_dataframe().groupby([Features.CELL_ID])[[
Axes.X, Axes.Y, Axes.ZPLANE]]
Axes.X.value, Axes.Y.value, Axes.ZPLANE.value]]
min_ = grouped.min()
max_ = grouped.max()
coordinate_df = min_ + (max_ - min_) / 2
Expand Down

0 comments on commit 89dc61e

Please sign in to comment.